Android TV and WLED turn on and turn off together

Hi everyone,

first of all sorry for my bad english.
I want to do an automation based on my sony android tv and a WLED led strip that I installed behind tv.
I would like to turn on led strip when tv turn on and turn off when tv turn off. In my configuration.yaml I added this line for android tv:

media_player:
    - platform: androidtv
      name: Sony TV
      host: xxx.xxx.x.xx

and into automations.yaml I added:

- alias: turn on tv
  trigger:
    platform: state
    to: playing
    entity_id: media_player.sony_tv
  action:
    service: light.turn_on
    entity_id: light.wled

This is last configuration. I tried, also, with platform: state and to: on but nothing happens.
Can someone help me?

At first: have you restarted HA or reloaded HA? IF not do that first.
Second: Why do you write the automation directly in the yaml? Using the UI editor is way easier for me.
Third: If you turn your tv off and then on again, what state does the tv have in developer tools?

  1. Yes, more than once
  2. If i turn off and on TV, pass from off state to playing.
  3. I use UI editor for automation. This is the result:
- id: '1612989587362'
 alias: Turn On TV and WLED
 description: ''
 trigger:
 - platform: state
   entity_id: media_player.sony_tv
   attribute: adb_response
   from: 'off'
   to: playing
 condition: []
 action:
 - type: turn_on
   device_id: 8f51aa5f4324e7deb2af784e051c2c57
   entity_id: light.wled
   domain: light
   brightness_pct: 80
 mode: single

but nothing happens again.

What happens, if you fire the automation manually?

Turn on only led strip.

Ok, do you have the ability to use the device trigger instead of state trigger? I dont own an android tv, so i cant check that

If I select device trigger i can’t select my android tv named as sony_tv

Have a look at the state_detection_rules mentioned in the docs. I believe with this you can make HA interpret that opening the default launcher package from nothing equals turning the device on. Getting this package name can be optained by executing this:

service: androidtv.adb_command
  data:
    entity_id: media_player.sony_tv
    command: "GET_PROPERTIES"

After you turned the device on in developer tools