Issues with 2 pistons activating


#1

1) Give a description of the problem
I’ve got two different pistons that seem to not be consistently activating, and a third that I’m hoping to ensure looks good.
2) What is the expected behaviour?
Control automation of bathroom shower/lights/exhaust fan.
#1 Cutoff shower if on for 30 with no movement or 1 hr even if movement
#2 Turn on heater (dependant on temperature), exhaust fan and shower light with shower, turn off post, turn on room light after
3) What is happening/not happening?
Not consistently activating, not consistently impacting all components. Latest time the cutoff didn’t run, but on a test did, and seemed to run twice.

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


5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

Cutoff Logs:

11/19/2019, 7:25:23 PM +550ms
+1ms ╔Received event [Shower].valve = closed with a delay of 94ms
+66ms ║RunTime Analysis CS > 14ms > PS > 40ms > PE > 12ms > CE
+68ms ║Runtime (38554 bytes) successfully initialized in 40ms (v0.3.110.20191009) (66ms)
+69ms ║╔Execution stage started
+139ms ║║Duration 6153745ms for is >= 1800000ms threshold = true
+140ms ║║Comparison (enum) closed was (string) open = true (63ms)
+142ms ║║Condition #3 evaluated true (68ms)
+151ms ║║Comparison (enum) inactive is_not (string) active = true (2ms)
+152ms ║║Condition #4 evaluated true (9ms)
+153ms ║║Condition group #2 evaluated true (state did not change) (79ms)
+154ms ║║Condition group #1 evaluated true (state did not change) (81ms)
+156ms ║║Cancelling statement #6’s schedules…
+521ms ║║Executed physical command [Shower].close() (362ms)
+522ms ║║Executed [Shower].close (363ms)
+537ms ║║Executed virtual command [Shower].sendPushNotification (11ms)
+549ms ║║Executed virtual command [Shower].sendSMSNotification (7ms)
+551ms ║╚Execution stage complete. (482ms)
+552ms ╚Event processed successfully (552ms)
11/19/2019, 7:25:13 PM +585ms
+0ms ╔Received event [Suite].test = 1574209513584 with a delay of 1ms
+96ms ║RunTime Analysis CS > 22ms > PS > 58ms > PE > 16ms > CE
+99ms ║Runtime (38564 bytes) successfully initialized in 58ms (v0.3.110.20191009) (98ms)
+100ms ║╔Execution stage started
+242ms ║║Duration 6144114ms for is >= 1800000ms threshold = true
+243ms ║║Comparison (enum) open was (string) open = true (130ms)
+245ms ║║Cancelling condition #3’s schedules…
+246ms ║║Condition #3 evaluated true (141ms)
+255ms ║║Comparison (enum) inactive is_not (string) active = true (1ms)
+257ms ║║Condition #4 evaluated true (10ms)
+259ms ║║Cancelling condition #2’s schedules…
+260ms ║║Condition group #2 evaluated true (state changed) (154ms)
+261ms ║║Cancelling condition #1’s schedules…
+262ms ║║Condition group #1 evaluated true (state changed) (158ms)
+265ms ║║Cancelling statement #6’s schedules…
+736ms ║║Executed physical command [Shower].close() (467ms)
+737ms ║║Executed [Shower].close (469ms)
+788ms ║║Executed virtual command [Shower].sendPushNotification (45ms)
+867ms ║║Executed virtual command [Shower].sendSMSNotification (73ms)
+873ms ║╚Execution stage complete. (773ms)
+875ms ╚Event processed successfully (875ms)
11/19/2019, 12:42:03 PM +744ms
+10107ms ║Piston waited at a semaphore for 10014ms

