Piston Sending Multiple SMS Notifications


#1

1) Give a description of the problem
I have a piston that is sending two SMS notifications

2) What is the expected behaviour?
I should be only getting one SMS notification based on the trigger I have setup.

3) What is happening/not happening?
At the scheduled time of the trigger I get one SMS notification then a minute later I get another one.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
2/19/2020, 5:08:59 PM +56ms
+0ms ╔Received event [Home].time = 1582150140000 with a delay of -945ms
+173ms ║RunTime Analysis CS > 75ms > PS > 90ms > PE > 9ms > CE
+175ms ║Runtime (37468 bytes) successfully initialized in 90ms (v0.3.110.20191009) (174ms)
+176ms ║╔Execution stage started
+202ms ║║Comparison (time) 61739237 happens_daily_at (time) 1582150140000 = true (1ms)
+203ms ║║Time restriction check passed
+204ms ║║Condition #2 evaluated true (23ms)
+221ms ║║Cancelling statement #2’s schedules…
+227ms ║║Requesting time schedule wake up at Thu, Feb 20 2020 @ 5:09:00 PM EST
+229ms ║║Condition group #1 evaluated true (state did not change) (48ms)
+231ms ║║Cancelling statement #3’s schedules…
+243ms ║║Skipped execution of physical command [Kids Bedroom].on([]) because it would make no change to the device. (6ms)
+244ms ║║Executed [Kids Bedroom].on (8ms)
+251ms ║║Skipped execution of physical command [Living Room Northeast].on([]) because it would make no change to the device. (5ms)
+252ms ║║Executed [Living Room Northeast].on (7ms)
+260ms ║║Skipped execution of physical command [Living Room Northwest].on([]) because it would make no change to the device. (5ms)
+260ms ║║Executed [Living Room Northwest].on (7ms)
+267ms ║║Skipped execution of physical command [Master Bedroom].on([]) because it would make no change to the device. (4ms)
+268ms ║║Executed [Master Bedroom].on (6ms)
+275ms ║║Skipped execution of physical command [Playroom Northeast].on([]) because it would make no change to the device. (4ms)
+276ms ║║Executed [Playroom Northeast].on (5ms)
+282ms ║║Skipped execution of physical command [Playroom Southwest].on([]) because it would make no change to the device. (4ms)
+283ms ║║Executed [Playroom Southwest].on (6ms)
+294ms ║║Executed virtual command [Kids Bedroom, Living Room Northeast, Living Room Northwest, Master Bedroom, Playroom Northeast, Playroom Southwest].sendSMSNotification (5ms)
+297ms ║╚Execution stage complete. (121ms)
+298ms ║Setting up scheduled job for Thu, Feb 20 2020 @ 5:09:00 PM EST (in 86400.646s)
+306ms ╚Event processed successfully (307ms)
2/19/2020, 5:07:59 PM +401ms
+0ms ╔Received event [Home].time = 1582150080000 with a delay of -600ms
+328ms ║RunTime Analysis CS > 29ms > PS > 267ms > PE > 32ms > CE
+330ms ║Runtime (37451 bytes) successfully initialized in 267ms (v0.3.110.20191009) (329ms)
+331ms ║╔Execution stage started
+359ms ║║Comparison (time) 61679737 happens_daily_at (time) 1582150140000 = true (1ms)
+360ms ║║Time restriction check passed
+361ms ║║Cancelling condition #2’s schedules…
+362ms ║║Condition #2 evaluated true (26ms)
+367ms ║║Cancelling statement #2’s schedules…
+371ms ║║Requesting time schedule wake up at Wed, Feb 19 2020 @ 5:09:00 PM EST
+374ms ║║Cancelling condition #1’s schedules…
+375ms ║║Condition group #1 evaluated true (state changed) (38ms)
+377ms ║║Cancelling statement #3’s schedules…
+415ms ║║Executed physical command [Kids Bedroom].on() (31ms)
+416ms ║║Executed [Kids Bedroom].on (33ms)
+436ms ║║Executed physical command [Living Room Northeast].on() (15ms)
+436ms ║║Executed [Living Room Northeast].on (17ms)
+457ms ║║Executed physical command [Living Room Northwest].on() (16ms)
+458ms ║║Executed [Living Room Northwest].on (18ms)
+479ms ║║Executed physical command [Master Bedroom].on() (16ms)
+480ms ║║Executed [Master Bedroom].on (17ms)
+502ms ║║Executed physical command [Playroom Northeast].on() (18ms)
+503ms ║║Executed [Playroom Northeast].on (20ms)
+522ms ║║Executed physical command [Playroom Southwest].on() (14ms)
+523ms ║║Executed [Playroom Southwest].on (16ms)
+546ms ║║Executed virtual command [Kids Bedroom, Living Room Northeast, Living Room Northwest, Master Bedroom, Playroom Northeast, Playroom Southwest].sendSMSNotification (10ms)
+549ms ║╚Execution stage complete. (219ms)
+550ms ║Setting up scheduled job for Wed, Feb 19 2020 @ 5:09:00 PM EST (in 60.049s)
+557ms ╚Event processed successfully (556ms)


