Why isn't my dryer running piston firing?


#1
  1. Give a description of the problem
    I created a piston trying to detect when the dryer is running. It has a number of conditions (temperature, persistent vibration, variable value, contact sensor closed), and they all seem to be met.

2) What is the expected behaviour?
The piston fires, setting a variable and flipping a virtual switch

3) What is happening/not happening?
The piston doesn’t fire

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

5) Attach logs after turning logging level to Full
3/19/2020, 3:41:38 PM +66ms
+0ms ╔Received event [Home].time = 1584650499670 with a delay of -1605ms
+97ms ║RunTime Analysis CS > 17ms > PS > 41ms > PE > 39ms > CE
+99ms ║Runtime (43353 bytes) successfully initialized in 41ms (v0.3.110.20191009) (98ms)
+100ms ║╔Execution stage started
+107ms ║║Cancelling condition #25’s schedules…
+108ms ║║Condition #25 evaluated true (1ms)
+117ms ║║Comparison (enum) open is (string) closed = false (2ms)
+118ms ║║Cancelling condition #26’s schedules…
+119ms ║║Condition #26 evaluated false (10ms)
+120ms ║║Condition group #24 evaluated false (state did not change) (15ms)
+128ms ║║Comparison (string) opened is (string) running = false (1ms)
+130ms ║║Cancelling condition #14’s schedules…
+131ms ║║Condition #14 evaluated false (7ms)
+132ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+140ms ║║Cancelling condition #19’s schedules…
+141ms ║║Condition #19 evaluated false (7ms)
+142ms ║║Cancelling condition #18’s schedules…
+143ms ║║Condition group #18 evaluated false (state changed) (8ms)
+145ms ║╚Execution stage complete. (44ms)
+146ms ╚Event processed successfully (147ms)
3/19/2020, 3:41:24 PM +477ms
+1ms ╔Received event [Dryer Sensor].contact = open with a delay of 91ms
+168ms ║RunTime Analysis CS > 18ms > PS > 107ms > PE > 43ms > CE
+170ms ║Runtime (43361 bytes) successfully initialized in 107ms (v0.3.110.20191009) (168ms)
+171ms ║╔Execution stage started
+183ms ║║Comparison (decimal) 80.0 is_greater_than (integer) 75 = true (1ms)
+184ms ║║Condition #2 evaluated true (8ms)
+191ms ║║Comparison (enum) active stays (string) active = true (2ms)
+193ms ║║Adding a timed trigger schedule for condition 25
+195ms ║║Cancelling condition #25’s schedules…
+196ms ║║Condition #25 evaluated false (11ms)
+197ms ║║Cancelling condition #24’s schedules…
+198ms ║║Condition group #24 evaluated false (state changed) (22ms)
+203ms ║║Comparison (string) running is (string) running = true (1ms)
+205ms ║║Condition #14 evaluated true (4ms)
+211ms ║║Comparison (enum) active stays (string) inactive = false (1ms)
+213ms ║║Cancelling any timed trigger schedules for condition 17
+214ms ║║Cancelling statement #17’s schedules…
+215ms ║║Condition #17 evaluated false (10ms)
+216ms ║║Condition group #1 evaluated false (state did not change) (16ms)
+221ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+222ms ║║Cancelling condition #19’s schedules…
+223ms ║║Condition #19 evaluated true (5ms)
+224ms ║║Cancelling condition #18’s schedules…
+225ms ║║Condition group #18 evaluated true (state changed) (7ms)
+227ms ║║Cancelling statement #20’s schedules…
+233ms ║║Skipped execution of physical command [Warning lamp].off([]) because it would make no change to the device. (2ms)
+234ms ║║Executed [Warning lamp].off (4ms)
+236ms ║║Cancelling statement #22’s schedules…
+240ms ║║Executed virtual command setVariable (0ms)
+242ms ║╚Execution stage complete. (71ms)
+244ms ║Setting up scheduled job for Thu, Mar 19 2020 @ 3:41:39 PM CDT (in 14.95s)
+253ms ╚Event processed successfully (253ms)
3/19/2020, 3:41:22 PM +89ms
+1ms ╔Received event [Home].time = 1584650483737 with a delay of -1648ms
+152ms ║RunTime Analysis CS > 28ms > PS > 84ms > PE > 39ms > CE
+154ms ║Runtime (43361 bytes) successfully initialized in 84ms (v0.3.110.20191009) (152ms)
+155ms ║╔Execution stage started
+161ms ║║Cancelling condition #25’s schedules…
+162ms ║║Condition #25 evaluated true (1ms)
+168ms ║║Comparison (enum) closed is (string) closed = true (2ms)
+169ms ║║Condition #26 evaluated true (7ms)
+174ms ║║Comparison (string) opened is_not (string) running = true (1ms)
+175ms ║║Condition #27 evaluated true (5ms)
+176ms ║║Cancelling condition #24’s schedules…
+177ms ║║Condition group #24 evaluated true (state changed) (16ms)
+179ms ║║Cancelling statement #31’s schedules…
+185ms ║║Skipped execution of physical command [VFSDryer].on([]) because it would make no change to the device. (2ms)
+186ms ║║Executed [VFSDryer].on (4ms)
+189ms ║║Cancelling statement #10’s schedules…
+814ms ║║Executed physical command [Echo - Korey’s Echo Show].playTextAndRestore([The dryer is now running, 100]) (616ms)
+815ms ║║Executed [Echo - Korey’s Echo Show].playTextAndRestore (618ms)
+817ms ║║Cancelling statement #33’s schedules…
+821ms ║║Executed virtual command setVariable (0ms)
+827ms ║║Comparison (string) running is (string) running = true (1ms)
+828ms ║║Cancelling condition #14’s schedules…
+829ms ║║Condition #14 evaluated true (6ms)
+836ms ║║Comparison (enum) active stays (string) inactive = false (2ms)
+838ms ║║Cancelling any timed trigger schedules for condition 17
+838ms ║║Cancelling statement #17’s schedules…
+839ms ║║Condition #17 evaluated false (10ms)
+840ms ║║Condition group #1 evaluated false (state did not change) (17ms)
+848ms ║║Condition #19 evaluated false (5ms)
+848ms ║║Condition group #18 evaluated false (state did not change) (6ms)
+850ms ║╚Execution stage complete. (695ms)
+851ms ╚Event processed successfully (851ms)
3/19/2020, 3:41:15 PM +616ms
+1ms ╔Received event [Dryer Sensor].contact = closed with a delay of 175ms
+128ms ║RunTime Analysis CS > 22ms > PS > 62ms > PE > 44ms > CE
+131ms ║Runtime (43356 bytes) successfully initialized in 62ms (v0.3.110.20191009) (129ms)
+132ms ║╔Execution stage started
+142ms ║║Comparison (decimal) 80.0 is_greater_than (integer) 75 = true (1ms)
+144ms ║║Condition #2 evaluated true (8ms)
+150ms ║║Comparison (enum) active stays (string) active = true (1ms)
+152ms ║║Condition #25 evaluated false (8ms)
+153ms ║║Condition group #24 evaluated false (state did not change) (18ms)
+159ms ║║Comparison (string) opened is (string) running = false (1ms)
+160ms ║║Cancelling condition #14’s schedules…
+161ms ║║Condition #14 evaluated false (6ms)
+162ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+167ms ║║Comparison (enum) closed changes_to (string) open = false (0ms)
+168ms ║║Cancelling condition #19’s schedules…
+169ms ║║Condition #19 evaluated false (5ms)
+170ms ║║Cancelling condition #18’s schedules…
+171ms ║║Condition group #18 evaluated false (state changed) (6ms)
+173ms ║╚Execution stage complete. (42ms)
+174ms ║Setting up scheduled job for Thu, Mar 19 2020 @ 3:41:23 PM CDT (in 7.947s)
+188ms ╚Event processed successfully (188ms)
3/19/2020, 3:41:08 PM +586ms
+2ms ╔Received event [Dryer Sensor].contact = open with a delay of 180ms
+125ms ║RunTime Analysis CS > 20ms > PS > 55ms > PE > 49ms > CE
+127ms ║Runtime (43359 bytes) successfully initialized in 55ms (v0.3.110.20191009) (125ms)
+128ms ║╔Execution stage started
+140ms ║║Comparison (decimal) 80.0 is_greater_than (integer) 75 = true (2ms)
+141ms ║║Condition #2 evaluated true (9ms)
+149ms ║║Comparison (enum) active stays (string) active = true (2ms)
+151ms ║║Adding a timed trigger schedule for condition 25
+153ms ║║Cancelling condition #25’s schedules…
+154ms ║║Condition #25 evaluated false (11ms)
+155ms ║║Cancelling condition #24’s schedules…
+156ms ║║Condition group #24 evaluated false (state changed) (24ms)
+162ms ║║Comparison (string) running is (string) running = true (1ms)
+163ms ║║Condition #14 evaluated true (5ms)
+170ms ║║Comparison (enum) active stays (string) inactive = false (2ms)
+172ms ║║Cancelling any timed trigger schedules for condition 17
+173ms ║║Cancelling statement #17’s schedules…
+174ms ║║Condition #17 evaluated false (10ms)
+175ms ║║Condition group #1 evaluated false (state did not change) (17ms)
+181ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+182ms ║║Cancelling condition #19’s schedules…
+183ms ║║Condition #19 evaluated true (5ms)
+184ms ║║Cancelling condition #18’s schedules…
+185ms ║║Condition group #18 evaluated true (state changed) (8ms)
+187ms ║║Cancelling statement #20’s schedules…
+193ms ║║Skipped execution of physical command [Warning lamp].off([]) because it would make no change to the device. (2ms)
+194ms ║║Executed [Warning lamp].off (4ms)
+197ms ║║Cancelling statement #22’s schedules…
+200ms ║║Executed virtual command setVariable (1ms)
+203ms ║╚Execution stage complete. (75ms)
+204ms ║Setting up scheduled job for Thu, Mar 19 2020 @ 3:41:23 PM CDT (in 14.947s)
+213ms ╚Event processed successfully (212ms)
3/19/2020, 3:40:08 PM +178ms
+0ms ╔Received event [Home].time = 1584650409632 with a delay of -1455ms
+172ms ║RunTime Analysis CS > 51ms > PS > 85ms > PE > 36ms > CE
+175ms ║Runtime (43360 bytes) successfully initialized in 85ms (v0.3.110.20191009) (173ms)
+176ms ║╔Execution stage started
+183ms ║║Cancelling condition #25’s schedules…
+184ms ║║Condition #25 evaluated true (1ms)
+192ms ║║Comparison (enum) closed is (string) closed = true (1ms)
+194ms ║║Cancelling condition #26’s schedules…
+195ms ║║Condition #26 evaluated true (11ms)
+200ms ║║Comparison (string) opened is_not (string) running = true (2ms)
+201ms ║║Condition #27 evaluated true (6ms)
+203ms ║║Cancelling condition #24’s schedules…
+204ms ║║Condition group #24 evaluated true (state changed) (23ms)
+207ms ║║Cancelling statement #31’s schedules…
+213ms ║║Skipped execution of physical command [VFSDryer].on([]) because it would make no change to the device. (3ms)
+214ms ║║Executed [VFSDryer].on (5ms)
+217ms ║║Cancelling statement #10’s schedules…
+985ms ║║Executed physical command [Echo - Korey’s Echo Show].playTextAndRestore([The dryer is now running, 100]) (761ms)
+987ms ║║Executed [Echo - Korey’s Echo Show].playTextAndRestore (762ms)
+990ms ║║Cancelling statement #33’s schedules…
+996ms ║║Executed virtual command setVariable (1ms)
+1006ms ║║Comparison (string) running is (string) running = true (3ms)
+1008ms ║║Cancelling condition #14’s schedules…
+1009ms ║║Condition #14 evaluated true (8ms)
+1020ms ║║Comparison (enum) active stays (string) inactive = false (2ms)
+1023ms ║║Cancelling any timed trigger schedules for condition 17
+1024ms ║║Cancelling statement #17’s schedules…
+1025ms ║║Cancelling condition #17’s schedules…
+1026ms ║║Condition #17 evaluated false (16ms)
+1027ms ║║Condition group #1 evaluated false (state did not change) (27ms)
+1035ms ║║Condition #19 evaluated false (4ms)
+1036ms ║║Condition group #18 evaluated false (state did not change) (6ms)
+1038ms ║╚Execution stage complete. (862ms)
+1039ms ╚Event processed successfully (1040ms)
3/19/2020, 3:39:54 PM +642ms
+2ms ╔Received event [Dryer Sensor].contact = closed with a delay of 100ms
+10150ms ║RunTime Analysis CS > 23ms > PS > 10066ms > PE > 61ms > CE
+10151ms ║Piston waited at a semaphore for 10012ms
+10154ms ║Runtime (43442 bytes) successfully initialized in 10066ms (v0.3.110.20191009) (10151ms)
+10154ms ║╔Execution stage started
+10165ms ║║Comparison (decimal) 80.0 is_greater_than (integer) 75 = true (1ms)
+10166ms ║║Condition #2 evaluated true (8ms)
+10173ms ║║Comparison (enum) active stays (string) active = true (2ms)
+10175ms ║║Condition #25 evaluated false (8ms)
+10176ms ║║Condition group #24 evaluated false (state did not change) (18ms)
+10181ms ║║Comparison (string) opened is (string) running = false (1ms)
+10182ms ║║Condition #14 evaluated false (4ms)
+10183ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+10188ms ║║Comparison (enum) closed changes_to (string) open = false (1ms)
+10189ms ║║Condition #19 evaluated false (4ms)
+10190ms ║║Condition group #18 evaluated false (state did not change) (5ms)
+10192ms ║╚Execution stage complete. (38ms)
+10193ms ║Setting up scheduled job for Thu, Mar 19 2020 @ 3:40:09 PM CDT (in 4.797s)
+10203ms ╚Event processed successfully (10203ms)
3/19/2020, 3:39:54 PM +485ms
+2ms ╔Received event [Dryer Sensor].acceleration = active with a delay of 135ms
+124ms ║RunTime Analysis CS > 20ms > PS > 58ms > PE > 46ms > CE
+126ms ║Runtime (43368 bytes) successfully initialized in 58ms (v0.3.110.20191009) (124ms)
+127ms ║╔Execution stage started
+139ms ║║Comparison (decimal) 80.0 is_greater_than (integer) 75 = true (1ms)
+140ms ║║Condition #2 evaluated true (9ms)
+145ms ║║Comparison (enum) active stays (string) active = true (1ms)
+146ms ║║Adding a timed trigger schedule for condition 25
+148ms ║║Condition #25 evaluated false (7ms)
+149ms ║║Condition group #24 evaluated false (state did not change) (18ms)
+155ms ║║Comparison (string) opened is (string) running = false (1ms)
+156ms ║║Condition #14 evaluated false (4ms)
+157ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+164ms ║║Condition #19 evaluated false (5ms)
+165ms ║║Condition group #18 evaluated false (state did not change) (6ms)
+167ms ║╚Execution stage complete. (40ms)
+168ms ║Setting up scheduled job for Thu, Mar 19 2020 @ 3:40:09 PM CDT (in 14.979s)
+175ms ╚Event processed successfully (175ms)
3/19/2020, 3:38:54 PM +577ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+402ms ║╔Subscribing to devices…
+426ms ║║Subscribing to Dryer Sensor.acceleration…
+442ms ║║Subscribing to Dryer Sensor.contact…
+559ms ║║Subscribing to VFSDryer…
+561ms ║║Subscribing to Echo - Korey’s Echo Show…
+562ms ║║Subscribing to Warning lamp…
+563ms ║╚Finished subscribing (166ms)
+591ms ║Comparison (decimal) 80.0 is_greater_than (integer) 75 = true (1ms)
+599ms ║Comparison (enum) inactive stays (string) active = false (1ms)
+606ms ║Comparison (enum) open is (string) closed = false (2ms)
+611ms ║Comparison (string) opened is_not (string) running = true (2ms)
+625ms ║Comparison (string) opened is (string) running = false (1ms)
+633ms ║Comparison (enum) inactive stays (string) inactive = true (1ms)
+657ms ╚Piston successfully started (656ms)
3/19/2020, 3:38:48 PM +470ms
+109ms ╔Stopping piston…
+216ms ╚Piston successfully stopped (106ms)
3/19/2020, 3:35:46 PM +231ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+331ms ║╔Subscribing to devices…
+352ms ║║Subscribing to Dryer Sensor.acceleration…
+362ms ║║Subscribing to Dryer Sensor.contact…
+404ms ║║Subscribing to VFSDryer…
+405ms ║║Subscribing to Echo - Korey’s Echo Show…
+406ms ║║Subscribing to Warning lamp…
+408ms ║╚Finished subscribing (84ms)
+432ms ║Comparison (decimal) 82.0 is_greater_than (integer) 75 = true (2ms)
+441ms ║Comparison (enum) inactive stays (string) active = false (1ms)
+449ms ║Comparison (enum) open is (string) closed = false (1ms)
+454ms ║Comparison (string) opened is_not (string) running = true (2ms)
+455ms ║Cancelling condition #27’s schedules…
+468ms ║Comparison (string) opened is (string) running = false (1ms)
+477ms ║Comparison (enum) inactive stays (string) inactive = true (2ms)
+479ms ║Cancelling condition #17’s schedules…
+504ms ╚Piston successfully started (502ms)
3/19/2020, 3:29:04 PM +279ms
+1ms ╔Received event [Dryer Sensor].acceleration = inactive with a delay of 2544ms
+88ms ║RunTime Analysis CS > 19ms > PS > 33ms > PE > 35ms > CE
+90ms ║Runtime (43369 bytes) successfully initialized in 33ms (v0.3.110.20191009) (89ms)
+91ms ║╔Execution stage started
+101ms ║║Comparison (decimal) 86.0 is_greater_than (integer) 75 = true (1ms)
+102ms ║║Condition #2 evaluated true (7ms)
+107ms ║║Comparison (enum) inactive stays (string) active = false (1ms)
+108ms ║║Cancelling any timed trigger schedules for condition 25
+109ms ║║Cancelling statement #25’s schedules…
+110ms ║║Cancelling condition #25’s schedules…
+111ms ║║Condition #25 evaluated false (8ms)
+112ms ║║Condition group #24 evaluated false (state did not change) (16ms)
+117ms ║║Comparison (string) opened is (string) running = false (1ms)
+118ms ║║Condition #14 evaluated false (4ms)
+119ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+126ms ║║Condition #19 evaluated false (5ms)
+127ms ║║Condition group #18 evaluated false (state did not change) (5ms)
+128ms ║╚Execution stage complete. (38ms)
+129ms ╚Event processed successfully (129ms)
3/19/2020, 3:29:01 PM +327ms
+0ms ╔Received event [Home].time = 1584649742762 with a delay of -1435ms
+152ms ║RunTime Analysis CS > 72ms > PS > 48ms > PE > 32ms > CE
+155ms ║Runtime (43355 bytes) successfully initialized in 48ms (v0.3.110.20191009) (154ms)
+156ms ║╔Execution stage started
+163ms ║║Cancelling condition #25’s schedules…
+165ms ║║Condition #25 evaluated true (1ms)
+173ms ║║Comparison (enum) open is (string) closed = false (2ms)
+174ms ║║Cancelling condition #26’s schedules…
+176ms ║║Condition #26 evaluated false (9ms)
+177ms ║║Condition group #24 evaluated false (state did not change) (14ms)
+183ms ║║Comparison (string) opened is (string) running = false (2ms)
+185ms ║║Cancelling condition #14’s schedules…
+186ms ║║Condition #14 evaluated false (7ms)
+187ms ║║Condition group #1 evaluated false (state did not change) (8ms)
+196ms ║║Cancelling condition #19’s schedules…
+197ms ║║Condition #19 evaluated false (7ms)
+198ms ║║Cancelling condition #18’s schedules…
+199ms ║║Condition group #18 evaluated false (state changed) (10ms)
+201ms ║╚Execution stage complete. (45ms)
+203ms ╚Event processed successfully (203ms)
3/19/2020, 3:28:47 PM +638ms
+0ms ╔Received event [Dryer Sensor].contact = open with a delay of 78ms
+99ms ║RunTime Analysis CS > 15ms > PS > 34ms > PE > 51ms > CE
+101ms ║Runtime (43360 bytes) successfully initialized in 34ms (v0.3.110.20191009) (100ms)
+102ms ║╔Execution stage started
+113ms ║║Comparison (decimal) 86.0 is_greater_than (integer) 75 = true (2ms)
+114ms ║║Condition #2 evaluated true (7ms)
+121ms ║║Comparison (enum) active stays (string) active = true (1ms)
+123ms ║║Adding a timed trigger schedule for condition 25
+125ms ║║Cancelling condition #25’s schedules…
+126ms ║║Condition #25 evaluated false (11ms)
+127ms ║║Condition group #24 evaluated false (state did not change) (21ms)
+133ms ║║Comparison (string) running is (string) running = true (1ms)
+134ms ║║Condition #14 evaluated true (5ms)
+141ms ║║Comparison (enum) active stays (string) inactive = false (1ms)
+142ms ║║Cancelling any timed trigger schedules for condition 17
+143ms ║║Cancelling statement #17’s schedules…
+144ms ║║Condition #17 evaluated false (9ms)
+145ms ║║Condition group #1 evaluated false (state did not change) (16ms)
+150ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+152ms ║║Cancelling condition #19’s schedules…
+152ms ║║Condition #19 evaluated true (5ms)
+153ms ║║Cancelling condition #18’s schedules…
+154ms ║║Condition group #18 evaluated true (state changed) (7ms)
+156ms ║║Cancelling statement #20’s schedules…
+163ms ║║Skipped execution of physical command [Warning lamp].off([]) because it would make no change to the device. (2ms)
+163ms ║║Executed [Warning lamp].off (4ms)
+166ms ║║Cancelling statement #22’s schedules…
+169ms ║║Executed virtual command setVariable (1ms)
+172ms ║╚Execution stage complete. (69ms)
+173ms ║Setting up scheduled job for Thu, Mar 19 2020 @ 3:29:02 PM CDT (in 14.952s)
+190ms ╚Event processed successfully (190ms)


