Trouble adding a second condition to an automation

Hi,

I have a basic “dim the lights when media is played” automation/scene. I want to add a second condition that the scene only run if the media type is a movie. However adding the second condition causes the scene not to run. Not sure what I’m doing wrong. below is both the working and non working code.

Mike

Working Automation:

### Movie Lights ###
- alias: "Media player paused/stopped"
  trigger:
    - platform: state
      entity_id: media_player.xboxone
      from: 'playing'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
      service: scene.turn_on
      entity_id: scene.familyroom_normal

- alias: "Media player playing"
  trigger:
    - platform: state
      entity_id: media_player.xboxone
      to: 'playing'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
      service: scene.turn_on
      entity_id: scene.familyroom_dim

Automation with second condition:

### Movie Lights ###
- alias: "Media player paused/stopped"
  trigger:
    - platform: state
      entity_id: media_player.xboxone
      from: 'playing'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
      - condition: template
        value_template: '{{ states.media_player.xboxone.attributes.media_content_type == movie }}'
  action:
      service: scene.turn_on
      entity_id: scene.familyroom_normal

- alias: "Media player playing"
  trigger:
    - platform: state
      entity_id: media_player.xboxone
      to: 'playing'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
      - condition: template
        value_template: '{{ states.media_player.xboxone.attributes.media_content_type == movie }}'
  action:
      service: scene.turn_on
      entity_id: scene.familyroom_dim

By default, all conditions are run as AND conditions, so that portion was superfluous. You should also have movie in quotes, since it’s a string.

### Movie Lights ###
- alias: "Media player paused/stopped"
  trigger:
    - platform: state
      entity_id: media_player.xboxone
      from: 'playing'
  condition:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
      - condition: template
        value_template: '{{ states.media_player.xboxone.attributes.media_content_type == "movie" }}'
  action:
      service: scene.turn_on
      entity_id: scene.familyroom_normal

That being said, you can always run your value template through the Hass template editor (the 4th icon from the left on the sidebar) to ensure that it is working as expected.

Good to know. Thanks.

::smacks forehead:: I knew that.

All working now. I also realized i don’t need the movie condition for the “paused/stopped” state since at that point technically nothing is playing. It was causing the lights to not return to normal. Also thanks for the tip on the template editor. Still learning how/when to use those dev sections.

No worries. Glad I could help.