#2

Pistons set their own schedules. Your piston will have run at 5:08pm on the 18th, which was sunset. It will then have seen its next scheduled run is also at sunset. As that has been and gone for the day, and it doesn’t yet know when sunset is on the 19th, it sets the timer for 24 hours time, which is its best guess.

On the 19th the piston ran at 5:08pm and sent a text. It then saw it next needed to run at sunset which was 5:09pm. That hadn’t arrived yet so it set a timer for about a minute’s time and ran the piston again sending another text. It then saw that sunset had gone for the day so set the next timer for 5:09pm on the 20th. And so on …

The sunrise and sunset data is updated at midnight, if I remember correctly (*), so a workaround is to run the piston sometime between then and sunset to pick up the new values. Just do a ‘happens daily at 4am’ or something like that, that doesn’t actually do anything, and that will set the next schedule correctly. Someone may offer a more polished solution.

(*) I don’t. It seems it is updated when it is found to be more than eight hours out of date. I’m not sure at which point it returns new information.


#3

Thanks for the reply.

I understand what you mean, but it doesn’t make much sense. What is the purpose of the sunset/sunrise preset if it doesn’t actually work as expected? Is it bugged?


#4

WebCoRE schedules a wakeup based on the data it has at that moment.
This means that 6 months every year, you will get double alerts.
(half of the year where the sun sets later than the previous day)

The other half of the year, you will only get a single SMS, but it will always be a minute early…


What I do is stick a small block at the bottom of that piston:

Every day at 4am
    do (nothing)
END EVERY

This forces it to run on the new day to update the scheduled time.
(but won’t actually do anything at 4am)


#5

That seems…odd. Almost like a programming oversight. I would think it wouldn’t be too difficult to pull the sunrise/sunset time from when it’s actually accurate earlier in the day.


#6

I wouldn’t say there is any bug here. It is just that because of the way webCoRE pistons work, because of the way SmartThings makes sunrise/sunset information available, and because your piston makes it obvious when it is being run twice, your particular example isn’t going to work as you expect it to. All it takes is the piston to fire at another time when the sunrise/sunset information has been updated for the new day, and you would get sunset when you expect it to (SmartThings is never terribly precise with timings).


#7

It’s a piece of cake. Just add this small block at the very bottom of that piston:

Every day at 4am
    do (nothing)
END EVERY

#8

Something like this?


#9

I have this piston that runs every day at sunset and I have never noticed that it runs twice. There is no notification in this piston but the switch that gets toggled starts another piston that closes all of my Leviosa shades. Once the entire sequence is ran there is an announcement over Alexa that all shades are closed. I have never gotten two notifications.

Is there a difference between time happens daily and run every day at?
I will have to turn on logging today and see what happens.


#10

That should do it…

If for some reason, you still have a double SMS, then please add a 12 second wait inside that 4am IF block. This is to force a new timer, that should guarantee that the sunset schedule is accurate. (although you probably do not need to do this step)


#11

The biggest difference is:


#12

I just wanted to follow up. I’ve added the block to run every day at 4:00 AM and since adding I’ve received the correct number of notifications. Thanks for the help.


#13

Sweet! Glad to be able to help!!

Perhaps you can solution an earlier post as the solution to help others…