Is it possible to subscribe to the "mediaSource" attribute from the ChromeCast Intergration in a custom app? I cannot find out when capability I should be using to do this.
I currently am polling it for a change, but would like to tidy that part of the code up.
You can subscribe to any attribute for a device once you get a reference to it--it doesn't matter what capability you use to select it. If this attribute is called "mediaSource," that's not part of any capability (i.e., a custom attribute), so knowing that is all the more important.
You can select via any capability the device supports, maybe MediaPlayer? (I don't have one and can't check; there are likely several.) If you only want a specific device by driver, you can also select using device.driverName (spaces removed) instead of capability.capabilityName.
Appears to be a custom attribute that this app uses (it is a native Hubitat app). I can create triggers in RM based on it changing, so I made the assumption that it was someone one could subscribe to, but that might have been a poor assumption?
From what I tested, only non-custom attributes can be part of the subscription model, is that correct?
While Robert would be more of a authoritative voice on this than me, let alone the HE dev's...
It would seem strange to me that you could not subscribe to other known attribute changes from defined capabilities.... That's without dipping my toes into this space in terms of app development.
Oh you can, it's just it seems that this app seems to be the "media transport" and "speech synthesis" capabilities. None of the attributes from those tell me if it's playing though.
When you cast media to Chromecast, it doesn't trigger the play attribute, the only thing that changes is this custom attribute of "mediaSource".
I chose to not wrigh in earlier in the conversation... but I did find the mediaSource somewhat unreliable for what I tried to use it for (displaying the currently playing media on a dashboard). I firget exactly how it was not accurate, but I know I ended up choosing to not display the media source on my dashboard.
That said.... I haven't look at it recently and things could have changed...
I have found better results, I must say, when using Node RED's integration with Chromecast, or it may be Home Assistant...
No, you can subscribe to any attribute. If this isn't working, what does your app's "App Status" page, specifically the event subscriptions, look like after the call to subscribe()?
Issue I found in the past is you need to periodically do a "refresh" to the Chromecast devices, or it goes stale. The newer Chromecast Integration app as a polling feature to take care of this.