Call Service and Automation

He Guys,

One question:

If i run these on my HA my Denon Receiver changes its input correctly:

In my automation, this doesn’t work

- alias: Fernsehen
  trigger:
    platform: state
    entity_id: input_select.fernbedinung
    to: "Fernsehen"
  action:
    - service: script.vierapoweron
    - service: media_player.turn_on
      entity_id: media_player.denon
    - service: media_player.select_source
      data:
        entity_id: media_player.denon
        source: TV Audio
    - delay: '00:00:10'
    - service: script.vierafernsehen

Anyone can guess why?

Could it be that you need a bit of time after turning on the device before it’ll accept commands?

(aside - I can’t remember… can you use delays in actions or only in scripts? Also, I’m not 100% sure you’ve got the format for delay correct. )

He @ih8gates thanks for Input. I’ll give it a try after my wife is finished with watching tv. Delay is working in automation and syntax should be correct. I’m using it in another automation.

BR

Got it to work. Have to put TV AUDIO under “”.

Here the working Code:

- alias: Fernsehen
  trigger:
    platform: state
    entity_id: input_select.fernbedinung
    to: "Fernsehen"
  action:
    - service: script.vierapoweron
    - service: media_player.turn_on
      entity_id: media_player.denon
    - service: media_player.select_source
      data:
        entity_id: media_player.denon
        source: "TV AUDIO"
    - delay: '00:00:10'
    - service: script.vierafernsehen
1 Like

That likely raised an error in your home_assistant.log. Always check there first when things act up.

@outrun Thanks so much for this piece of code - I now have a script running to get everything setup for when I go out to swim in the backyard - turns on zone 2 and sets source appropriately. Much appreciated!!