Automation not triggering from kodi

I’ve been trying to set up an automation to dim the lights when I start watching a movie on my kodi media player, but I cannot seem to get it working. The automation can be triggered manually, but it does not detect triggers from kodi. I followed the examples on the home assistant web page and also examples from others that have shared their configuration, but nothing seems to be working.
This is the configuration I currently have

  - alias: "Media player paused/stopped"
    trigger:
      - platform: state
        entity_id: media_player.kodi
        from: 'playing'
        to: 'idle'
    condition:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
    action:
        service: scene.turn_on
        entity_id: scene.normal

  - alias: "Media player playing"
    trigger:
      - platform: state
        entity_id: media_player.kodi
        to: 'playing'
        from: 'idle'
    condition:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
    action:
        service: scene.turn_on
        entity_id: scene.movie

This is what I used when using yaml for automations

## Dim lights whilst playing media of an evening
  - alias: 'Dim Lights for Lounge Media'
    trigger:
    - platform: state
      entity_id: media_player.media_4k_kodi
      from: idle
      to: playing
    condition:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
    - condition: time
      after: '19:00'
      before: '04:00'      
    action:
    - service: scene.turn_on
      data:
        entity_id: scene.livingroom_dim
        
## Turn up lights after media finishes of an evening
  - alias: 'Light Normal After Media'
    trigger:
    - platform: state
      entity_id: media_player.media_4k_kodi
      to: idle
    condition:
    - condition: state
      entity_id: light.lounge_bulb
      state: 'on'    
    action:
    - service: scene.turn_on
      data:
        entity_id: scene.livingroom_normal
        
## Dim lights when resuming playing media from pause of an evening
  - alias: 'Dim Lights for Lounge Media - Paused'
    trigger:
    - platform: state
      entity_id: media_player.media_4k_kodi
      from: paused
      to: playing
    condition:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
    - condition: time
      after: '19:00'
      before: '04:00'      
    action:
    - service: scene.turn_on
      data:
        entity_id: scene.livingroom_dim
        
## Turn up lights after media paused of an evening
  - alias: 'Light Normal Media Paused'
    trigger:
    - platform: state
      entity_id: media_player.media_4k_kodi
      from: playing
      to: paused
    condition:
    - condition: state
      entity_id: light.lounge_bulb
      state: 'on'    
    action:
    - service: scene.turn_on
      data:
        entity_id: scene.livingroom_normal

If you look at how the action is implemented you might see your error

Thank you very much! this worked!