#2

Triggers first conditions later.

Swap places of line 22 and 20
Swap places of line 44 and 42

Is there a reason why you are using a global variable instead of local?
are you checking the data from someplace else?


#3

Your piston will execute from top to bottom when it receives state change events for acceleration or contact. Is that what you want?

The logs show on the one occasion the acceleration changed to active and stayed that way for 15 seconds, it found the switch was already on but otherwise did its stuff.

The ‘stays active’ and ‘stays inactive’ timed triggers are surprisingly complicated beasts. They test if the acceleration is currently active/inactive and if so they set a timer for 15 seconds time and immediately return false and the piston continues. If the acceleration remains active/inactive the piston wakes up after fifteen seconds and acts like it had returned true. So unless you particularly want a condition to be checked after the fifteen seconds there is an argument for placing them last in the ‘and’ group so they don’t need to be evaluated unnecessarily.

Always bear in mind that pistons read global variables when they startup an instance, and write changes when that instance exits. Changes while the instance is running are not reflected elsewhere.

On the whole though, the piston clearly is firing, so the question is what is it doing or not doing when it does?


#4

Agree with @ike2018. Also, for the next time, if you turn on trace before taking the snapshot, it is easier to link the log to lines of code so we can help debug what is happening.


#5

Ah, very good. Thanks. I’ve read up on triggers vs. conditions some more.

