Tv Idle automation

Hi there, i am quite new on HA, i am trying to create an automation with my sony tv whenever becomes idle or stopped playing for few minutes should then change to HDMI 1 input. I did try to create the automation setting the state of the tv as idle as trigger and call adb android tv command HDMI1 as action but doesn’t start, the adb command works on his own.

Please share the YAML for what you tried. Make sure to format it for the forum correctly, see:

alias: "Tv Idle "
description: ""
  - platform: state
      - media_player.living_room_tv_2
    from: playing
    to: idle
      hours: 0
      minutes: 0
      seconds: 30
    id: Tv Idle
  - condition: trigger
      - Tv Idle
  - service: androidtv.adb_command
      entity_id: media_player.sony_tv
      command: HDMI1
mode: single`Preformatted text`

Format it properly.


How to do that ? i don’t understand the screenshot

Click the link you were provided.

You click on </>, this appears

type or paste code here

Then you paste your code there.

Is it ok now?

Can you check if the automation is active? Go to Settings → automations and check if the icon is greyed out or red. If it is then your code is not properly formated.

Then check if was triggered and take a look at traces.

Also remember to reload the automations when you edit them.

I think you need to remove the condition

Removed but still doesn’t work, automation is active created with gui so how the code can be wrong,?

How to reload the automation?

Developer tools → YAML → Automations

Done nothing happens with any tv state

I dont know, try removing the from: playing , and leave the to: idle

  - platform: state
    entity_id: media_player.living_room_tv_2
    to: 'idle'
      seconds: 5

And just for the test, put five seconds.

Are you sure the state of media_player.living_room_tv_2 is showing as idle?
Check it in developer tools, states

I do it the other way around. There is more than one state a media player can change to (off, idle, paused) when not playing. This is the trigger I use to change out of my movie scene:

    platform: state
    entity_id: media_player.lounge_osmc_kodi
    from: 'playing'
      seconds: 1

Thanks, your trick works better, i changed the Tv device and now seams to work the automation. Luca.