Is this doing what i think its doing?


#1

ive cobbled this piston together manly by guessing and cutting bits of other pistons , its meant to tell me if a device has frozen by looking at the device events and if there’s no activity in 4hours push a message to me

1) Give a description of the problem
its showing one device that’s frozen, but the device has given a battery update in the last 24hours

2) What is the expected behaviour?
its meant to tell me if a device has frozen by looking at the device events and if there’s no activity in 24hours push a message to me

3) What is happening/not happening?
as the problem

**4)

5) Attach logs after turning logging level to Full
4/23/2021, 12:11:53 AM +393ms
+5ms ╔Received event [Home].test = 1619133113393 with a delay of 0ms,canQueue: true, calledMyself: false
+65ms ║RunTime initialize > 64 LockT > 1ms > rtDT > 50ms > pistonT > 49ms (first state access 13 6 58)
+77ms ║Runtime (32888 bytes) successfully initialized in 50ms (v0.3.113.20210211_HE)
+78ms ║╔Execution stage started
+129ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+136ms ║║Comparison (string) ACTIVE did_not_change = true (6ms)
+149ms ║║Comparison (string) ACTIVE did_not_change = true (12ms)
+163ms ║║Comparison (string) ACTIVE did_not_change = true (13ms)
+172ms ║║Comparison (string) INACTIVE did_not_change = true (8ms)
+178ms ║║Comparison (string) ACTIVE did_not_change = true (5ms)
+187ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+196ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+201ms ║║Comparison (string) INACTIVE did_not_change = true (5ms)
+208ms ║║Comparison (string) ACTIVE did_not_change = true (5ms)
+219ms ║║Comparison (string) ACTIVE did_not_change = true (10ms)
+228ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+238ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+248ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+261ms ║║Comparison (string) ACTIVE did_not_change = true (12ms)
+316ms ║║Comparison (string) ACTIVE did_not_change = true (55ms)
+327ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+334ms ║║Comparison (string) ACTIVE did_not_change = true (7ms)
+349ms ║║Comparison (string) ACTIVE did_not_change = true (14ms)
+381ms ║║Comparison (string) ACTIVE did_not_change = true (31ms)
+392ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+401ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+407ms ║║Comparison (string) INACTIVE did_not_change = true (5ms)
+417ms ║║Comparison (string) ACTIVE did_not_change = true (10ms)
+428ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+439ms ║║Comparison (string) ACTIVE did_not_change = true (11ms)
+445ms ║║Comparison (string) ACTIVE did_not_change = true (5ms)
+453ms ║║Comparison (string) ACTIVE did_not_change = true (6ms)
+460ms ║║Comparison (string) ACTIVE did_not_change = true (6ms)
+469ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+475ms ║║Comparison (string) ACTIVE did_not_change = true (6ms)
+489ms ║║Comparison (string) ACTIVE did_not_change = true (14ms)
+499ms ║║Comparison (string) ACTIVE did_not_change = true (10ms)
+571ms ║║Comparison (string) ACTIVE did_not_change = true (72ms)
+582ms ║║Comparison (string) ACTIVE did_not_change = true (11ms)
+593ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+603ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+613ms ║║Comparison (string) ACTIVE did_not_change = true (10ms)
+623ms ║║Comparison (string) ACTIVE did_not_change = true (10ms)
+635ms ║║Comparison (string) ACTIVE did_not_change = true (10ms)
+644ms ║║Comparison (string) ACTIVE did_not_change = true (8ms)
+658ms ║║Comparison (string) ACTIVE did_not_change = true (13ms)
+672ms ║║Comparison (string) ACTIVE did_not_change = true (13ms)
+682ms ║║Comparison (string) ACTIVE did_not_change = true (9ms)
+689ms ║║Comparison (string) ACTIVE did_not_change = true (7ms)
+695ms ║║Comparison (string) ACTIVE did_not_change = true (4ms)Preformatted text


#2

Few things

  • I assume you checked that this attribute actually changes for the devices regularly?
    • I suggest you check the device events to ensure your ‘heuristic’ is correct
  • An every block when it fires, only runs the every block, so you likely should convert that to an if statement if you want it to run the entire piston

#3

Thoughts:

  • The piston will run automatically once every twenty four hours and do nothing. Every blocks are self contained and do not cause the rest of the piston to run.
  • $status is the online/offline status of your device and doesn’t constantly change. Presumably as it returns ACTIVE / INACTIVE this is an HE installation as ST now uses ONLINE / OFFLINE. All of your devices are likely to match unless they have dropped offline or gone back online recently.
  • Your for each loop just looks wrong. It seems to be using currentDevice as the loop iterator, so it would just loop round setting a variable to the name of each device and doing nothing else. Typically for each is used with $device as the iterator.