Automation to change state of media_player when same media_player stays iddle for 5 minutes

Hello there,

How can I change the state of my “media_player.chromecast_beta” from idle to off as an action in an automation.

I find it easy to use a state change as a trigger to do things, but there’s no entity state change as an action on the automation frontend page.

I guess I have to call a service or an event…? If so, how can I have an action to change the state of an entity? What goes on the event data field?
Or… will I have to do this using YAML?

Thanks in advance,
Airton

The media player services are listed here Media Player - Home Assistant

1 Like

That worked. Thanks!
But what if there was no service to turn off the media player?
I ask for cases when I want to change a state of any entity…
Cheers

Some entities can be changed through service calls, like for switches, lights, climate and so on.
These entities are user-controlable.

Others can’t be changed, like sensors, which are event-controlled.

Both can have their state set in developer tools, but the event-controlled entities will be reset at next update and some of the user-controlled ones will too.

This is nothing, you really can do. :slight_smile: It is easy to think, it would be a solution to change a reported state, but in reality this is just “messing” around.

Integrations report states for a reason, they have program code behind that logic. So if your state isn’t accurate, you need to get to the problem itself, not trying to change the sympthoms (in this case states).

And as already said, it wouldn’t change anything for a longer time. Normally the integration should change the state back to idle, as this is the reported state. If the default polling is in place, you won’t have much from “your” state change, as it should be reset to the original, reported state in 30 seconds (that normally is the polling interval).

If you really want to turn_off your media_player, there is a service for that, but that isn’t “only” a state change, you will actively call the integration to change the real state on the device.

If you just want to show another state for a device, you have several other possibilities, one of them being to use a template sensor. But still, that has nothing to do with an actual state change! :slight_smile:

I’d advise to first check why the actually reported state isn’t the one you expect. If it’s a chromecast, you need to get the correct states reported by the integration, in this case I assume android_tv.