Play/Stop Song at Specific Time


#1

1) Give a description of the problem
I want to play a specific music track at a specific time and end at a specific time every day. Attempting to lure song birds (purple martin) to a new nest colony I set up in the yard with their mating song.

2) What is the expected behavior?
At 4am every morning during April, May and June the track Purple Martin Dawn song will play until approx 12pm. The track is only about an hour long, so I want it too loop until 12pm, then stop. Then repeat the next day. I uploaded the track to my Google Music Library and pasted the link into webcore.

3) What is happening/not happening?
The song is not playing unless I started it manually in the sonos app. If I use my Sonos for something else, the song no longer plays when the piston calls for it. I am also seeing a play track every 60min in SmartThings outside the time frame that I set.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

5/20/2018, 6:05:59 PM +92ms
+0ms	╔Received event [Home].time = 1526853960000 with a delay of -909ms
+151ms	║RunTime Analysis CS > 16ms > PS > 54ms > PE > 82ms > CE
+154ms	║Runtime (37843 bytes) successfully initialized in 54ms (v0.3.104.20180323) (152ms)
+155ms	║╔Execution stage started
+164ms	║║Comparison (string) :544a9b992c238a89c379073fefaa7fe1: is_not (string) :d9ffb4c971fcdbf37488d71ae133699a: = true (2ms)
+166ms	║║Condition #1 evaluated true (5ms)
+167ms	║║Condition group #null evaluated true (state did not change) (6ms)
+171ms	║║Comparison (time) 65159261 happens_daily_at (time) 65160000 = true (0ms)
+173ms	║║Time restriction check passed
+174ms	║║Cancelling condition #8's schedules...
+175ms	║║Condition #8 evaluated true (6ms)
+176ms	║║Cancelling statement #8's schedules...
+179ms	║║Requesting time schedule wake up at Mon, May 21 2018 @ 6:06:00 PM EDT
+182ms	║║Cancelling condition #2's schedules...
+183ms	║║Condition group #2 evaluated true (state changed) (14ms)
+187ms	║║Cancelling statement #4's schedules...
+218ms	║║Executed physical command [Pool Speakers].playTrack([https://play.google.com/music/listen?u=0#/album///Purple+Martin+Dawn+Song]) (26ms)
+219ms	║║Executed [Pool Speakers].playTrack (28ms)
+228ms	║║Executed virtual command [Pool Speakers].wait (5ms)
+230ms	║║Requesting a wake up for Sun, May 20 2018 @ 7:05:59 PM EDT (in 3600.0s)
+237ms	║╚Execution stage complete. (83ms)
+239ms	║Setting up scheduled job for Sun, May 20 2018 @ 6:30:00 PM EDT (in 1440.67s), with 2 more jobs pending
+247ms	╚Event processed successfully (247ms)
5/20/2018, 6:05:38 PM +938ms
+0ms	╔Starting piston... (v0.3.104.20180323)
+592ms	║╔Subscribing to devices...
+704ms	║║Subscribing to Pool Speakers...
+705ms	║╚Finished subscribing (126ms)
+737ms	║Comparison (string) :544a9b992c238a89c379073fefaa7fe1: is_not (string) :d9ffb4c971fcdbf37488d71ae133699a: = true (6ms)
+743ms	║Comparison (time) 65139679 happens_daily_at (time) 65160000 = false (0ms)
+749ms	║Cancelling statement #8's schedules...
+752ms	║Requesting time schedule wake up at Sun, May 20 2018 @ 6:06:00 PM EDT
+767ms	║Comparison (time) 65139704 happens_daily_at (time) 66600000 = false (0ms)
+769ms	║Cancelling statement #7's schedules...
+772ms	║Requesting time schedule wake up at Sun, May 20 2018 @ 6:30:00 PM EDT
+789ms	║Setting up scheduled job for Sun, May 20 2018 @ 6:06:00 PM EDT (in 20.274s), with 1 more job pending
+802ms	╚Piston successfully started (802ms)
5/20/2018, 6:04:46 PM +596ms
+1ms	╔Starting piston... (v0.3.104.20180323)
+362ms	║╔Subscribing to devices...
+439ms	║║Subscribing to Pool Speakers...
+440ms	║╚Finished subscribing (86ms)
+470ms	║Comparison (string) :544a9b992c238a89c379073fefaa7fe1: is_not (string) :d9ffb4c971fcdbf37488d71ae133699a: = true (8ms)
+477ms	║Comparison (time) 65087069 happens_daily_at (time) 64980000 = false (2ms)
+495ms	║Cancelling statement #8's schedules...
+502ms	║Requesting time schedule wake up at Mon, May 21 2018 @ 6:03:00 PM EDT
+520ms	║Comparison (time) 65087114 happens_daily_at (time) 65040000 = false (1ms)
+523ms	║Cancelling statement #7's schedules...
+526ms	║Requesting time schedule wake up at Mon, May 21 2018 @ 6:04:00 PM EDT
+541ms	║Setting up scheduled job for Mon, May 21 2018 @ 6:03:00 PM EDT (in 86292.864s), with 1 more job pending
+560ms	╚Piston successfully started (559ms)
5/20/2018, 6:03:59 PM +100ms
+0ms	╔Received event [Home].time = 1526853840000 with a delay of -900ms
+152ms	║RunTime Analysis CS > 21ms > PS > 57ms > PE > 75ms > CE
+155ms	║Runtime (37728 bytes) successfully initialized in 57ms (v0.3.104.20180323) (154ms)
+156ms	║╔Execution stage started
+166ms	║║Comparison (string) :544a9b992c238a89c379073fefaa7fe1: is_not (string) :d9ffb4c971fcdbf37488d71ae133699a: = true (2ms)
+168ms	║║Condition #1 evaluated true (6ms)
+169ms	║║Condition group #null evaluated true (state did not change) (7ms)
+174ms	║║Comparison (time) 65039272 happens_daily_at (time) 64980000 = false (1ms)
+175ms	║║Cancelling condition #8's schedules...
+176ms	║║Condition #8 evaluated false (5ms)
+182ms	║║Cancelling statement #8's schedules...
+185ms	║║Requesting time schedule wake up at Mon, May 21 2018 @ 6:03:00 PM EDT
+188ms	║║Cancelling condition #2's schedules...
+188ms	║║Condition group #2 evaluated false (state changed) (17ms)
+192ms	║╚Execution stage complete. (36ms)
+194ms	║Setting up scheduled job for Mon, May 21 2018 @ 6:03:00 PM EDT (in 86340.707s)
+202ms	╚Event processed successfully (202ms)
5/20/2018, 6:02:59 PM +116ms
+0ms	╔Received event [Home].time = 1526853780000 with a delay of -885ms
+354ms	║RunTime Analysis CS > 21ms > PS > 259ms > PE > 74ms > CE
+357ms	║Runtime (37730 bytes) successfully initialized in 259ms (v0.3.104.20180323) (355ms)
+358ms	║╔Execution stage started
+368ms	║║Comparison (string) :544a9b992c238a89c379073fefaa7fe1: is_not (string) :d9ffb4c971fcdbf37488d71ae133699a: = true (2ms)
+370ms	║║Condition #1 evaluated true (6ms)
+371ms	║║Condition group #null evaluated true (state did not change) (8ms)
+376ms	║║Comparison (time) 64979490 happens_daily_at (time) 64980000 = true (1ms)
+377ms	║║Time restriction check passed
+378ms	║║Condition #8 evaluated true (5ms)
+379ms	║║Cancelling statement #8's schedules...
+382ms	║║Requesting time schedule wake up at Mon, May 21 2018 @ 6:03:00 PM EDT
+385ms	║║Condition group #2 evaluated true (state did not change) (12ms)
+389ms	║║Cancelling statement #4's schedules...
+436ms	║║Executed physical command [Pool Speakers].playTrack([https://play.google.com/music/listen?u=0#/album///Purple+Martin+Dawn+Song]) (42ms)
+437ms	║║Executed [Pool Speakers].playTrack (44ms)
+441ms	║║Executed virtual command [Pool Speakers].wait (1ms)
+442ms	║║Requesting a wake up for Sun, May 20 2018 @ 7:02:59 PM EDT (in 3600.0s)
+449ms	║╚Execution stage complete. (92ms)
+452ms	║Setting up scheduled job for Sun, May 20 2018 @ 6:04:00 PM EDT (in 60.433s), with 2 more jobs pending
+459ms	╚Event processed successfully (459ms)
5/20/2018, 6:02:37 PM +333ms
+0ms	╔Received event [Home].time = 1526853758678 with a delay of -1346ms
+144ms	║RunTime Analysis CS > 18ms > PS > 56ms > PE > 70ms > CE
+147ms	║Runtime (37729 bytes) successfully initialized in 56ms (v0.3.104.20180323) (145ms)
+148ms	║╔Execution stage started
+167ms	║║Comparison (time) 64957497 happens_daily_at (time) 65040000 = false (0ms)
+168ms	║║Condition #7 evaluated false (4ms)
+169ms	║║Cancelling statement #7's schedules...
+173ms	║║Requesting time schedule wake up at Sun, May 20 2018 @ 6:04:00 PM EDT
+176ms	║║Condition group #3 evaluated false (state did not change) (11ms)
+178ms	║║Cancelling statement #4's schedules...
+223ms	║║Executed physical command [Pool Speakers].playTrack([https://play.google.com/music/listen?u=0#/album///Purple+Martin+Dawn+Song]) (39ms)
+224ms	║║Executed [Pool Speakers].playTrack (41ms)
+228ms	║║Executed virtual command [Pool Speakers].wait (1ms)
+229ms	║║Requesting a wake up for Sun, May 20 2018 @ 7:02:37 PM EDT (in 3600.0s)
+236ms	║╚Execution stage complete. (89ms)
+239ms	║Setting up scheduled job for Sun, May 20 2018 @ 6:03:00 PM EDT (in 22.429s), with 2 more jobs pending
+246ms	╚Event processed successfully (246ms)
5/20/2018, 5:02:38 PM +280ms
+0ms	╔Received event [Home].time = 1526850159424 with a delay of -1145ms
+325ms	║RunTime Analysis CS > 19ms > PS > 40ms > PE > 266ms > CE
+328ms	║Runtime (37730 bytes) successfully initialized in 40ms (v0.3.104.20180323) (326ms)
+329ms	║╔Execution stage started
+347ms	║║Comparison (time) 61358625 happens_daily_at (time) 65040000 = false (1ms)
+349ms	║║Condition #7 evaluated false (5ms)
+350ms	║║Cancelling statement #7's schedules...
+353ms	║║Requesting time schedule wake up at Sun, May 20 2018 @ 6:04:00 PM EDT
+356ms	║║Condition group #3 evaluated false (state did not change) (11ms)
+358ms	║║Cancelling statement #4's schedules...
+392ms	║║Executed physical command [Pool Speakers].playTrack([https://play.google.com/music/listen?u=0#/album///Purple+Martin+Dawn+Song]) (28ms)
+393ms	║║Executed [Pool Speakers].playTrack (30ms)
+397ms	║║Executed virtual command [Pool Speakers].wait (1ms)
+398ms	║║Requesting a wake up for Sun, May 20 2018 @ 6:02:38 PM EDT (in 3600.0s)
+405ms	║╚Execution stage complete. (77ms)
+408ms	║Setting up scheduled job for Sun, May 20 2018 @ 6:02:38 PM EDT (in 3599.991s), with 2 more jobs pending
+415ms	╚Event processed successfully (414ms)

#2

Try something like this

That should start it automatically. But if you use sonos for something else. Then your going to have to put in more stuff to play track again.


#3

I got it working with the following. It started up on and ended exactly on time. Repeated the track without any issues as well. However, I still need to test what happens if I play a different song before the piston fires again. Going to give that a try tomorrow hopefully.


#4

if you play something else before it triggers again, it will stop what you are playing on the next trigger and play tour songbird mp3 then continue with the loop until the end time.

You could create another if in that repeat to check if current track does not equal songbird.mp3. Then exit and cancel all pending tasks.

That way if your out by the pool and playing music, it won’t cut your music out to play your song bird mp3

Just a thought


#5

Oh, that’s a good idea! Something like this?


#6

Looks like it should work, have you tried it yet?


#7

Not yet, going to give it a try this weekend.