Kodi light automation issue **Pulled my HAIR**

Hi All,

I am facing a weird problem, and for the love of God I can not find what went wrong. I implemented the Kodi light automation and with some trial and error it worked. My room lights are switched off when I play a movie and vice versa. I was happy and had a good night sleep. NEXT day for god know what reason it stopped working, nothing changed I changed nothing, but lights would not turn off. No error, all settings are same. The scene works when I click on it on HA web console. All switched work manually from web console, just kodi automation stopped. I had a backup of my working yaml file as well, I replaced it as well, but kodi light automation will simple NOT work??? Below is the snippet from my yaml file …
Also an fyi Kodi was autodetected and I did not specifically added it in the yaml file. The web console shows the movie playing when kodi is playing a movie … back to config file

scene:

  • name: Bedroom normal
    entities:
    switch.bedroom_light:
    state: on

  • name: Bedroom dim
    entities:
    switch.bedroom_light:
    state: off

  • name: Fan On
    entities:
    switch.bedroom_fan:
    state: on

  • name: Fan Off
    entities:
    switch.bedroom_fan:
    state: off

automation:

  • alias: “Media player paused/stopped Lights On”
    trigger:

    • platform: state
      entity_id: media_player.kodi
      from: ‘playing’

    condition:

    • condition: state
      entity_id: sun.sun
      state: ‘below_horizon’
      action:
      service: scene.turn_on
      entity_id: scene.bedroom_normal
  • alias: “Media player playing Lights Off”
    trigger:

    • platform: state
      entity_id: media_player.kodi
      to: ‘playing’

    condition:

    • condition: state
      entity_id: sun.sun
      state: ‘below_horizon’
      action:
      service: scene.turn_on
      entity_id: scene.bedroom_dim

The above config worked as far as I know, but now it is not working,and I have done everything that I can think off. Please assist

Regards
Sammy

And just like that, now when i returned from office, it started working. And I did nothing. Weird behaviour, what makes it work??? and why is it intermitted???

and just like that again it has again stopped working …can someone please assist what is happening here. I am using kodi on nVidia SHIELD, which is on sleep mode always, and I wake it up when I need to access Kodi, can that be the reason … please need to understand what make this tik and what is breaking it …