HASS+ Kodi Lighting Play Pause automation - Cookbook Example Broken?

Hey guys:

I’m trying to implement the Dim Lights When Playing Media automation from here, but i think there is an error: https://home-assistant.io/cookbook/dim_lights_when_playing_media/

I have the following scene created, and it appears as an entity:

  - name: Great Room Normal
    entities:
        light.great_room_table_left:
            state: on
            transition: 2
            brightness: 175
            xy_color: [ 0.1684,0.0416 ]
        light.great_room_table_right:
            state: on
            transition: 2
            brightness: 190
            xy_color: [ 0.1684,0.0416 ]
        light.great_room_ceiling:
            state: on
            transition: 2
            brightness: 190
            xy_color: [ 0.1684,0.0416 ]
  - name: Great Room Dim
    entities:
        light.great_room_table_left:
            state: on
            transition: 2
            brightness: 75
            xy_color: [ 0.1684,0.0416 ]
        light.great_room_table_right:
            state: on
            transition: 2
            brightness: 75
            xy_color: [ 0.1684,0.0416 ]
        light.great_room_ceiling:
            state: on
            transition: 2
            brightness: 75
            xy_color: [ 0.1684,0.0416 ]

but the automation is throwing some errors:

###Dim and Turn on Great Room Lights with Movie####	  
  - alias: "Media player paused/stopped"
    trigger:
      - platform: state
        entity_id: media_player.family_room_tv
        from: 'on'
    condition:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
    action:
        service: scene.turn_on
        entity_id: scene.great_room_normal

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

If I run hass --script check_config I get the following:

  automation:
    - [OrderedDict([('alias', 'Media player paused/stopped'), ('trigger', [OrderedDict([('platform', 'state'), ('entity_id', 'media_player.family_room_tv'), ('from', 'on')])]), ('condition', [OrderedDict([('condition', 'state'), ('entity_id', 'sun.sun'), ('state', 'below_horizon')])]), ('action', OrderedDict([('service', 'scene.turn_on'), ('entity_id', 'scene.great_room_normal')]))]), OrderedDict([('alias', 'Media player playing'), ('trigger', [OrderedDict([('platform', 'state'), ('entity_id', 'media_player.family_room_tv'), ('to', 'on')])]), ('condition', [OrderedDict([('condition', 'state'), ('entity_id', 'sun.sun'), ('state', 'below_horizon')])]), ('action', OrderedDict([('service', 'scene.turn_on'), ('entity_id', 'scene.great_room_dim')]))])]

Successful config (partial)
  automation:

I’m running HASS version 0.32.1, and Kodi version 16.1 ( librelec )

Does anyone have any ideas how I can make this work? Maybe we can update the cookbook if there’s an issue?

In the linked example the first part of the automation is
from: 'playing' not from: 'on'

If you are using !includes to split up your config you need to adjust formatting to account for the way it gets pulled in and I get dictionary errors from doing it the wrong way often - I keep forgetting which witch is which. Spacing and hyphens are my usual culprits so that’s where I would start.

If you had other automations working before this perhaps compare the hyphen placement and see if you need it on - platform: state , condition: state etc

Hello @BarryHampants Thanks very much for the reply. Yes it was my formatting / spacing as I did breakout my config files. Lesson Learned ALWAYS double check formatting…

1 Like