Piston skipping step?


#1

1) Give a description of the problem
I have two switchbots to control my A/C since the thermostat has no smart capabilities. I have set up one switch to turn it on and the other to change between only fan and cool air. The problem is, at least from what I gather, is that in the execution of the piston it is skipping one of the toggles which throws everything off.

2) What is the expected behaviour?
When A/C turns on I want the switchbot to toggle four times (this would set the A/C mode to fan only) then I want it to wait and hour and toggle the switch again (this would set the A/C to cool air), wait 30 minutes, and repeat the process until the A/C is turned off…at that point the piston should stop until the A/C is turned on again.

3) What is happening/not happening?
From my little understanding of the logs, it seems like the execution starts well but then for some reason, it sees the switchbot as off and skips a step as it wouldn’t change anything.

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

5) Attach logs after turning logging level to Full
8/7/2021, 12:22:53 PM +835ms
+62ms ╔Stopping piston…
+162ms ╚Piston successfully stopped (100ms)
8/7/2021, 12:18:43 PM +521ms
+2ms ╔Received event [Air conditioner].switch = off with a delay of 62ms
+6812ms ║RunTime Analysis CS > 17ms > PS > 6763ms > PE > 32ms > CE
+6813ms ║Piston waited at a semaphore for 6759ms
+6816ms ║Runtime (38039 bytes) successfully initialized in 6763ms (v0.3.113.20210203) (6813ms)
+6816ms ║╔Execution stage started
+6823ms ║║Comparison (enum) off changes_to (string) on = false (0ms)
+6825ms ║║Cancelling condition #2’s schedules…
+6826ms ║║Condition #2 evaluated false (6ms)
+6827ms ║║Cancelling condition #1’s schedules…
+6828ms ║║Condition group #1 evaluated false (state changed) (8ms)
+6830ms ║╚Execution stage complete. (14ms)
+6836ms ╚Event processed successfully (6836ms)
8/7/2021, 12:18:40 PM +118ms
+0ms ╔Received event [Home].time = 1628331521163 with a delay of -1046ms
+81ms ║RunTime Analysis CS > 43ms > PS > 5ms > PE > 34ms > CE
+84ms ║Runtime (37962 bytes) successfully initialized in 5ms (v0.3.113.20210203) (82ms)
+85ms ║╔Execution stage started
+108ms ║║Condition #5 evaluated false (10ms)
+109ms ║║Condition group #4 evaluated false (state did not change) (12ms)
+112ms ║║Cancelling statement #6’s schedules…
+136ms ║║Executed physical command [AC FAN].on() (18ms)
+137ms ║║Executed [AC FAN].on (21ms)
+143ms ║║Executed virtual command [AC FAN].wait (0ms)
+144ms ║║Waiting for 2000ms
+2180ms ║║Executed physical command [AC FAN].off() (18ms)
+2181ms ║║Executed virtual command [AC FAN].toggle (34ms)
+2187ms ║║Executed virtual command [AC FAN].wait (1ms)
+2188ms ║║Waiting for 2000ms
+4225ms ║║Executed physical command [AC FAN].on() (17ms)
+4226ms ║║Executed virtual command [AC FAN].toggle (35ms)
+4232ms ║║Executed virtual command [AC FAN].wait (1ms)
+4233ms ║║Waiting for 2000ms
+6264ms ║║Executed physical command [AC FAN].off() (16ms)
+6266ms ║║Executed virtual command [AC FAN].toggle (28ms)
+6272ms ║║Executed virtual command [AC FAN].wait (1ms)
+6274ms ║║Requesting a wake up for Sat, Aug 7 2021 @ 12:18:56 PM CEST (in 10.0s)
+6279ms ║╚Execution stage complete. (6195ms)
+6281ms ║Setting up scheduled job for Sat, Aug 7 2021 @ 12:18:56 PM CEST (in 9s)
+6289ms ╚Event processed successfully (6289ms)
8/7/2021, 12:18:11 PM +58ms
+0ms ╔Received event [Home].time = 1628331492451 with a delay of -1394ms
+64ms ║RunTime Analysis CS > 25ms > PS > 6ms > PE > 34ms > CE
+66ms ║Runtime (37962 bytes) successfully initialized in 6ms (v0.3.113.20210203) (65ms)
+67ms ║╔Execution stage started
+90ms ║║Skipped execution of physical command [AC FAN].off([]) because it would make no change to the device. (7ms)
+91ms ║║Executed [AC FAN].off (10ms)
+102ms ║║Executed virtual command [AC FAN].wait (0ms)
+104ms ║║Requesting a wake up for Sat, Aug 7 2021 @ 12:18:41 PM CEST (in 30.0s)
+114ms ║╚Execution stage complete. (47ms)
+116ms ║Setting up scheduled job for Sat, Aug 7 2021 @ 12:18:41 PM CEST (in 29s)
+123ms ╚Event processed successfully (123ms)
8/7/2021, 12:17:56 PM +62ms
+0ms ╔Received event [Home].time = 1628331477750 with a delay of -1688ms
+62ms ║RunTime Analysis CS > 20ms > PS > 5ms > PE > 36ms > CE
+64ms ║Runtime (37967 bytes) successfully initialized in 5ms (v0.3.113.20210203) (63ms)
+65ms ║╔Execution stage started
+71ms ║║Cancelling condition #3’s schedules…
+73ms ║║Condition #3 evaluated true (1ms)
+74ms ║║Cancelling condition #1’s schedules…
+75ms ║║Condition group #1 evaluated true (state changed) (4ms)
+78ms ║║Cancelling statement #6’s schedules…
+98ms ║║Executed physical command [AC FAN].on() (16ms)
+100ms ║║Executed [AC FAN].on (17ms)
+105ms ║║Executed virtual command [AC FAN].wait (0ms)
+106ms ║║Waiting for 2000ms
+2279ms ║║Executed physical command [AC FAN].off() (16ms)
+2281ms ║║Executed virtual command [AC FAN].toggle (29ms)
+2288ms ║║Executed virtual command [AC FAN].wait (1ms)
+2290ms ║║Waiting for 2000ms
+4339ms ║║Executed physical command [AC FAN].on() (24ms)
+4340ms ║║Executed virtual command [AC FAN].toggle (46ms)
+4346ms ║║Executed virtual command [AC FAN].wait (1ms)
+4347ms ║║Waiting for 2000ms
+6379ms ║║Executed physical command [AC FAN].off() (17ms)
+6380ms ║║Executed virtual command [AC FAN].toggle (29ms)
+6386ms ║║Executed virtual command [AC FAN].wait (0ms)
+6388ms ║║Requesting a wake up for Sat, Aug 7 2021 @ 12:18:12 PM CEST (in 10.0s)
+6393ms ║╚Execution stage complete. (6328ms)
+6395ms ║Setting up scheduled job for Sat, Aug 7 2021 @ 12:18:12 PM CEST (in 9s)
+6410ms ╚Event processed successfully (6409ms)
8/7/2021, 12:17:47 PM +669ms
+1ms ╔Received event [Air conditioner].switch = on with a delay of 61ms
+57ms ║RunTime Analysis CS > 14ms > PS > 5ms > PE > 38ms > CE
+60ms ║Runtime (37968 bytes) successfully initialized in 5ms (v0.3.113.20210203) (58ms)
+61ms ║╔Execution stage started
+70ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+71ms ║║Cancelling condition #2’s schedules…
+72ms ║║Condition #2 evaluated true (6ms)
+78ms ║║Comparison (enum) on stays (string) on = true (2ms)
+80ms ║║Adding a timed trigger schedule for condition 3
+83ms ║║Condition #3 evaluated false (9ms)
+84ms ║║Condition group #1 evaluated false (state did not change) (18ms)
+87ms ║╚Execution stage complete. (25ms)
+88ms ║Setting up scheduled job for Sat, Aug 7 2021 @ 12:17:57 PM CEST (in 9s)
+95ms ╚Event processed successfully (95ms)


