Creating an On-Off-On Sequence


#1

1) Give a description of the problem
I’ve got a set of lamps with LED bulbs in them. The LED bulbs are either completely illuminated, or display a flame animation. This behavior alternates between each power cycle. Turn it on, and you get flames. Turn it off, then back on, and you get full illumination.

I only want the flames to appear, so I’m trying to build a piston that turns the light off for a couple of seconds and then back on every time a command is sent to turn the lights on, effectively “skipping” the completely illuminated mode of the bulbs. I recognize the potential to accidentally build a recursive loop with something like this, so my piston uses a variable to attempt to avoid that problem.

2) What is the expected behavior?
If a command is sent via any source - or even at the switch - the variable FlameWait is set to “true”, the lights are illuminated for 2 seconds, the lights turn off for two seconds, then the lights turn back on and remain lit. The FlameWait variable is then set to “false.”

3) What is happening/not happening?
When an “on” command is sent, the lights turn on for 2 seconds, then back off, and they stay off.

4) Post a Green Snapshot of the piston![image|45x37](

)
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
6249cdc5-f19b-4040-94d2-8b8ba92c1291 10:33:42 AM: debug getChildDevices(false), children=4 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: trace ║╚ Execution stage started 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: debug ║║ Cancelling condition #9's schedules... 70253b46-5e72-49ba-b7b1-0e2f25998f0c 10:33:39 AM: info smartapp_pause called by smartAppName=webCoRE, value=250, smartAppVersionId=7deb3230-7ab6-4a7d-8a4c-5ae0628d117b 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: trace ║ Runtime (37680 bytes) successfully initialized in 2075ms (v0.2.0fe.20171109) (2126ms) 70253b46-5e72-49ba-b7b1-0e2f25998f0c 10:33:40 AM: info smartapp_pause called by smartAppName=webCoRE, value=250, smartAppVersionId=7deb3230-7ab6-4a7d-8a4c-5ae0628d117b 70253b46-5e72-49ba-b7b1-0e2f25998f0c 10:33:38 AM: info smartapp_pause called by smartAppName=webCoRE, value=250, smartAppVersionId=7deb3230-7ab6-4a7d-8a4c-5ae0628d117b 70253b46-5e72-49ba-b7b1-0e2f25998f0c 10:33:39 AM: info smartapp_pause called by smartAppName=webCoRE, value=250, smartAppVersionId=7deb3230-7ab6-4a7d-8a4c-5ae0628d117b 70253b46-5e72-49ba-b7b1-0e2f25998f0c 10:33:38 AM: info smartapp_pause called by smartAppName=webCoRE, value=250, smartAppVersionId=7deb3230-7ab6-4a7d-8a4c-5ae0628d117b 70253b46-5e72-49ba-b7b1-0e2f25998f0c 10:33:38 AM: info smartapp_pause called by smartAppName=webCoRE, value=250, smartAppVersionId=7deb3230-7ab6-4a7d-8a4c-5ae0628d117b 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:38 AM: info ╚ Received event [Outside Four Front Yard Lights].switch = off with a delay of 71ms 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: trace ║╔ Execution stage complete. (4118ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:38 AM: debug ║║ Executed physical command [Outside Four Front Yard Lights].off() (38ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: info smartapp_pause called by smartAppName=webCoRE Piston, value=2000, smartAppVersionId=afdc192d-d0a1-4ab5-8639-5014088767bd 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: info ╔ Event processed successfully (4225ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: trace ║║ Waiting for 2000ms 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: trace ║║ Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: trace ║║ Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:40 AM: trace ║║ Executed virtual command [Outside Four Front Yard Lights].toggle (25ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Cancelling statement #2's schedules... 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:38 AM: info smartapp_pause called by smartAppName=webCoRE Piston, value=2000, smartAppVersionId=afdc192d-d0a1-4ab5-8639-5014088767bd 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Cancelling condition #1's schedules... 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Comparison (boolean) false is_not (boolean) true = true (1ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: trace ║║ Executed virtual command [Outside Four Front Yard Lights].wait (1ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Condition #9 evaluated true (8ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Condition group #1 evaluated true (state changed) (19ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Condition #10 evaluated true (8ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Comparison (enum) on changes_to (string) on = true (1ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║║ Cancelling condition #9's schedules... 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: debug ║ RunTime Analysis CS > 16ms > PS > 50ms > PE > 21ms > CE 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: trace ║╚ Execution stage started 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: trace ║ Runtime (37608 bytes) successfully initialized in 50ms (v0.2.0fe.20171109) (97ms) 15b540af-904e-4142-89cb-dd46b0e830aa 10:33:36 AM: info ╚ Received event [Outside Four Front Yard Lights].switch = on with a delay of 102ms 3c4f0b2c-9255-40f3-82f3-5fc79691f9a2 10:33:38 AM: debug switch off1 30159896-1146-46bc-8fc6-6e9e81247e7b 10:33:38 AM: debug sending data to AT 30159896-1146-46bc-8fc6-6e9e81247e7b 10:33:38 AM: debug A sensor event occurred: [name:switch, deviceId:5d2f7491-8e2c-4c2a-815f-2c38c9115bad, isoDate:2017-11-27T18:33:38.216Z, unit:null, value:off] 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:38 AM: debug RegIDs triggered: [eP64vcyRYE8:APA91bE2P_N0X4FMhif1Vzp4glnThJRz1s7MyVAApMXGWiTl_jFdOuEFsEPvs2_hImwV1JZDusZzxU8ObAdHcEUoTk67INkeZnHl4kWH_Swl44XweYT3YmbNmWTPwl78zS5rok41-baa] 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:38 AM: debug Event data successfully posted 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:38 AM: debug device info: [switch:[eP64vcyRYE8:APA91bE2P_N0X4FMhif1Vzp4glnThJRz1s7MyVAApMXGWiTl_jFdOuEFsEPvs2_hImwV1JZDusZzxU8ObAdHcEUoTk67INkeZnHl4kWH_Swl44XweYT3YmbNmWTPwl78zS5rok41-baa]] 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:38 AM: debug event triggered for switch on 5d2f7491-8e2c-4c2a-815f-2c38c9115bad 6249cdc5-f19b-4040-94d2-8b8ba92c1291 10:33:38 AM: trace Harmony - Sending data to Living Room Harmony Hub 3c4f0b2c-9255-40f3-82f3-5fc79691f9a2 10:33:36 AM: debug switch on1 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:36 AM: debug RegIDs triggered: [eP64vcyRYE8:APA91bE2P_N0X4FMhif1Vzp4glnThJRz1s7MyVAApMXGWiTl_jFdOuEFsEPvs2_hImwV1JZDusZzxU8ObAdHcEUoTk67INkeZnHl4kWH_Swl44XweYT3YmbNmWTPwl78zS5rok41-baa] 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:36 AM: debug Event data successfully posted 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:36 AM: debug device info: [switch:[eP64vcyRYE8:APA91bE2P_N0X4FMhif1Vzp4glnThJRz1s7MyVAApMXGWiTl_jFdOuEFsEPvs2_hImwV1JZDusZzxU8ObAdHcEUoTk67INkeZnHl4kWH_Swl44XweYT3YmbNmWTPwl78zS5rok41-baa]] 9788bd5c-b96c-49f5-8fb2-67307295fe9e 10:33:36 AM: debug event triggered for switch on 5d2f7491-8e2c-4c2a-815f-2c38c9115bad 30159896-1146-46bc-8fc6-6e9e81247e7b 10:33:36 AM: debug sending data to AT 30159896-1146-46bc-8fc6-6e9e81247e7b 10:33:36 AM: debug A sensor event occurred: [name:switch, deviceId:5d2f7491-8e2c-4c2a-815f-2c38c9115bad, isoDate:2017-11-27T18:33:35.948Z, unit:null, value:on] 6249cdc5-f19b-4040-94d2-8b8ba92c1291 10:33:35 AM: trace Harmony - Sending data to Living Room Harmony Hub 30159896-1146-46bc-8fc6-6e9e81247e7b 10:33:35 AM: debug command on executed successfully 30159896-1146-46bc-8fc6-6e9e81247e7b 10:33:35 AM: info executing '/device/5d2f7491-8e2c-4c2a-815f-2c38c9115bad/on' endpoint 2ca3ab55-7ea1-4890-8f50-1adcd7e2200b 10:33:34 AM: error groovy.lang.MissingMethodException: No signature of method: script_dth_2a3fbc49_4c44_4096_b250_efceea80c729_ver_0_1.zwaveEvent() is applicable for argument types: (physicalgraph.zwave.commands.manufacturerspecificv1.ManufacturerSpecificReport) values: [ManufacturerSpecificReport(manufacturerId: 265, manufacturerName: Vision Security, productId: 5911, productTypeId: 8215)] Possible solutions: zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport), zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap), zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport), createEvent(java.util.Map) 167f784c-9d98-4040-a500-58be13e68261 10:33:13 AM: debug getChildDevices(false), children=1 10:32:56 AM: info Waiting on events...