I’ve made the changes you suggested. But it’s not firing either. The way you’ve suggested, does that mean: when the motion reaches 15 seconds in duration, check the temperature and open/close sensor. Because the motion will begin long before the temperature gets up to 75. Does that mean the motion will have to stop and restart again (after the other conditions are met) before this piston will fire?

The global vs. local was because I didn’t know how to do locals. I found it now, thanks! And it’s a little better, because I can see the value from the view-only view of the piston.


#6

when motion stays active (dryer is spining etc) the piston will execute and check all other conditions,
Is the temp greater than 75 (condition - if true move on)
Is the open close sensor is closed (condition - if true move on)
Is the variable this or that (condition - if true move on AND execute the rest)


#7

Regarding “top to bottom”:
Does that mean all the "if"s are evaluated in a row? I’m a software guy, and familiar with procedural and event-driven code, but I’m trying to make sense of how webcore works. My intention was to make three separate event handlers here. Should I have made them in 3 separate pistons? There’s a lot of webcore that looks like normal code but works a bit differently, so I’m trying to get it all straight.

Regarding writing to variables:
I guess this is affected by the “top to bottom” aspect as well.

What I want to do is: “when the temperature is above 75, the dryer is closed, and the sensor is vibrating, do something (in this case, just record the state for later, but for now, speak for debugging).” I used the “stay active for 15 seconds” as a sort of noise filter, to weed out false positives, like jostling the dryer without it actually running.


