Sonos Triggering Harmony Denon AVR


#1

1) Give a description of the problem
I’m trying to get that when my Sonos Port (Bathroom in code) starts playing a song (changes state to “Playing”) a Harmony Activity (virtual switch) turns On. This Harmony Activity (Sonos Quincho Test in code example) basically turns on a Denon AVR and switches it to the correct input. I also want that when the Harmony Activity virtual switch is On, and the Sonos is “Paused” for 1 minute, the Harmony Activity virtual switch turns Off. The turning ON works great, however whenever I pause the “timer” starts running and it doesn’t reset if I resume playing. This means that no matter what, the Harmony Activity will turn off 1 minute after the first time I Pause the Sonos. I would like the timer to reset whenever I play again. The Harmony activity should only turn off when Sonos is left on pause for an entire minute.

2) What is the expected behaviour?
Turning off after 1 minute of having the Sonos “Paused” and the Harmony activity On.

3) What is happening/not happening?
The Harmony Activity virtual switch is turning off after 1 minute of the Sonos first being paused. The timer doesn’t reset if I resume playing before the 1 minute runs out.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
/24/2020, 5:24:35 PM +381ms
+1ms ╔Received event [Bathroom].playbackStatus = paused with a delay of 38ms
+64ms ║RunTime Analysis CS > 15ms > PS > 36ms > PE > 13ms > CE
+66ms ║Runtime (37828 bytes) successfully initialized in 36ms (v0.3.110.20191009) (65ms)
+67ms ║╔Execution stage started
+73ms ║║Comparison (string) paused changes_to (string) playing = false (1ms)
+74ms ║║Cancelling condition #2’s schedules…
+75ms ║║Condition #2 evaluated false (5ms)
+76ms ║║Cancelling condition #1’s schedules…
+77ms ║║Condition group #1 evaluated false (state changed) (7ms)
+86ms ║║Comparison (enum) off is (string) on = false (1ms)
+87ms ║║Cancelling condition #6’s schedules…
+88ms ║║Condition #6 evaluated false (9ms)
+89ms ║║Cancelling condition #5’s schedules…
+90ms ║║Condition group #5 evaluated false (state changed) (11ms)
+92ms ║╚Execution stage complete. (26ms)
+93ms ╚Event processed successfully (93ms)
5/24/2020, 5:24:22 PM +58ms
+0ms ╔Received event [Fercho’s Home].time = 1590355462970 with a delay of -913ms
+93ms ║RunTime Analysis CS > 29ms > PS > 50ms > PE > 14ms > CE
+95ms ║Runtime (37834 bytes) successfully initialized in 50ms (v0.3.110.20191009) (94ms)
+96ms ║╔Execution stage started
+104ms ║║Cancelling condition #7’s schedules…
+105ms ║║Condition #7 evaluated true (1ms)
+106ms ║║Cancelling condition #5’s schedules…
+107ms ║║Condition group #5 evaluated true (state changed) (4ms)
+109ms ║║Cancelling statement #8’s schedules…
+190ms ║║Executed physical command [Sonos Quincho Test [Harmony Activity]].off() (78ms)
+191ms ║║Executed [Sonos Quincho Test [Harmony Activity]].off (80ms)
+193ms ║╚Execution stage complete. (98ms)
+194ms ╚Event processed successfully (194ms)
5/24/2020, 5:24:16 PM +918ms
+1ms ╔Received event [Bathroom].playbackStatus = playing with a delay of 41ms
+73ms ║RunTime Analysis CS > 17ms > PS > 44ms > PE > 13ms > CE
+76ms ║Runtime (37835 bytes) successfully initialized in 44ms (v0.3.110.20191009) (74ms)
+77ms ║╔Execution stage started
+84ms ║║Comparison (string) playing changes_to (string) playing = true (0ms)
+85ms ║║Cancelling condition #2’s schedules…
+86ms ║║Condition #2 evaluated true (5ms)
+87ms ║║Cancelling condition #1’s schedules…
+87ms ║║Condition group #1 evaluated true (state changed) (7ms)
+89ms ║║Cancelling statement #3’s schedules…
+95ms ║║Skipped execution of physical command [Sonos Quincho Test [Harmony Activity]].on([]) because it would make no change to the device. (3ms)
+96ms ║║Executed [Sonos Quincho Test [Harmony Activity]].on (4ms)
+99ms ║╚Execution stage complete. (22ms)
+100ms ║Setting up scheduled job for Sun, May 24 2020 @ 5:24:22 PM PYT (in 5.953s)
+134ms ╚Event processed successfully (134ms)
5/24/2020, 5:23:36 PM +558ms
+1ms ╔Received event [Bathroom].playbackStatus = paused with a delay of 33ms
+133ms ║RunTime Analysis CS > 17ms > PS > 37ms > PE > 78ms > CE
+135ms ║Runtime (37832 bytes) successfully initialized in 37ms (v0.3.110.20191009) (133ms)
+136ms ║╔Execution stage started
+143ms ║║Comparison (string) paused changes_to (string) playing = false (0ms)
+144ms ║║Condition #2 evaluated false (4ms)
+145ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+153ms ║║Comparison (enum) on is (string) on = true (1ms)
+155ms ║║Condition #6 evaluated true (7ms)
+160ms ║║Comparison (string) paused stays (string) paused = true (1ms)
+162ms ║║Condition #7 evaluated false (6ms)
+163ms ║║Condition group #5 evaluated false (state did not change) (15ms)
+165ms ║╚Execution stage complete. (29ms)
+166ms ║Setting up scheduled job for Sun, May 24 2020 @ 5:24:22 PM PYT (in 46.246s)
+179ms ╚Event processed successfully (178ms)
5/24/2020, 5:23:12 PM +857ms
+2ms ╔Received event [Bathroom].playbackStatus = paused with a delay of 43ms
+10082ms ║RunTime Analysis CS > 16ms > PS > 10054ms > PE > 11ms > CE
+10082ms ║Piston waited at a semaphore for 10014ms
+10085ms ║Runtime (37909 bytes) successfully initialized in 10054ms (v0.3.110.20191009) (10082ms)
+10085ms ║╔Execution stage started
+10092ms ║║Comparison (string) paused changes_to (string) playing = false (1ms)
+10093ms ║║Cancelling condition #2’s schedules…
+10094ms ║║Condition #2 evaluated false (5ms)
+10095ms ║║Cancelling condition #1’s schedules…
+10096ms ║║Condition group #1 evaluated false (state changed) (7ms)
+10104ms ║║Comparison (enum) on is (string) on = true (1ms)
+10106ms ║║Condition #6 evaluated true (8ms)
+10111ms ║║Comparison (string) paused stays (string) paused = true (1ms)
+10112ms ║║Adding a timed trigger schedule for condition 7
+10115ms ║║Cancelling condition #7’s schedules…
+10115ms ║║Condition #7 evaluated false (9ms)
+10116ms ║║Cancelling condition #5’s schedules…
+10117ms ║║Condition group #5 evaluated false (state changed) (19ms)
+10119ms ║╚Execution stage complete. (34ms)
+10121ms ║Setting up scheduled job for Sun, May 24 2020 @ 5:24:22 PM PYT (in 59.993s)
+10128ms ╚Event processed successfully (10128ms)
5/24/2020, 5:23:12 PM +619ms
+1ms ╔Received event [Bathroom].playbackStatus = playing with a delay of 38ms
+67ms ║RunTime Analysis CS > 18ms > PS > 37ms > PE > 12ms > CE
+69ms ║Runtime (37833 bytes) successfully initialized in 37ms (v0.3.110.20191009) (67ms)
+70ms ║╔Execution stage started
+77ms ║║Comparison (string) playing changes_to (string) playing = true (0ms)
+79ms ║║Cancelling condition #2’s schedules…
+80ms ║║Condition #2 evaluated true (5ms)
+81ms ║║Cancelling condition #1’s schedules…
+81ms ║║Condition group #1 evaluated true (state changed) (7ms)
+84ms ║║Cancelling statement #3’s schedules…
+930ms ║║Executed physical command [Sonos Quincho Test [Harmony Activity]].on() (842ms)
+931ms ║║Executed [Sonos Quincho Test [Harmony Activity]].on (845ms)
+933ms ║╚Execution stage complete. (863ms)
+934ms ╚Event processed successfully (934ms)
5/24/2020, 5:22:52 PM +90ms
+0ms ╔Received event [Fercho’s Home].time = 1590355373078 with a delay of -989ms
+70ms ║RunTime Analysis CS > 18ms > PS > 41ms > PE > 11ms > CE
+72ms ║Runtime (37838 bytes) successfully initialized in 41ms (v0.3.110.20191009) (71ms)
+74ms ║╔Execution stage started
+83ms ║║Cancelling condition #7’s schedules…
+85ms ║║Condition #7 evaluated true (1ms)
+86ms ║║Cancelling condition #5’s schedules…
+86ms ║║Condition group #5 evaluated true (state changed) (4ms)
+89ms ║║Cancelling statement #8’s schedules…
+306ms ║║Executed physical command [Sonos Quincho Test [Harmony Activity]].off() (214ms)
+307ms ║║Executed [Sonos Quincho Test [Harmony Activity]].off (216ms)
+311ms ║╚Execution stage complete. (237ms)
+312ms ╚Event processed successfully (312ms)
5/24/2020, 5:21:52 PM +987ms
+1ms ╔Received event [Bathroom].playbackStatus = paused with a delay of 32ms
+60ms ║RunTime Analysis CS > 14ms > PS > 38ms > PE > 8ms > CE
+62ms ║Runtime (37830 bytes) successfully initialized in 38ms (v0.3.110.20191009) (61ms)
+63ms ║╔Execution stage started
+69ms ║║Comparison (string) paused changes_to (string) playing = false (1ms)
+70ms ║║Cancelling condition #2’s schedules…
+71ms ║║Condition #2 evaluated false (5ms)
+72ms ║║Cancelling condition #1’s schedules…
+73ms ║║Condition group #1 evaluated false (state changed) (7ms)
+82ms ║║Comparison (enum) on is (string) on = true (1ms)
+83ms ║║Cancelling condition #6’s schedules…
+84ms ║║Condition #6 evaluated true (9ms)
+89ms ║║Comparison (string) paused stays (string) paused = true (1ms)
+91ms ║║Adding a timed trigger schedule for condition 7
+93ms ║║Cancelling condition #7’s schedules…
+94ms ║║Condition #7 evaluated false (9ms)
+95ms ║║Condition group #5 evaluated false (state did not change) (20ms)
+97ms ║╚Execution stage complete. (35ms)
+98ms ║Setting up scheduled job for Sun, May 24 2020 @ 5:22:53 PM PYT (in 59.993s)
+106ms ╚Event processed successfully (106ms)
5/24/2020, 5:21:27 PM +256ms
+2ms ╔Received event [Bathroom].playbackStatus = playing with a delay of 180ms
+70ms ║RunTime Analysis CS > 16ms > PS > 40ms > PE > 13ms > CE
+72ms ║Runtime (37811 bytes) successfully initialized in 40ms (v0.3.110.20191009) (70ms)
+73ms ║╔Execution stage started
+80ms ║║Comparison (string) playing changes_to (string) playing = true (1ms)
+81ms ║║Cancelling condition #2’s schedules…
+82ms ║║Condition #2 evaluated true (5ms)
+83ms ║║Cancelling condition #1’s schedules…
+84ms ║║Condition group #1 evaluated true (state changed) (7ms)
+86ms ║║Cancelling statement #3’s schedules…
+987ms ║║Executed physical command [Sonos Quincho Test [Harmony Activity]].on() (898ms)
+988ms ║║Executed [Sonos Quincho Test [Harmony Activity]].on (900ms)
+991ms ║╚Execution stage complete. (918ms)
+992ms ╚Event processed successfully (992ms)
5/24/2020, 5:21:09 PM +867ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+221ms ║╔Subscribing to devices…
+229ms ║║Subscribing to Bathroom.playbackStatus…
+289ms ║║Subscribing to Sonos Quincho Test [Harmony Activity]…
+290ms ║╚Finished subscribing (72ms)
+321ms ║Comparison (enum) off is (string) on = false (2ms)
+329ms ║Comparison (string) paused stays (string) paused = true (1ms)
+330ms ║Cancelling condition #7’s schedules…
+332ms ║Cancelling condition #5’s schedules…
+342ms ╚Piston successfully started (340ms)