#On/Off Logs:
11/19/2019, 7:33:26 PM +150ms
+1ms ╔Received event [Suite].time = 1574210007168 with a delay of -1019ms
+128ms ║RunTime Analysis CS > 25ms > PS > 64ms > PE > 39ms > CE
+130ms ║Runtime (39198 bytes) successfully initialized in 64ms (v0.3.110.20191009) (128ms)
+131ms ║╔Execution stage started
+221ms ║║Executed physical command [Ceiling Heater].off() (64ms)
+223ms ║║Executed [Ceiling Heater].off (66ms)
+225ms ║╚Execution stage complete. (94ms)
+226ms ╚Event processed successfully (226ms)
11/19/2019, 7:31:24 PM +147ms
+0ms ╔Received event [Suite].time = 1574209884635 with a delay of -489ms
+164ms ║RunTime Analysis CS > 28ms > PS > 86ms > PE > 51ms > CE
+167ms ║Runtime (39197 bytes) successfully initialized in 86ms (v0.3.110.20191009) (165ms)
+168ms ║╔Execution stage started
+2029ms ║║Executed physical command [Shower Light].setLevel([0]) (1856ms)
+2988ms ║║Executed physical command [Shower Light].setLevel([0]) (954ms)
+3014ms ║║Cancelling statement #17’s schedules…
+3019ms ║║Executed virtual command [Ceiling Heater].wait (0ms)
+3021ms ║║Requesting a wake up for Tue, Nov 19 2019 @ 7:33:27 PM EST (in 120.0s)
+3025ms ║╚Execution stage complete. (2857ms)
+3026ms ║Setting up scheduled job for Tue, Nov 19 2019 @ 7:33:27 PM EST (in 119.995s)
+3034ms ╚Event processed successfully (3034ms)
11/19/2019, 7:29:53 PM +103ms
+1ms ╔Received event [Suite].time = 1574209794634 with a delay of -1531ms
+166ms ║RunTime Analysis CS > 47ms > PS > 90ms > PE > 29ms > CE
+169ms ║Runtime (39198 bytes) successfully initialized in 90ms (v0.3.110.20191009) (166ms)
+169ms ║╔Execution stage started
+4180ms ║║Executed physical command [Shower Light].setLevel([1]) (4005ms)
+4182ms ║╚Execution stage complete. (4013ms)
+4184ms ║Setting up scheduled job for Tue, Nov 19 2019 @ 7:31:24 PM EST (in 87.348s), with 2 more jobs pending
+4193ms ╚Event processed successfully (4193ms)
11/19/2019, 7:28:22 PM +170ms
+1ms ╔Received event [Suite].time = 1574209703702 with a delay of -1532ms
+111ms ║RunTime Analysis CS > 23ms > PS > 58ms > PE > 30ms > CE
+114ms ║Runtime (39198 bytes) successfully initialized in 58ms (v0.3.110.20191009) (111ms)
+115ms ║╔Execution stage started
+524ms ║║Executed physical command [Ceiling Exhaust Fan].off() (385ms)
+525ms ║║Executed [Ceiling Exhaust Fan].off (387ms)
+527ms ║║Cancelling statement #8’s schedules…
+2426ms ║║Executed physical command [Overhead Light].on() (1895ms)
+2427ms ║║Executed [Overhead Light].on (1897ms)
+2430ms ║║Cancelling statement #10’s schedules…
+2445ms ║║Skipped execution of physical command [Shower Light].setLevel([2]) because it would make no change to the device. (5ms)
+2466ms ║║Executed virtual command [Shower Light].fadeLevel (31ms)
+2467ms ║║Requesting a wake up for Tue, Nov 19 2019 @ 7:31:24 PM EST (in 180.1s)
+2472ms ║╚Execution stage complete. (2357ms)
+2474ms ║Setting up scheduled job for Tue, Nov 19 2019 @ 7:29:54 PM EST (in 89.991s), with 3 more jobs pending
+2482ms ╚Event processed successfully (2482ms)
11/19/2019, 7:25:23 PM +568ms
+2ms ╔Received event [Shower].valve = closed with a delay of 112ms
+104ms ║RunTime Analysis CS > 21ms > PS > 54ms > PE > 29ms > CE
+107ms ║Runtime (39184 bytes) successfully initialized in 54ms (v0.3.110.20191009) (104ms)
+108ms ║╔Execution stage started
+115ms ║║Comparison (enum) closed changes_to (string) open = false (1ms)
+116ms ║║Cancelling condition #3’s schedules…
+117ms ║║Condition #3 evaluated false (5ms)
+118ms ║║Cancelling condition #1’s schedules…
+119ms ║║Condition group #1 evaluated false (state changed) (7ms)
+123ms ║║Comparison (enum) closed changes_to (string) closed = true (1ms)
+124ms ║║Condition #4 evaluated true (4ms)
+125ms ║║Condition group #2 evaluated true (state did not change) (5ms)
+127ms ║║Cancelling statement #5’s schedules…
+132ms ║║Executed virtual command [Ceiling Exhaust Fan].wait (1ms)
+133ms ║║Requesting a wake up for Tue, Nov 19 2019 @ 7:28:23 PM EST (in 180.0s)
+137ms ║╚Execution stage complete. (30ms)
+138ms ║Setting up scheduled job for Tue, Nov 19 2019 @ 7:28:23 PM EST (in 179.996s)
+149ms ╚Event processed successfully (149ms)
11/19/2019, 5:42:49 PM +921ms
+2ms ╔Received event [Shower].valve = open with a delay of 210ms
+120ms ║RunTime Analysis CS > 26ms > PS > 65ms > PE > 29ms > CE
+123ms ║Runtime (39189 bytes) successfully initialized in 65ms (v0.3.110.20191009) (120ms)
+124ms ║╔Execution stage started
+131ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+132ms ║║Cancelling condition #3’s schedules…
+133ms ║║Condition #3 evaluated true (5ms)
+134ms ║║Cancelling condition #1’s schedules…
+135ms ║║Condition group #1 evaluated true (state changed) (7ms)
+137ms ║║Cancelling statement #12’s schedules…
+1736ms ║║Executed physical command [Shower Light].on() (1595ms)
+1737ms ║║Executed [Shower Light].on (1597ms)
+1740ms ║║Cancelling statement #14’s schedules…
+1853ms ║║Executed physical command [Ceiling Exhaust Fan].on() (109ms)
+1854ms ║║Executed [Ceiling Exhaust Fan].on (111ms)
+1866ms ║║Comparison (decimal) 60.0 is_less_than_or_equal_to (integer) 67 = true (1ms)
+1867ms ║║Condition #22 evaluated true (10ms)
+1868ms ║║Condition group #20 evaluated true (state did not change) (12ms)
+1870ms ║║Cancelling statement #20’s schedules…
+1902ms ║║Executed physical command [Ceiling Heater].on() (26ms)
+1903ms ║║Executed [Ceiling Heater].on (28ms)
+1905ms ║╚Execution stage complete. (1782ms)
+1906ms ╚Event processed successfully (1906ms)