#8

is that “stays active” a one time event, or something that happens continuously?


#9

if i’m not mistaken: (Better users in this forum will correct me if i’m wrong)
STAYS ACTIVE X AMOUNT OF TIME (which is a trigger) one time event for that spesific countdown.


#10

Pistons are event handlers. The events that fire them are device attribute ‘change’ events (I say ‘change’ because it means a new value has been received which may not be different to an old one), timers or various internal webCoRE events such as pressing the test button.

Very roughly, when you write a piston you are writing a single generic event handler. You are working out what has happened and deciding what to do.

When you use ‘triggers’ you are considering the event e.g. ‘contact changes to closed’ is saying ‘is this instance of the piston running because a contact attribute event was received, and if so does that event say the contact is closed, and was it open before?’. If you use conditions like ‘contact is closed’ you are actually directly querying what SmartThings believes the current state of the attribute is.

‘Stays’ is weird. It is like a ‘trigger’ in its influence over what events the piston is subscribed to, but evaluates like a conditional.

‘Stays active for 15 seconds’ effectively means ‘is active now and continues to be active for the next fifteen seconds’.


#11

Ok, so if I understand you, a piston is exactly one event handler, so I need to split this into three pistons, then go back to using the global variable for state, right?


#12

@korey99 I think you understand the issue. I didn’t think about it at first but the sequence is definitely the problem but no need to split it up. Since the temperature should be the last condition to be achieved, I would suggest triggering on that event rather than the acceleration. If you use this logic, it should work:

