Automation to dim lights when playing a specific content type in Kodi

Hi there,
I’d like to set my lights to dim when playing a specific media type in Kodi. I’ve tried to modify the example dim lights automation, but am not winning.
The dim lights automation works well, but becomes a little annoying when Kodi plays the next song. So I’d like it to only apply to videos.

Can one fetch the attribute state of media_content_type in the trigger rather than the condition, if so, how?
What am I doing wrong in my automation below?
Here is my current automation script:

Automation

Kodi - Light - Sun Integration

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

    • platform: state
      entity_id: media_player.kodi
      from: ‘playing’
      condition:
      condition: and
      conditions:
      • condition: template
        value_template: ‘{{ states.media_player.kodi.attributes.media_content_type = “video” }}’
      • condition: state
        entity_id: sun.sun
        state: ‘below_horizon’
        action:
        service: scene.turn_on
        entity_id: scene.livingroom_normal
  • alias: “Media player playing”
    trigger:

    • platform: state
      entity_id: media_player.kodi
      to: ‘playing’
      condition:
      condition: and
      conditions:
      • condition: template
        value_template: ‘{{ states.media_player.kodi.attributes.media_content_type = “video” }}’
      • condition: state
        entity_id: sun.sun
        state: ‘below_horizon’
        action:
        service: scene.turn_on
        entity_id: scene.livingroom_dim

This may not be the good answer, but yaml is picky about identation. Your "condition:"should start inline with “trigger:”, and the “condition: and” identeed two spaces to the right.
I think this error should appear on your dev-info page (http://ha.ip.address:8123/dev-info)

cheers
tom

You config should work, but as towme says, please check your indentation.

I’m using this and it works great:

alias: "Movie time on"
trigger:
  platform: state
  entity_id: media_player.mediacenter
  to: 'playing'
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
    - condition: template
      value_template: '{{ states.media_player.mediacenter.attributes.media_content_type == "video" }}'
    - condition: state
      entity_id: group.livingroomlights
      state: "on"
    - condition: state
      entity_id: input_boolean.theater
      state: 'on'
action:
  service: scene.turn_on
  entity_id: scene.woonkamer_gedimd

Hi Guys,

Thanks alot for the help. I actually just pasted my config and the spacing became messed up. What sorted the automation out was the extra ‘=’ that needed to be added before “video”
Brilliant! Now for a drink…

Have an awesome weekend!