Device statuses


#1

I have been messing with a piston for a while and got it working by logic that doesn’t make sense, but what’s the deal with device (specifically switches) status? I have a piston that I want to send a push notification after I turn a switch on or off that says it’s been turned on or off and that is proving more difficult than expected. I have tried polling the devices (what’s the difference between poll and refresh? Some have both and some only refresh) and it doesn’t work without refreshing my variable each time.


#2

With your current wording, it’s trying to check the status 5 ms after the toggle command was sent…

I would add a short WAIT (500ms to 1sec) right after the toggles & before the internal IFs. This should give ample time for the device to make the change, and report the correct status.


If you like, you can drop the variables & internal IF, and just send a PUSH like this:

Send Push notification "AC Timer turned "[Switch 19 : switch]" (30 min delay)"

(Replace “Switch 19” with the exact name of that device)

temp

(I would still add the short WAITs before the PUSH though)


#3

I tried a wait initially thinking that but it didn’t work. I can see the variables and they never update correctly.

I will try the push like you have done and see what happens (with a wait). Thank you!!


#4

I appreciate the tip on using an expression in my push notifications…I had not tried that.

But I got the same results, even with a 1-second delay…any other ideas?


#5

For any further testing, please turn on Trace and set logging to full. We’d need to see an update of both (during a failure) to properly diagnose


#6

I am posting a new piston (using the wait and changing the push notification):

Logs:
7/12/2019, 11:39:58 AM +514ms
+5ms ╔Received event [Outdoor Button].held = 1 with a delay of 62ms, canQueue: true, calledMyself: false
+108ms ║RunTime LockT > 51ms > rtDataT > 69ms > pistonT > 30ms 0 > CE
+139ms ║Runtime (11160 bytes) successfully initialized in 70ms (v0.3.10d.20190627)
+165ms ║╔Execution stage started
+184ms ║║Condition #2 evaluated false (12ms)
+187ms ║║Condition group #1 evaluated false (state did not change) (15ms)
+199ms ║║Comparison (integer) 1 gets (integer) 1 = true (1ms)
+202ms ║║Condition #8 evaluated true (10ms)
+206ms ║║Condition group #7 evaluated true (state did not change) (13ms)
+211ms ║║Cancelling statement #11’s schedules…
+253ms ║║Executed physical command [Outdoor Lights].off() (22ms)
+255ms ║║Executed virtual command [Outdoor Lights].toggle (29ms)
+284ms ║║Executed physical command [Pool Light Switch].off() (19ms)
+286ms ║║Executed virtual command [Pool Light Switch].toggle (25ms)
+300ms ║║Executed virtual command [Outdoor Lights, Pool Light Switch].wait (2ms)
+303ms ║║executeTask: Waiting for 1000ms
+1311ms ║║executeTask: Execution time exceeded by 306ms, Waiting for 100ms; lastPause: null
+1427ms ║║Cancelling statement #9’s schedules…
+1441ms ║║Calculating (string) Outdoor and pool lights turned + (string) on >> (string) Outdoor and pool lights turned on
+1448ms ║║Calculating (string) Outdoor and pool lights turned on + (string) . >> (string) Outdoor and pool lights turned on.
+1547ms ║║Executed virtual command sendPushNotification (89ms)
+1568ms ║║Condition #16 evaluated false (13ms)
+1572ms ║║Condition group #15 evaluated false (state did not change) (16ms)
+1579ms ║╚Execution stage complete. (1414ms)
+1617ms ╚Event processed successfully (1616ms)
7/12/2019, 11:39:41 AM +289ms
+6ms ╔Received event [Outdoor Button].held = 1 with a delay of 97ms, canQueue: true, calledMyself: false
+125ms ║RunTime LockT > 48ms > rtDataT > 87ms > pistonT > 52ms 1 > CE
+151ms ║Runtime (11162 bytes) successfully initialized in 87ms (v0.3.10d.20190627)
+232ms ║╔Execution stage started
+261ms ║║Condition #2 evaluated false (13ms)
+267ms ║║Condition group #1 evaluated false (state did not change) (23ms)
+284ms ║║Comparison (integer) 1 gets (integer) 1 = true (2ms)
+287ms ║║Cancelling condition #8’s schedules…
+291ms ║║Condition #8 evaluated true (16ms)
+294ms ║║Cancelling condition #7’s schedules…
+296ms ║║Condition group #7 evaluated true (state changed) (22ms)
+301ms ║║Cancelling statement #11’s schedules…
+406ms ║║Executed physical command [Outdoor Lights].on() (82ms)
+410ms ║║Executed virtual command [Outdoor Lights].toggle (91ms)
+471ms ║║Executed physical command [Pool Light Switch].on() (48ms)
+474ms ║║Executed virtual command [Pool Light Switch].toggle (57ms)
+491ms ║║Executed virtual command [Outdoor Lights, Pool Light Switch].wait (1ms)
+494ms ║║executeTask: Waiting for 1000ms
+1498ms ║║executeTask: Execution time exceeded by 496ms, Waiting for 100ms; lastPause: null
+1605ms ║║Cancelling statement #9’s schedules…
+1637ms ║║Calculating (string) Outdoor and pool lights turned + (string) off >> (string) Outdoor and pool lights turned off
+1649ms ║║Calculating (string) Outdoor and pool lights turned off + (string) . >> (string) Outdoor and pool lights turned off.
+1788ms ║║Executed virtual command sendPushNotification (122ms)
+1815ms ║║Condition #16 evaluated false (19ms)
+1819ms ║║Condition group #15 evaluated false (state did not change) (23ms)
+1832ms ║╚Execution stage complete. (1600ms)
+1886ms ╚Event processed successfully (1885ms)


