I’m trying to find a definitive way of getting a list of all found Chromecast Audio devices. The only sort-of unique information I’ve been able to find in the states is the media_player.attributes.supported_features property that is 21437 for Chromecast devices. This doesn’t seem like a very safe approach though. It would be better if I could enumerate something that listed all the entities for platform “cast” but I can’t figure out how to do that.
Here is what I’m using now as an example to list all my Chromecasts:
{% for state in states.media_player -%}
{%- if state.attributes.supported_features == 21437 %}
{{ state.entity_id }}{% endif -%}
{%- endfor %}
So in practice, you could get another media player that has the same value. As for getting all cast devices, the only other option you have is friendly_name because the only options available when media_players are off is friendly_name and supported_features.
You could always create a cast group, then just iterate through the group.
{% for entity_id in states.group.castgroup.attributes.entity_id %}
{{ states(entity_id) }}
{% endfor %}
Thanks, you’re basically confirming that there is not a good way to do what I want from the information exposed to templates. I do understand the bitmask and why it is a bad identifier.
Thank you for the suggestion of creating a group, I hadn’t thought of that.
Too bad the platform isn’t exposed as an attribute. (e.g., ‘onkyo’, ‘cast’, etc.)
Eventually I’ll probably end up writing a custom component for a Chromecast Radio Tuner instead of adding a pile of hard-coded YAML.