Clear

Full

#2

So many thoughts in my head right now, but a quick and dirty solution would be to simply add another conditional check after the 1 minute, and before the Turn off command.

IE:

IF Bathroom X for 1 minute  <-- Trigger
   and
   Harmony's switch is on   <-- Condition
Then
   IF Bathroom's playbackStatus is paused   <-- New condition
      Then Turn off Harmony
   END IF
END IF

Side Note:

Personally, I would never use a STAYS timer inside an ELSE block…


#3

Thanks for your reply!

What would the “X” stand for in “Bathroom X”? I can’t seem to find how to make a trigger check the status of a switch for 1 minute…


#4

I used the term X because that is a longer conversation than I currently have time for at the moment.

Essentially, I recommend using a trigger, followed by a condition
(but which trigger is a giant can of worms)


Untested, but my last post coupled with my “side note” may even solve the issue…


#5

Thank you very much! I managed to get it working taking out the STAYS timer from the else block. Created two pistons (goes below) and it now works. Will try to tidy it up now!

To turn on the Receiver when Sonos plays (through Harmony).

To turn off the Receiver after Sonos pauses for 1 minute (through Harmony). (I will change this now to 15 minutes for normal use).


#7

Hi Alwas! Very sorry, didn’t know exactly how it worked. I thought I had to mark as a solution the post with the code that worked, wether that comment was mine or someone else! Just corrected it! have a good day.


#8

I don’t feel I put in enough time to justify the solution, but I appreciate the gesture none-the-less. :sunglasses: