CoRE and Piston Rules Engine, first design steps

@eibyer
I have similar rules but I do not use the ‘ELSE’ statement.
Don’t know why I try to keep all my rules away from the ELSE statement.
Under THEN I go:-
Turn On
Wait for False
Turn Off

Works OK for me.

Oh. I thought I HAD excluded those from the list. I will fix that! Sorry for the confusion.

1 Like

@bobbles That’s an interesting approach on that and it makes sense looking at how it’s set up. This is my log for the test I performed at 1130a.

f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎10‎ ‎AM: trace ╔═══ Task processing took 3537ms 
f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎10‎ ‎AM: trace ║░░░ Removing any existing ST safety nets 
f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎10‎ ‎AM: info ║░░░ Executing command: [Living Room Fan].on() (35ms) 
f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎09‎ ‎AM: info ║░░░ Scheduling ST to run in 39590s, at Sat, Jun 11 2016 @ 10:30 PM MST 
f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎09‎ ‎AM: trace ║░░░ Rescheduling time triggers 
f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎09‎ ‎AM: trace ║╔══ Event processing took 1733ms 
f73464db-bfc1-4517-bd0a-6a2772e6d648  ‎11‎:‎30‎:‎08‎ ‎AM: info ║║░░ ♦ Simple Piston changed state to true ♦ 

Is it supposed to schedule the next OFF and ON or just the OFF, then ON will be rescheduled after that?

TBH I don’t know.
All I know is that this approach works for me.

This is the type of rule I have set up.

I know what the problem is. The ST job scheduler sometimes runs early and time is not yet past the required time. Will fix that by adding a second to the scheduled time.

A time condition will automatically schedule two triggering, one at interval start, one at interval end. This is by design. Your piston did the right thing, turned the fan on and planned for a new evaluation at 10:30pm. It just happens that sometimes the job runs at 10:29:59pm and, well, the evaluation is again true. I have to compensate for that.

1 Like

@ady624
Because of how you have written the code, which way of doing the same job do you think is best.
Wait for a ‘false’ to happen or use an ‘ELSE’.

No, never went back to red.
Clear
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:56 PM: trace ╔═══ Task processing took 1472ms
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:56 PM: trace ║░░░ Removing any existing ST safety nets
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:56 PM: info ║░░░ Executing virtual command loadStateLocally (1128ms)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:55 PM: info ║░░░ Executing [Gardenspot].setLevel(100)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:55 PM: info ║░░░ Executing [Gardenspot].setHue(26.96078618367513)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:54 PM: trace ║░░░ Installing ST safety net
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:54 PM: trace ║░░░ Rescheduling time triggers
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:54 PM: trace ╚═══ Processing tasks (v0.0.086.20160611)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:29 PM: trace ╔═══ Task processing took 304ms
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:29 PM: trace ║░░░ Removing any existing ST safety nets
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:29 PM: info ║░░░ Scheduling ST to run in 24s, at Sat, Jun 11 2016 @ 3:09 PM EDT
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:28 PM: trace ║░░░ Rescheduling time triggers
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:28 PM: trace ╚═══ Processing tasks (v0.0.086.20160611)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:28 PM: trace ╔═══ Event processing took 266ms
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:28 PM: info ║░░░ :diamonds: Basic Piston changed state to false :diamonds:
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:28 PM: trace ╚═══ Processing event motion for device Front Entry Motion with id 0ca45562-aa7c-4744-a6ee-af5fa43ba0e4, value inactive, generated on Sat Jun 11 19:09:24 UTC 2016, about 3665ms ago (v0.0.086.20160611)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: trace ╔═══ Task processing took 626ms
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: trace ║░░░ Removing any existing ST safety nets
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: info ║░░░ Executing command: [Gardenspot].setColor([hue:2E+1, saturation:80, level:72]) (210ms)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: info ║░░░ Executing virtual command saveStateLocally (27ms)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: trace ║░░░ Installing ST safety net
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: info ║░░░ Scheduling ST to run in 30s, at Sat, Jun 11 2016 @ 3:09 PM EDT
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: trace ║░░░ Rescheduling time triggers
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: trace ╚═══ Processing tasks (v0.0.086.20160611)
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:23 PM: trace ╔═══ Event processing took 388ms
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:22 PM: info ║░░░ :diamonds: Basic Piston changed state to true :diamonds:
b8bf3551-2a33-461d-a810-48ffa5434b2c 3:09:22 PM: trace ╚═══ Processing event motion for device Front Entry Motion with id 0ca45562-aa7c-4744-a6ee-af5fa43ba0e4, value active, generated on Sat Jun 11 19:09:18 UTC 2016, about 4103ms ago (v0.0.086.20160611)

I actually changed my mind on this…I have added to the next version the ability to trigger off of Macro Groups as well…I thought of some use cases that justify it. Thanks to @davew44 for bringing this up.

2 Likes

Matter of preference, really

OK. Thanks.

You need to both capture and restore saturation. Please try to enclose logs in code, use the code button in the editor.

I had already cut your code snippet in and was testing, Most macros work but not ‘its bedtime’ that kicked all this off. I get the message
"response": {
“outputSpeech”: {
“type”: “PlainText”,
“text”: "There was error with the Ask Alexa SmartApp execution. If this continues, please contact the author of the SmartApp. "
},
“card”: {
“content”: "There was error with the Ask Alexa SmartApp execution. If this continues, please contact the author of the SmartApp. ",
“title”: “SmartThings Voice Macro”,
“type”: “Simple”
},
“shouldEndSession”: true
}
}

Should I wait for your new code release ? Or swap the original code lines back in from githib 2.0.0c

I sent you a PM, but revert back to the GitHub code and try those lines…

If you get that error in normal , however, it means something else… First test your macro without any new stuff, then put those replacement lines in. Let’s take this to PM as not to disrupt this thread.

Sorry, I don’t see a code button. I tried to capture saturation and got the same result. I tried switching to another device handler but no progress there either. I appreciate your help but I don’t want to waste any more of your time on this. I can work around it with using a standard color to revert to. Thanks again.

Go to your Restore task and select saturation there. You are “capturing” it but never using it.

Hey Adi, basic question for a basic piston. Do I need cancel for IF, THEN. My piston worked the first time and nothing after that. Thought I’d ask before I start looking around for other reasons…

I put it back and tried all the combinations I can think of (attributes) but the lights don’t change back. The logs show the states being loaded, but nothing happens. :frowning:

I successfully had the piston change the color to a preset color after the timer, but can’t restore the previous color.

Three axis control, especially now that you have state capture and recall!

1 Like