I found this thread when I was trying to figure out how to turn my Apple TV on and off from HA. A few threads said it couldn’t be done, but I could SEE that HA accurately reports when my Apple TV was in standby mode, or powered on (idle, playing, etc).
Anyways, I made the following two scrips that will only turn the ATV On if it’s off, and off when it’s on. This way it’s safe to call from scripts that turn the whole living room off. I can call “turn off Apple TV” when it’s already off and it won’t toggle it on.
alias: Living Room Apple TV On
sequence:
- if:
- "{{is_state('media_player.living_room', 'standby' )}}"
then:
- service: remote.send_command
target:
entity_id: remote.living_room_apple_tv
data:
delay_secs: 1
command:
- home
mode: single
icon: mdi:apple
alias: Living Room Apple TV Off
sequence:
- if:
- "{{ not is_state('media_player.living_room', 'standby' )}}"
then:
- service: remote.send_command
target:
entity_id: remote.living_room_apple_tv
data:
delay_secs: 1
command:
- home_hold
- select
mode: single
icon: mdi:apple