Automation Apple TV

Hi everbody,

I would like to turn on my Apple TV when a smart outlet is turned on, so that my TV automatically turns on when I tell Alexa “Alexa outlet on” for example.

My automation currently looks like this:

description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: ab559e5ff2cb67853a8f2399151908c6
    entity_id: switch.tv_socket_1
    domain: switch
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 25
      milliseconds: 0
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.apple_tv
mode: single

Somehow this does not want to work.

Does anyone have a tip?

Thanks a lot.

What doesn’t work? Is the automation being triggered? Have you tested that service call separately in the developer tools?

The automation is executed but the TV (Sony XH95) is not turned on.

How can I test this in the developer tools?

image

I am German, sorry for my bad Englisch :slight_smile:

Developer Tools > Services and then select the service you want to test.

In the developer tools it works, but the socket has to be on for a very long time until the TV reacts.

That sucks.

How long? HA should be reacting as soon as states are updated, but there’s nothing that can be done if the switch itself is taking a long time to report it’s state.

But the status of the socket is changed very quickly, at least that’s what the log says.

It might be a silly question, but you’re not just talking about the 25 second delay you’ve included, right? Because, if the socket is reporting it’s state immediately and the service call turns on the TV immediately, there’s no reason the automation shouldn’t complete in no more than a few seconds. And the trace you shared shows the automation taking 25.01 seconds, which is mostly your delay action.

I think my TV is the problem. The TV can only be switched on quickly directly with its own TV remote control. I also wanted to fix this problem with Android TV, but it doesn’t work. I thought with the Apple TV it works better.

I have solved it otherwise. I leave the TV on. By changing the state of the Apple TV to standby, I make the power outlet turn off.

When I turn on the power outlet, it turns on the Apple TV. Since the TV is still on, I don’t need a power on command.

Works fine so far.

Another question. Can I start the Apple TV with a specific app for example Plex?