Apple TV (4th. gen) don´t turn off using media_player.turn_off

… or it does have status off after the automation has run.


The device is still on, showing a freezed image on the TV set like it´s been paused.
I was expecting Apple TV to be turned off, completely.
BTW: The Apple TV is the only input for my TV. All TV channels are streamed though the ATV.

This is what I want:

  1. Recognize when Apple TV is playing between 08:00 - 18:00 week days.
  2. Notify (my kids) that this is not allowed (via tts.google_say)
  3. Set the volume on SONOS Beam (mounted below the TV set)
  4. Play the tts.google.say message stating “Watcing TV is not allowed now”
  5. Turn off TV set - this is normally triggered when hybernating the Apple TV from the remote.

Here is the entire automation:

- alias: 'Not allowed to watch TV now'
  trigger:
    platform: state
    entity_id: media_player.atv_stua_1_etg
    to: 'playing'
  condition:  
    condition: and
    conditions:
    - condition: time
      after: '08:00:00'
      before: '18:00:00'
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
    - condition: template
      value_template: "{{ states.media_player.atv_stua_1_etg.state == 'playing' }}"
  action:
    - service: media_player.turn_on
      entity_id: media_player.atv_stua_1_etg
    - service: media_player.volume_set
      data:
        entity_id: media_player.sonos_beam_stue_1etg
        volume_level: 0.4
    - service: tts.google_say
      entity_id: media_player.sonos_beam_stue_1etg
      data_template:
        message: 'Det er ikke lov å se på TV nå.'
        cache: false
    - service: media_player.turn_off
      entity_id: media_player.atv_stua_1_etg

I had an apple TV and I recall it never turning off without unplugging it. It always went into a screensavor type mode. My apple TV is Old and now in a box somewhere.

1 Like

Thanks for the reply, mate!
The Apple TV 4th gen is supposed to hibernate form when telling it so from the Apple Remote…
Unfortunately that don’t happened when doing the media_player.turn_off

It is not possible to physically turn off the device via network (no known solution at least). Most people do hacks by navigating with the remote to the shut it off. When it’s “off” it just doesn’t communicate with the device, in order to avoid it starting other equipment due to CEC.

yeah, I just looked at the API and the supported remote commands do not list a hybernate. You can get the github page but it looks like it’s limited.

OK.
So what is your suggestion here?
I´ve also run into the problem that the ATV turns on when Hassio reboots, som I put it into start_off: true to avoid that. but the, its not reachable for scripts in Hassio (due to state:off)

It would be cool to force the ATV into hibernation IF the kids try to watch TV before 18:00.

I personally moved away from it because of the limitations. For some reason, apple doesn’t like automation. Especially open source and working with others.