#2

Can you take your logs from the webcore browser not the IDE please… when viewing the piston preview page, below the green snapshot button, turn on full logging and then fire the piston.


#3

Sorry 'bout that… Here you go.

11/27/2017, 10:36:30 AM +855ms
+83ms ╔Stopping piston…
+212ms ╚Piston successfully stopped (129ms)
11/27/2017, 10:33:38 AM +287ms
+2ms ╔Received event [Outside Four Front Yard Lights].switch = off with a delay of 71ms
+2119ms ║RunTime Analysis CS > 15ms > PS > 2075ms > PE > 29ms > CE
+2126ms ║Piston waited at a semaphore for 2023ms
+2128ms ║Runtime (37680 bytes) successfully initialized in 2075ms (v0.2.0fe.20171109) (2126ms)
+2129ms ║╔Execution stage started
+2141ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+2143ms ║║Cancelling condition #9’s schedules…
+2143ms ║║Condition #9 evaluated false (8ms)
+2144ms ║║Cancelling condition #1’s schedules…
+2145ms ║║Condition group #1 evaluated false (state changed) (10ms)
+2148ms ║╚Execution stage complete. (18ms)
+2155ms ╚Event processed successfully (2155ms)
11/27/2017, 10:33:36 AM +50ms
+2ms ╔Received event [Outside Four Front Yard Lights].switch = on with a delay of 102ms
+88ms ║RunTime Analysis CS > 16ms > PS > 50ms > PE > 21ms > CE
+100ms ║Runtime (37608 bytes) successfully initialized in 50ms (v0.2.0fe.20171109) (97ms)
+101ms ║╔Execution stage started
+114ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+116ms ║║Cancelling condition #9’s schedules…
+117ms ║║Condition #9 evaluated true (8ms)
+123ms ║║Comparison (boolean) false is_not (boolean) true = true (1ms)
+125ms ║║Condition #10 evaluated true (8ms)
+126ms ║║Cancelling condition #1’s schedules…
+127ms ║║Condition group #1 evaluated true (state changed) (19ms)
+129ms ║║Cancelling statement #2’s schedules…
+135ms ║║Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms)
+139ms ║║Executed virtual command [Outside Four Front Yard Lights].wait (1ms)
+140ms ║║Waiting for 2000ms
+2180ms ║║Executed physical command [Outside Four Front Yard Lights].off() (38ms)
+2181ms ║║Executed [Outside Four Front Yard Lights].off (40ms)
+2185ms ║║Executed virtual command [Outside Four Front Yard Lights].wait (1ms)
+2186ms ║║Waiting for 2000ms
+4211ms ║║Executed physical command [Outside Four Front Yard Lights].off() (22ms)
+4212ms ║║Executed virtual command [Outside Four Front Yard Lights].toggle (25ms)
+4216ms ║║Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms)
+4219ms ║╚Execution stage complete. (4118ms)
+4225ms ╚Event processed successfully (4225ms)
11/27/2017, 10:19:10 AM +440ms
+2ms ╔Received event [Outside Four Front Yard Lights].switch = off with a delay of 65ms
+2127ms ║RunTime Analysis CS > 22ms > PS > 2073ms > PE > 31ms > CE
+2132ms ║Piston waited at a semaphore for 2023ms
+2134ms ║Runtime (37680 bytes) successfully initialized in 2073ms (v0.2.0fe.20171109) (2132ms)
+2135ms ║╔Execution stage started
+2149ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+2151ms ║║Cancelling condition #9’s schedules…
+2152ms ║║Condition #9 evaluated false (9ms)
+2153ms ║║Cancelling condition #1’s schedules…
+2154ms ║║Condition group #1 evaluated false (state changed) (11ms)
+2156ms ║╚Execution stage complete. (21ms)
+2163ms ╚Event processed successfully (2163ms)
11/27/2017, 10:19:08 AM +192ms
+1ms ╔Received event [Outside Four Front Yard Lights].switch = on with a delay of 78ms
+111ms ║RunTime Analysis CS > 17ms > PS > 53ms > PE > 42ms > CE
+118ms ║Runtime (37611 bytes) successfully initialized in 53ms (v0.2.0fe.20171109) (116ms)
+119ms ║╔Execution stage started
+132ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+133ms ║║Cancelling condition #9’s schedules…
+134ms ║║Condition #9 evaluated true (8ms)
+141ms ║║Comparison (boolean) false is_not (boolean) true = true (2ms)
+143ms ║║Condition #10 evaluated true (8ms)
+144ms ║║Cancelling condition #1’s schedules…
+145ms ║║Condition group #1 evaluated true (state changed) (19ms)
+147ms ║║Cancelling statement #2’s schedules…
+153ms ║║Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms)
+157ms ║║Executed virtual command [Outside Four Front Yard Lights].wait (1ms)
+158ms ║║Waiting for 2000ms
+2203ms ║║Executed physical command [Outside Four Front Yard Lights].off() (43ms)
+2204ms ║║Executed [Outside Four Front Yard Lights].off (45ms)


