Apple TV - Using Sleep Mode

I am trying to turn my TV off when no motion is detected. Below is what I have tried.

If the TV is ON it works. Turns the TV OFF.

If the TV is OFF it does not work. it turns the TV back ON.

alias: "Make the Apple TV sleep"


- service: remote.send_command


entity_id: remote.lounge_appletv


delay_secs: 1


- home_hold

- select

- service: media_player.turn_off


entity_id: media_player.lounge_appletv

Your code is difficult to understand because it has not been formatted correctly to preserve indents. When you paste it in you should surround it with 3 backticks (```), or select it all and click </> (which does the same thing).