#2

It is important when using stays, that it always gets run when the piston is executed.

Your if statement is setup with a trigger AND stays, so the stays will not run every time…


#3

The logs show:

  • Fire the piston because the Air Conditioner switch on event has been received
  • Schedule a timed trigger and then exit because the stays condition returned false (that’s how it works)
  • Fire the piston ten seconds later to return true from the stays condition (ditto)
  • AC Fan On
  • 2 second wait
  • Toggle AC Fan to Off
  • 2 second wait
  • Toggle AC Fan to On
  • 2 second wait
  • Toggle AC Fan to Off
  • Schedule a 10 second wait and exit
  • Resume the piston after the wait
  • Skip turning off AC Fan as it is already Off
  • Schedule a 30 second wait and exit
  • Resume the piston after the wait
  • Test the ‘until’ condition which is false (it always will be)
  • Run through the next iteration until the 10 second wait
  • Schedule the 10 second wait and exit
  • Fire the piston because the Air Conditioner off event has been received
  • Cancel the 10 second wait as the condition that allowed it to be created it has changed

Can’t see anything unusual, other than that you seem to have one more toggle than you intended or have a different idea of what a toggle is to webCoRE. Are you perhaps wanting a toggle to set the switch of off and back on again?

Your until condition will always be false. For switch changes to off to be true the piston will have to be running because the switch is off, and the condition would have to have been previously been evaluated when it was on. Even switch is off probably wouldn’t work as the piston is still handling an event that says the switch is on.


#4

My reason for using toggle is that I don’t really care whether the button is on or off as I need it to be pushed four times to get it set to the correct setting on the thermostat. What I mean is, on my Thermostat, when the A/C is on I have to push a button to change the setting from cool air to fan only. There are other option in between…but basically, to get from cool air to fan I have to push the button on the thermostat 4 times.

Then after a period of time I want it to push that same button once to get cool air again…and after a period of time to restart the process again. Hopefully that makes sense.


#5

Not sure what this means…sorry I’m new to all of this. I’m basically learning by trial and error.


#6

Fair enough. But you are turning it on and toggling it three times - so off, on, off - and then trying to turn it off when it is already off which webCoRE won’t do by default (it calls it ‘command optimization’ and is a piston setting).


#7

Before you wrote this, I figured what you were saying so I changed everything to toggle…I thought as long as it toggles, I don’t care whether it thinks it is on or off…I just need it to press the button. But it still seems to skip one of the toggles…but now it doesn’t saying anything about it already beging in an off state.


#8

What does the Air Conditioner switch get up to while the piston is running? In the first post the logs show it turning off about a minute after it turned on. That will stop your piston because of something called the Task Cancellation Policy (basically your piston assumes that stuff it started doing because the switch changed to on is no longer needed). That can be changed but I fear there will be a problem terminating the repeat loop if it is.


#9

I got it solved. Basically I just switch around the longer pause toggles to the beginning and that got it doing what I wanted it to. I think my problem here was not explaining what I wanted to do properly. I appreciate the help as it helped me see what was happening!!!