#2

Hi there,
I’m not a pro coder but I have a pretty good grip on Webcore.
Your first piston’s IF block is way more complicated then I would prefer.
Simpler the better.
I would split that block into 3-4 different IF blocks…
or if you share what you want to achieve maybe we can share some other ways of doing it…


#3

Sorry if I communicated poorly, I sometimes have the bad habit of assuming that what’s in my mind is in everyone else’s too.

The Cutoff piston is to
Turn off the shower if it’s been on for 30 minutes with no motion or 1 hr with motion.
Signal that it has done so by push and text

The other is more complicated as you noted, and controls what happens when the shower goes on/off. When it goes on The shower light is to turn on, the exhaust fan is to turn on, and if temperature is below 67 the heater is to turn on. When it turns off after 3 minutes the exhaust fan is to turn off, after 2 minutes the heater goes off, the shower light fades off over 3 minutes, and the overhead light turns on.

Part of the issue is apparently I’m using the wait command incorrectly, since it seems like it pauses the whole piston, not just the device it is under.

It’s a totally different question, but I’d like to make it so the heater never stays on for more than 5 minutes contiguously, and perhaps cycles on and off if the shower is on in that instance.


#4

oh we all do that no worries LOL

I’d say split everything in few separate pistons…


#5

I’m a bit too tired for the Lounge one but I will observe that it will fire when Motion Sensor 7 changes and when Contact Sensor 3 changes. However each time it fires only one of ‘Motion Sensor 7 changes to active’ or ‘Contact Sensor 3 changes away from open’ can be true.

For the Shower On/Off, click on the ‘with’ command in ‘with Switch 7’, hit the settings cog, and change the execution method to ‘Asynchronous’. Do the same for ‘with RGB Bulb 2’. That should make things run in parallel rather than in sequence, as it were.

For the Shower Cut Off, you have to consider that the piston only fires when the valve changes from open to closed, or vice versa, and whenever the motion sensor changes. The conditions are only evaluated at those times. If the valve is left open and there isn’t any change of motion status the piston will not fire.

You need to rethink that one. You might want to try splitting it into two pistons. One could say:

if valve stays open for 1 hour
then
    close valve
end if

That would trigger when the valve opens and close the valve if it stays open for an hour.

The other one might work as:

if motion changes to inactive
and valve is open
then
    wait 30 minutes
    close valve
end if

That would fire on motion changing and if it changes to inactive and the valve is open it will wait for 30 minutes and close the valve. If the motion starts again the wait gets cancelled. I’m tired but I think that is right.


#6

Thanks for the tips, I switched up the asynchronous bits since that really seemed to be the main issue I was having.

As it comes to the cutoff, I can definitely do it as multiple, but I’m still a bit confused on the execution. I’m not 100% getting why it’s executing on switch change and not on ‘has been on for over’ and why it’d be different split. I probably need the simple wiki explanation :joy:. Alternately it could be set so it does activate every time it goes on, either way works so long as it always cuts it off if those conditions are met.


#7

Background: Your piston checks its code on startup to determine when it needs to execute the piston. If if sees ‘triggers’ it subscribes to changes in device attributes used in those triggers. In the absence of any triggers it will check ‘conditions’ and subscribe to changes in the device attributes used in those. It will then execute the piston on any of those changes and it is up to your piston to decide what to do about it.

A trigger can only evaluate to true when it is the reason the piston is executing.

Your piston will run when the valve opens or closes, or the motion goes active or inactive, and then the piston code decides what happens from then on. If the case of ‘was open for at least 30 minutes’ it will look back through its records to see when it was last seen to be closed. So it is a passive thing. It only knows the answer when it looks, and if the valve doesn’t change or the motion doesn’t change, it doesn’t look.

If you want the valve being open for 1 hour to be a more active thing, the best you can do is use ‘stays open for 1 hour’. That is considered a ‘trigger’ rather than a ‘condition’. It effectively says ‘if valve is open then wait 1 hour and return true’. If the valve closes that wait gets cancelled, if not the condition is true.

I suggest two pistons just because I think it gets messy trying to combine them when long waits are involved.