Hi all,
just a simple question , i try to add in the mini media player card some buttons in order to change source , but i need to add a condition which state : if the av is on change the source to the one selected otherwise wait 10 sec(the av is turning on) and then change the source.
The following is working great , but i would avoid to wait always 10 sec to change source if the av is already on
The state of media_player.denon will now be on but, as you know, the physical device is not truly on and requires several seconds (10) before it’s fully operational and ready to accept commands.
What I suggest is to create an input_boolean that represents the true state of the Denon player.
input_boolean:
denon_status:
name: Denon Status
Create two automations. The first one turns on input_boolean.denon_status when media_player.denon is on for at least 10 seconds.
- alias: 'Denon player on'
trigger:
- platform: state
entity_id: media_player.denon
to: 'on'
for: '00:00:10'
action:
service: input_boolean.turn_on
entity_id: input_boolean.denon_status
The second automation simply turns off input_boolean.denon_status when media_player.denon is off
- alias: 'Denon player off'
trigger:
- platform: state
entity_id: media_player.denon
to: 'off'
action:
service: input_boolean.turn_off
entity_id: input_boolean.denon_status
Now your script can use wait_template instead of delay.