SMH - Multiple iterations outside FOREACH


#1

1) Give a description of the problem
Piston to monitor and alert on low battery levels. I copied and tweaked this piston. I get multiple SMS notifications but I can’t see why. Appears to be out of FOREACH loop to me, but I get multiple notifications - always a multiple of number of devices below battery threshold.

2) What is the expected behaviour?
Only one notification per 24 hours or change in batt level on any monitored device

3) What is happening/not happening?
Receiving multiple SMS notifications instead of just one.

4) Post a Green Snapshot of the piston![image|45x37](upload://xK8WwMCzoDkDrcB1Jf27yjtZ9bq

.png)
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full

+0ms ╔Received event [His House].test = 1564062935927 with a delay of 0ms
+99ms ║RunTime Analysis CS > 21ms > PS > 42ms > PE > 36ms > CE
+102ms ║Runtime (46043 bytes) successfully initialized in 42ms (v0.3.10e.20190628) (100ms)
+103ms ║╔Execution stage started
+137ms ║║Condition #50 evaluated false (29ms)
+139ms ║║Condition group #49 evaluated false (state did not change) (31ms)
+185ms ║║Comparison (dynamic) 1 drops_to_or_below (integer) 20 = false (1ms)
+187ms ║║Condition #32 evaluated false (32ms)
+188ms ║║Condition group #30 evaluated false (state did not change) (33ms)
+191ms ║║Cancelling statement #31’s schedules…
+224ms ║║Executed virtual command setState (1ms)
+227ms ║║Cancelling statement #43’s schedules…
+233ms ║║Executed virtual command setVariable (3ms)
+244ms ║║Cancelling statement #46’s schedules…
+255ms ║║Calculating (string) : == (string) % >> (boolean) false
+264ms ║║Calculating (string) Current battery levels: + (string) >> (string) Current battery levels:
+268ms ║║Calculating (string) Current battery levels: + (string) Arlo-FrontDoor >> (string) Current battery levels: Arlo-FrontDoor
+272ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor + (string) : >> (string) Current battery levels: Arlo-FrontDoor:
+279ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: + (string) 7 >> (string) Current battery levels: Arlo-FrontDoor: 7
+282ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7 + (string) % >> (string) Current battery levels: Arlo-FrontDoor: 7%
+287ms ║║Executed virtual command setVariable (3ms)
+300ms ║║Cancelling statement #46’s schedules…
+311ms ║║Calculating (string) % == (string) % >> (boolean) true
+320ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7% + (string) , >> (string) Current battery levels: Arlo-FrontDoor: 7%,
+325ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, + (string) Arlo-MainKitchen >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen
+328ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen + (string) : >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen:
+335ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: + (string) 78 >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78
+339ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78 + (string) % >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%
+344ms ║║Executed virtual command setVariable (3ms)
+358ms ║║Cancelling statement #46’s schedules…
+370ms ║║Calculating (string) % == (string) % >> (boolean) true
+378ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78% + (string) , >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%,
+383ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, + (string) Arlo-Reception >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception
+386ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception + (string) : >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception:
+392ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: + (string) 36 >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36
+395ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36 + (string) % >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%
+400ms ║║Executed virtual command setVariable (3ms)
+412ms ║║Cancelling statement #46’s schedules…
+423ms ║║Calculating (string) % == (string) % >> (boolean) true
+431ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36% + (string) , >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%,
+435ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, + (string) Arlo-SideKitchen >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen
+439ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen + (string) : >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen:
+446ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: + (string) 1 >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1
+449ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1 + (string) % >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%
+455ms ║║Executed virtual command setVariable (4ms)
+540ms ║║Cancelling statement #46’s schedules…
+551ms ║║Calculating (string) % == (string) % >> (boolean) true
+560ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1% + (string) , >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%,
+564ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, + (string) Arlo-Upstairs >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs
+568ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs + (string) : >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs:
+574ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs: + (string) 1 >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs: 1
+577ms ║║Calculating (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs: 1 + (string) % >> (string) Current battery levels: Arlo-FrontDoor: 7%, Arlo-MainKitchen: 78%, Arlo-Reception: 36%, Arlo-SideKitchen: 1%, Arlo-Upstairs: 1%
+583ms ║║Executed virtual command setVariable (3ms)
+606ms ║╚Execution stage complete. (503ms)
+610ms ║Setting up scheduled job for Thu, Jul 25 2019 @ 12:15:00 PM PDT (in 19163.463s)
+621ms ╚Event processed successfully (620ms)
7/25/2019, 6:50:41 AM +895ms
+10087ms ║Piston waited at a semaphore for 10013ms

REMOVE BELOW AFTER READING
indent preformatted text by 4 spaces


#2

Put your evaluation statements inside the every X hours statement, as it is, you’ll get notified when a battery level changes.


#3

I want the notifications on battery level change. (See #2 above). It’s that the notifications come in two or three times the number of under-threshold devices - ie: One camera drops battery level, I will receive receive six SMS messages that the device is below threshold. I should receive but one. The messaging DO is not within a FOREACH loop, but it acts as if it is. To me, the code looks kosher and should not over-notify, but I’m just a nuB.


#4

The screenshot you posted only shows us the first 7 lines…


#5

Per 24 hours is easy but if you want notification on CHANGING LEVEL on monitored devices, you will get lots of notifications.

Here is my piston for battery levels maybe it helps… (it was written by @WCmore and i added just a little more)