if temperature rises above 75 degrees         <--trigger
  and  acceleration is active                          <--condition
  and  door is closed                                     <--condition
  and dryer status is not running                   <--condition
then
   dryer status-running
end if

#13

So if I make the changes guxdude suggests, making the temperature change a trigger instead of vibration being the trigger, that should work in some cases. But a case it won’t work in is when the dryer is already hot, and I start a new load.

Can I put the conditions (temp, door closed, status) before the trigger (vibrating?) In other words, I only want to listen for the event when the prerequisite conditions are met?


#14

The piston still only runs when the trigger event occurs. Interesting dilemma. Usually dryers have a bit of cool down at the end and would certainly cool down a bit while unloading. Maybe you could use a higher temperature set point for the trigger? Although I don’t think any of these would deal with a case of you opening the dryer in the middle of a run for some reason.

Maybe go back to the acceleration being the trigger but use a longer time that would allow the dryer to heat up?


#15

The more I think of it… I guess I can just remove the temperature check. Vibrating should be good enough. I was trying to use all available inputs to make sure.

But I’m still confused on one matter then. What’s the difference between:

Stays vibrating (trigger)
and
Door closed
and
Status != running

vs.

Door closed
and
Status != running
and
Stays vibrating (trigger)


#16

One of the super experts would have to pipe in on that one for more detail. Ultimately, there shouldn’t be a difference but have heard many times through this forum that response can be inconsistent if the trigger is not first. I think it is mainly good practice. When the trigger occurs, the piston runs top to bottom so it should check everything anyway but we try to use theses good coding practices to avoid ‘ghost’ issues.


