Chromecast Audio - turning amplifier on/off


1) Give a description of the problem
I am trying to create a simple piston to turn on my amplifiers (on an extension lead wired into a single smart plug for now - I may split them in future) when any one of 3 chromecast audios, or 2 groups of chromecast audios are playing. I then want to turn the amplifiers off if there is no music playing on any of the chromecasts/groups for a period of 5 minutes. Currently the amplifier will turn on when music starts playing but does not turn off. I can review the status of the devices through the cast-web-api and confirm that none are playing (as confirmed in the piston logs too).

Any help gratefully received!

2) What is the expected behaviour?
Any chromecast changes to ‘playing’ - amplifiers turn on
All chromecasts are not playing music and the amplifier is still on - turn it off

3) What is happening/not happening?
The amplifier is not turning off

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

5) Attach logs after turning logging level to Full
30/06/2020, 09:45:34 +960ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+256ms ║╔Subscribing to devices…
+291ms ║║Subscribing to Bathroom speakers.status…
+305ms ║║Subscribing to Downstairs.status…
+317ms ║║Subscribing to Everywhere.status…
+327ms ║║Subscribing to Kitchen Diner Speakers.status…
+338ms ║║Subscribing to Living Room speakers.status…
+401ms ║║Subscribing to Amplifiers…
+402ms ║╚Finished subscribing (162ms)
+446ms ║Comparison (string) ready stays_away_from (string) playing = true (1ms)
+448ms ║Comparison (string) ready stays_away_from (string) playing = true (1ms)
+451ms ║Comparison (string) ready stays_away_from (string) playing = true (2ms)
+454ms ║Comparison (string) ready stays_away_from (string) playing = true (1ms)
+456ms ║Comparison (string) ready stays_away_from (string) playing = true (1ms)
+465ms ║Comparison (enum) on is (string) on = true (2ms)
+498ms ╚Piston successfully started (497ms)


Well it looks like this is now working! I didn’t change any of the code but I did play some music and stop it and then it triggered the timer.

It seems starting the piston when the music is not playing stops it from working? Maybe the piston has to witness the change from false to true for my first if statement before it triggers the timer. I assumed (wrongly) that it would start the 5 minute timer from when I started the piston.

I’ll leave this post here in case it helps anyone else.