#7

The logs are much easier to decipher if your green snapshot has Trace turned on.

temp

(Sometimes you may have to press Test before Trace will become visible)


#8

I didn’t realize that…thanks! Here you go:

7/12/2019, 3:24:39 PM +186ms
+4ms ╔Received event [Outdoor Button].held = 1 with a delay of 64ms, canQueue: true, calledMyself: false
+116ms ║RunTime LockT > 63ms > rtDataT > 73ms > pistonT > 34ms 0 > CE
+140ms ║Runtime (11160 bytes) successfully initialized in 74ms (v0.3.10d.20190627)
+164ms ║╔Execution stage started
+179ms ║║Condition #2 evaluated false (8ms)
+182ms ║║Condition group #1 evaluated false (state did not change) (12ms)
+192ms ║║Comparison (integer) 1 gets (integer) 1 = true (1ms)
+196ms ║║Condition #8 evaluated true (9ms)
+200ms ║║Condition group #7 evaluated true (state did not change) (12ms)
+204ms ║║Cancelling statement #11’s schedules…
+250ms ║║Executed physical command [Outdoor Lights].off() (25ms)
+253ms ║║Executed virtual command [Outdoor Lights].toggle (33ms)
+284ms ║║Executed physical command [Pool Light Switch].off() (20ms)
+287ms ║║Executed virtual command [Pool Light Switch].toggle (28ms)
+298ms ║║Executed virtual command [Outdoor Lights, Pool Light Switch].wait (1ms)
+301ms ║║executeTask: Waiting for 1000ms
+1305ms ║║executeTask: Execution time exceeded by 303ms, Waiting for 100ms; lastPause: null
+1412ms ║║Cancelling statement #9’s schedules…
+1421ms ║║Calculating (string) Outdoor and pool lights turned + (string) on >> (string) Outdoor and pool lights turned on
+1426ms ║║Calculating (string) Outdoor and pool lights turned on + (string) . >> (string) Outdoor and pool lights turned on.
+1529ms ║║Executed virtual command sendPushNotification (93ms)
+1548ms ║║Condition #16 evaluated false (10ms)
+1552ms ║║Condition group #15 evaluated false (state did not change) (14ms)
+1559ms ║╚Execution stage complete. (1394ms)
+1611ms ╚Event processed successfully (1610ms)
7/12/2019, 3:24:32 PM +257ms
+9ms ╔Received event [Outdoor Button].held = 1 with a delay of 72ms, canQueue: true, calledMyself: false
+108ms ║RunTime LockT > 50ms > rtDataT > 68ms > pistonT > 34ms 0 > CE
+133ms ║Runtime (11160 bytes) successfully initialized in 68ms (v0.3.10d.20190627)
+157ms ║╔Execution stage started
+174ms ║║Condition #2 evaluated false (10ms)
+178ms ║║Condition group #1 evaluated false (state did not change) (13ms)
+187ms ║║Comparison (integer) 1 gets (integer) 1 = true (0ms)
+191ms ║║Condition #8 evaluated true (8ms)
+195ms ║║Condition group #7 evaluated true (state did not change) (11ms)
+199ms ║║Cancelling statement #11’s schedules…
+291ms ║║Executed physical command [Outdoor Lights].on() (66ms)
+294ms ║║Executed virtual command [Outdoor Lights].toggle (74ms)
+341ms ║║Executed physical command [Pool Light Switch].on() (36ms)
+345ms ║║Executed virtual command [Pool Light Switch].toggle (44ms)
+355ms ║║Executed virtual command [Outdoor Lights, Pool Light Switch].wait (1ms)
+358ms ║║executeTask: Waiting for 1000ms
+1362ms ║║executeTask: Execution time exceeded by 361ms, Waiting for 100ms; lastPause: null
+1469ms ║║Cancelling statement #9’s schedules…
+1480ms ║║Calculating (string) Outdoor and pool lights turned + (string) off >> (string) Outdoor and pool lights turned off
+1487ms ║║Calculating (string) Outdoor and pool lights turned off + (string) . >> (string) Outdoor and pool lights turned off.
+1593ms ║║Executed virtual command sendPushNotification (97ms)
+1618ms ║║Condition #16 evaluated false (14ms)
+1622ms ║║Condition group #15 evaluated false (state did not change) (18ms)
+1630ms ║╚Execution stage complete. (1472ms)
+1681ms ╚Event processed successfully (1680ms)


#9

It seems the piston ran as expected, but the device did not update in time… (Some devices are slower to respond than others) I guess you could test with a longer WAIT…

For reference, I just made a test piston almost like yours, and it worked flawlessly:

temp


For what it’s worth, I always try to avoid using TOGGLE since that command can be so vague.

I usually would add another IF inside, something like this:

IF Switch 19 is on
Then 
    Turn off Switch 19
    Send SMS "AC turned off"
ELSE
    Turn on Switch 19
    Send SMS "AC turned on"
END IF

…and then farther down in the code:

IF Switch 17 is on
Then 
    Turn off Switch 17 & Switch 1
    Send SMS "Pool turned off"
ELSE
    Turn on Switch 17 & Switch 1
    Send SMS "Pool turned on"
END IF

#10

It must really depend on the switch…I waited 12 hours last night lol.
Never updated right…I ended up getting rid of the toggle and building out the logic and got it to work that way…thanks!!


#11

Another added benefit of my last suggestion is it keeps Switch 1 & Switch 17 in sync each time this piston runs…