CoRE and Piston Rules Engine, first design steps

How do you do that?

Sorry about that, I didn’t realize the debug method was overloaded. After taking a closer look, the logging functionality you’re implementing looks great.

I think the “debug” is a bit overkill - log seems to display them all wrong… in a weird order and some are missing. I think they have some kind of throttling on the logs

Context:

No people door involved, and no “sometimes X happens and sometimes y happens issues.”

The problem is that the door is going to open and close twice and he wants to ignore the first close and the second open. That way the yard light will stay on while the dog is outside and turn off after the dog is inside again.

Start with the dog inside the house. The dog door opens, he wants the light to come on now, the dog door closes but he wants the light to stay on. So now the dog is out in the yard, and the dog door is closed, and the light is on.

Then the dog is ready to come back inside the house. The dog door opens, the dog comes inside, the dog door closes, and now he wants the light to go off.

The goal is to have the yard light come on the first time that the dog door is opened, and to stay on until after the dog door is closed the second time.

The part that’s hard to do with regular SmartThings features is ignoring the first close and the second open. :sunglasses:

2 Likes

http://docs.smartthings.com/en/latest/tools-and-ide/github-integration.html

Here is a thread full of challenging use cases.

1 Like

I have probably missed something somewhere along the line but I am still getting errors.
I’m using the app ‘SmartThingers’ and when I try to add an action I get “You are not authorised to perform the requested action”.

That’s what I figured he wants too. The latching example I gave does just that. I also assume the door dog is part of a larger, “human” door. I have ignored that door in the logic.

The latching rule can do that because if you’re using the exact same condition, the rule itself will transition to true on one opening and to false on the second, hence giving him the “every other” effect. Alternatively, a rate limiting algorithm on the event can say “react to every N events”, then he can also do every third, fourth and so on. Of course, he needs every other for this particular example.

This stands:

IF
doggie door opens
THEN
turn light on

BUT IF
doggie door opens

THEN
turn light off in 1 minute

The latching rule evaluates both IF blocks and compares the result with the initial (before the event) state of the latch. Rule starts off FALSE, both IF blocks turn true because they share the same condition. However, only the first THEN executes because the rule was false and it should now be true. The BUT IF THEN block won’t execute because even though the rule state should be set to false (BUT IF evaluates true), the rule was false to begin with, so the state doesn’t “change to” false. Rule ultimately becomes true at the end of the evaluation. Door opens again, the IF THEN block won’t execute (true >>> true, no change), now the BUT IF … THEN executes because rule changes true >>> false

It can be useful when trying to figure out why something isn’t working the way you expect it to, but you’re right, the entries come out in the wrong order and I know it used to skip entries all the time, but I’m not sure if that’s still a problem.

Everything looks great so far and this will probably end up being one of the most powerful and popular SmartApps.

It’s nice seeing so many people working together to design something new instead of just complaining about Rule Machine being gone.

3 Likes

I believe you, but I’m glad I won’t be doing peer assistance on this one. :wink:

2 Likes

This is hard-core logic. Jason can do it. Mom probably won’t.

2 Likes

If you go to Settings and add a new repo ady624 / Rule-Engine / master then you can install the app from there. Whenever I change it, you see a change and can update from repo. Is this the github integration you are talking about?

And if I do fork SmartThingsPublic, then when I push changes, everyone gets the changes automatically? Or would they still have to go to the Update from Repo option?

Thanks

2 Likes

I’m in the UK. We can only dream of github intergration. It does not exist for us and ST do not seem to want to provide it either.

And if you create a new SmartApp and choose from code?

Here’s the code: https://raw.githubusercontent.com/ady624/Rule-Engine/master/smartapps/ady624/piston.src/piston.groovy

What then? What do you see in the live logging? What errors?

Also, this app doesn’t do anything yet :wink: Half way to functional

@ady624

Hey, sorry. I had to peel away from the phone for a while. I haven’t figured out how to get Alexa to paint the fence just yet…

@Toy4Rick and @JDRoberts explained it great.

But I’ll throw in my other 6 pence …

Not a dig door, it’s a human door. The whole thing is designed for at night . If you have a dog like mine, he’s scared of the dark.

This is my dog. His name is Dug.

Ok. It’s dark outside and Dug wants to go out, but like I said it’s dark and there’s a gopher. So when I open the door to let him out the light comes on. I close the door and the light stays on.

If not dug comes running back to the door and pees on the porch.

When he’s done he lets me know it’s time to open the door. I open, he comes in, I close the door, the light finally goes off.

In ST everything is basically bi-stable, except for a few devices. But I don’t see putting a garage door controller on the back door.

So, it took me a little while, but I figured out the logic… And yes I was super excited.

I’ll upload the rule matrix here in a bit so you can use for debugging.

2 Likes

I get it. Take a look at the example rule I gave, I think that’ll do.

1 Like

I think it will.

But don’t worry, when this hits the street I’m going to put it through the paces!

I’ve got some crazy ideas that I’ve done with rule machine and I can’t wait to streamline and do more.

3 Likes

Who wants to be in charge with the name selection for both the parent app and the child app? I’d like to ask the community and have them vote. Whichever name gets more traction will be the new name. I’ll open a new topic for the name voting when I have someone who wants to take ownership of this task.

Meanwhile on ST…

  • been working on the time “description in English” and also time evaluation. Conditions need only figure out if the time is within selection, whereas triggers need to be able to “predict” the next trigger date & time.
  • introducing three new grouping methods, besides AND, OR and XOR:
    1. NOR - NOT OR
    2. NAND - NOT AND
    3. FOLLOWED BY - this is the kicker. Each successive condition has to happen within a certain time limit from the previous one. Anything out of order and the succession resets. Example: Kitchen door changes to ‘open’, FOLLOWED BY Garage door changes to ‘opening’ within 2 minutes.

So, yesterday I was thinking of how I could set a reminder to take the champagne out of the freezer (fast cooling) right before I leave for the beach. Not after I left. I always “prepare” things but then forget to take them with me when leaving the house. Right now, I can have a reminder setup for when presence becomes inactive, but at that point I am already away and would have to turn back. So how do I know when I’m leaving, before I actually leave? My kitchen door leads to the garage, so if I open the kitchen door and then open the garage door, it means I may be leaving home. I want to add a feature to the parent app that allows for Reminders. Was thinking of a separate apps, but I’d like to be able to take advantage of the power of the child app. So when I open the kitchen door and then open the garage door, fire up a push notification or an SMS to remind me of whatever I need reminding of. Then delete the reminders automatically. I’d know I forgot something before or while getting to the car, not while I’m already zooming by through the green (more like yellow-ish LOL) light at a big intersection :wink: :wink:

I’ll have a few questions about the FOLLOWED BY later, when I implement it. One of them is: I have “IF A happens FOLLOWED BY B happens WITHIN 5 min FOLLOWED BY C happens WITHIN 5 min” and I have A happening, then B happening then A happening again, but still in time for C to happen, do I reset the succession of would a subsequent C happening within its allotted time limit still be considered as a success? i.e. Would A --1min–> B --1min–> A --1min–> C satisfy the condition? Technically speaking, B did happen within 5 minutes of A happening and then C happened within 5 minutes of B happening. It’s just that A happened again between B and C. Or would I have to be strict and have only A --1min–> B --1min–> C satisfy it? The 1min things show time laps less than the WITHIN limit.

4 Likes

I can babysit that thread…

4 Likes

Thank you. I’ll open the topic, or would you rather open it?