#17

The ‘trigger goes first’ thing may well be what I call ‘webCoRE lore’ originating from when it was more common for users to not understand what a trigger actually is. For example users thought ‘temperature rises above 10C’ meant some external mechanism was constantly checking if that was true and then executing the piston when it was. That sort of thing.

You can argue having the trigger first may be more efficient as it may save having to evaluate the additional conditions (by default webCoRE stops evaluating conditions if the result is known - the first false means an AND is false, the first true means an OR is true). Or you can argue it makes the code more readable. In terms of outcome, it often doesn’t matter though.

The ‘stays’ trigger is slightly different as it involves a significant delay and that emphasises where it might matter. In the first case you spend fifteen seconds (or however long it was) deciding whether there is vibration and then you test the contact and the status. Those tests might mean your piston needn’t have bothered checking the vibration. On the other hand they might have changed in the last fifteen seconds and so it was worth the wait. In the second case the tests are made and the vibration check is only made if necessary. However what if the tests would have been different if you waited?

The above is really talking generally about what you should consider. For your particular piston it may or may not be an issue - I haven’t thought about it.


#18

Thanks everyone. I’m acting on your advice and testing. I came here looking for answers, because each test case basically takes an hour. So it’s a slow process, and surprisingly, I ran out of dirty laundry :slight_smile: I’ll report back.