So I've automated my receiver to turn on and change to the correct input as soon as I begin playing music on my Chromecast Audio (so no CEC). And that part works...When I begin playing something on the CA device, the Source changes successfully as expected, and triggers the rule.
However the status does not change from idle, and once playback has begun, the Source will not change back to None if playback is stopped. (So next time the rule can't trigger because source won't update), and you can't use Hubitat to control the CA ... At first...
After about 30 seconds I receive this error...
errorjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean (parse)
Once the error occurs I am then able to control the CA from within Hubitat (by either pressing play, pause, or stop). To have the statuses update i must press play from within Hubitat (or refresh if the music was stopped or the source changed prior to the error), and then everything will update correctly until the music is stopped.
As it stands now I have added a repeat to my rule. When the rule is triggered, and after the receiver is on and the input is correctly selected, Hubitat repeats pressing play and refresh until either the status changes to playing (because that's what's being pressed) or the source changes back to None (for if the music stopped before the error). But that's not really ideal. If I pause the music via Google before the error occurs, then because Hubitat is pressing play, it will restart playback immediately after the error occurs.
It's a bug that manifests when Chromecast connection drops.
It will get fixed in the next release, but in the meantime please try community Chromecast Helper app that reconnects to Chromecast every few minutes. That should eliminate the condition under which bug occurs.
I created a RM rule that issues a refresh and initialize to each of my assistant devices every 4 minutes. That was the only way I could use "source" to drive some of my rules and keep my devices from occasionally "hanging".
I use a virtual switch to turn the rule on and off. I don't run the rule when I'm away because these commands fill the logs with garbage and there is no way to turn these log entries off.
The 2 second delays are me testing something else.
Could you share details of how you created the rule? I'm wanting to do something similar because I have noticed that my Chromecast doesn't consistently update so my lights don't always dim when playing content like I want them to. I could not figure out how to add Initialize and Refresh as actions in a rule.
Also, I'm with you on not running the rule when you aren't home, but then why not just use Mode as a condition? What's the purpose of the virtual switch?
You still need the beta. The "helper" just sends the commands to keep the Google devices alive. Exactly what the RM rule does. I experimented with the RM rule and the helper app to see if either way was better. I could find no discernible difference between the two methods.
I've been running the Chromecast Helper app for about a week now, and it doesn't always seem to do the trick. Sometimes I will come home, sit down on the couch, turn on the TV, cast YouTube or Netflix to my Chromecast, and the lights do not dim as they should . When I go to the device page for the Chromecast, it says the source is None. Initialize and refresh, and it'll show the correct source and lights will dim. Anyone else run into issues with the app not working?