#4

Aaahhhhaaaa… I see now.

The states of each switch only update at the start of every execution, a new subscription is built at the end of the run.

The toggle command therefore does not know the light has been turned off (from the off command in the same piston run), thinks the light is still on and sends an off command for the toggle.

Change ‘toggle’ to ‘turn on’ and you will be good.


#5

I do believe however that a ‘wait’ longer than 3 seconds causes an update of states, same as the piston re-firing… The pistons schedules itself to wake up for longer waits and carries on where it left off… this avoids clashing with the 20sec runtime rule that ST imposes.

Waits below 3 seconds and the piston stays awake and wont update till the next run.


#6

THanks for the help, Robin.

Changed “toggle” to “turn on”, and changed both wait times from 2 seconds to 4 seconds. Same result, logs below.

11/27/2017, 11:48:05 AM +86ms
+2ms ╔Received event [Outside Four Front Yard Lights].switch = off with a delay of 67ms
+4187ms ║RunTime Analysis CS > 15ms > PS > 4137ms > PE > 35ms > CE
+4194ms ║Piston waited at a semaphore for 4088ms
+4196ms ║Runtime (37676 bytes) successfully initialized in 4137ms (v0.2.0fe.20171109) (4193ms)
+4197ms ║╔Execution stage started
+4210ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+4212ms ║║Cancelling condition #9’s schedules…
+4213ms ║║Condition #9 evaluated false (9ms)
+4214ms ║║Cancelling condition #1’s schedules…
+4215ms ║║Condition group #1 evaluated false (state changed) (11ms)
+4218ms ║╚Execution stage complete. (20ms)
+4225ms ╚Event processed successfully (4225ms)
11/27/2017, 11:48:00 AM +843ms
+1ms ╔Received event [Outside Four Front Yard Lights].switch = on with a delay of 70ms
+101ms ║RunTime Analysis CS > 21ms > PS > 53ms > PE > 27ms > CE
+110ms ║Runtime (37604 bytes) successfully initialized in 53ms (v0.2.0fe.20171109) (107ms)
+111ms ║╔Execution stage started
+125ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+127ms ║║Cancelling condition #9’s schedules…
+127ms ║║Condition #9 evaluated true (9ms)
+135ms ║║Comparison (boolean) false is_not (boolean) true = true (2ms)
+137ms ║║Condition #10 evaluated true (9ms)
+138ms ║║Cancelling condition #1’s schedules…
+139ms ║║Condition group #1 evaluated true (state changed) (21ms)
+142ms ║║Cancelling statement #2’s schedules…
+149ms ║║Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms)
+153ms ║║Executed virtual command [Outside Four Front Yard Lights].wait (1ms)
+154ms ║║Waiting for 4000ms
+4189ms ║║Executed physical command [Outside Four Front Yard Lights].off() (33ms)
+4190ms ║║Executed [Outside Four Front Yard Lights].off (34ms)
+4193ms ║║Executed virtual command [Outside Four Front Yard Lights].wait (0ms)
+4194ms ║║Waiting for 4000ms
+8198ms ║║Skipped execution of physical command [Outside Four Front Yard Lights].on([]) because it would make no change to the device. (2ms)
+8199ms ║║Executed [Outside Four Front Yard Lights].on (3ms)
+8204ms ║║Executed virtual command [Outside Four Front Yard Lights].setVariable (1ms)
+8207ms ║╚Execution stage complete. (8097ms)
+8215ms ╚Event processed successfully (8214ms)
11/27/2017, 11:47:32 AM +754ms
+6ms ╔Starting piston… (v0.2.0fe.20171109)
+215ms ║╔Subscribing to devices…
+252ms ║║Subscribing to Outside Four Front Yard Lights.switch…
+486ms ║╚Finished subscribing (275ms)
+571ms ║Comparison (boolean) false is_not (boolean) true = true (6ms)
+603ms ╚Piston successfully started (598ms)


#7

Click on the ‘with’, click the cog symbol and change task cancellation policy (TCP) to ‘never cancel’.

I think the toggling light is causing the piston to re-fire too soon, sees a false and cancels after the wait.


#8

Still no love…


#9

Just throwing this out there - a kludgy approach, but that’s what I’m all about. :slight_smile: If you can’t work out an approach that works, what if you set a flash sequence with one flash (on/off) and then followed that with a single “on” command?


#10

This is what eventually solved it. Here’s what worked for me:


#11

Cool… It would have been even cooler if there was a way to end a flash event w/the light on, :slight_smile:


#12

Definitely. I looked, but didn’t see how that was possible. Still finally got it nailed down. It even got stuck in a loop a few times until I got the timings set up right. Thanks again.