When I test the IF in the template development tool the result is OK.
If I try it in in my configuration and restart Home Assistant, it does not start.
the log:
Is there another way to check if a state is empty?
Oh OK,
I try it another way. With my template sensor.sonos_status_kue I want to check the state of media_player.kuche. The problem is, that the media_player.kuche is not available at this moment.
It is a Sonos speaker without energy, the media_player.kuche appears after it get’s energy. Then the states.media_player.kuche.state turns to “paused”.
But I want: when there is no media_player.kuche (the speaker is without energy) then state.sensor.sonos_status_kue should be “OFF” else (if the media_player.kuche is available) the state of the media_player.kuche
This is because the state is not initialized yet.
You can test it this way:
'{% if states.media_player.kuche %}...
This will be “false” if the object is not initialized yet (i.e. “None”) and “true” otherwise.
You can add the if condition that checks for the on/off state below that.