I have a Sony Android TV with built-in Chromecast. The Chromecast integration provides lot of information about which app is playing content on the TV. I see something like this in the events capture:
{
"event_type": "state_changed",
"data": {
"entity_id": "media_player.bedroom_tv",
"old_state": {
"entity_id": "media_player.bedroom_tv",
"state": "playing",
"attributes": {
"volume_level": 0,
"is_volume_muted": false,
"media_content_id": "",
"media_duration": 1361.402,
"media_position": 119.415,
"media_position_updated_at": "2021-12-11T09:43:41.970265+00:00",
"media_title": "Myrtle Beach Vacation 1",
"app_id": "AndroidNativeApp",
"app_name": "Plex",
"entity_picture_local": null,
"friendly_name": "Master Bedroom TV",
"supported_features": 152463
}
I want to create different actions in automation depending on the state and app_name. So, if state is playing
and app_name is Plex
, then do some action. If state is playing
but app_name is Netflix
then do something else. I can use the state in condition clause of automation and set it to playing
but how do I use the app_name attribute?
condition: state
entity_id: media_player.bedroom_tv
state: playing
How do I add the app_name attribute?
Thanks,
Arun