For a project I need to know if a ChromeCast is currently used, or idle. openHAB can figure that out.
I’m not an experienced programmer, so can I ask why this is all required? I’m just using the Idling channel to do the same thing (as far as I can tell).
I have a rule that triggers when the Idling channel switches ON, waits five minutes, checks that it’s still idling, and then turns off devices. Another rule detects when Idling turns OFF (meaning that something is casting), and turns on the attached AV device.
This works equally well for my Chromecasts and my Chromecast Audio, and it’s pretty quick. When I start casting, the attached AV device turns on almost instantly.
That goes together with enabling/disabling the display when a video ChromeCast is used:
Occasionally I see that not all Items are updated instantly, especially when the ChromeCast was disconnected shortly before. Hence that’s why I’m monitoring all three Items - more reliable this way. I had used the “Idling” Item alone before, but that caused a couple seconds delay a few times - up to the point where I thought the rule is not triggered at all.
When I use more than one Item I need to see that the different states of the Items do not mix, that’s where the timer is used. And Java doesn’t like it if different threads work on the same timer (one thread is checking it while the other is setting it, and then the first thread is also setting it because it was still null before). That’s where the locking ensures that the threads work one after the other.
I also see that every ChromeCasts get disconnected fairly often, couple times per hour:
2020-07-05 02:30:19.279 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - Error while reading, caused by java.net.SocketException: Connection reset 2020-07-05 02:30:19.282 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - <-- null payload in message
Then it takes a couple seconds until the CC reconnects, or maybe not. If the CC stays offline for longer than a minute, openHAB sends me a message, and I have to disconnect and reconnect the device.
Summary: it’s all about making this more reliable. It did not work well when just the “Idling” Item was used.
Gotcha. I haven’t had the same troubles with my Chromecasts and the Idling channel.
Yeah, would love this to be more reliable
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.