[SOLVED] Newbie Help With Some [for] and [entity] errors

I’m on day 3 of my Home Assistant journey and I feel like I’m making progress, but I’m getting some errors that are really confusing me.

I’ve made some basic automations to control my speakers and lights in my front room:

  - alias: 'Front room lights off when no motion and kodi spmc idle for 20 minutes'
    trigger:
        platform: mqtt
        topic: smartthings/Motion - Front Room Window/motion, smartthings/Motion - Front Room Top/motion
        payload: 'inactive'
        for:
            minutes: 20
    condition:
        condition: state
        entity_id: media_player.kodi_front_room, media_player.spmc_front_room
        state: 'idle'
        for:
            hours: 0
            minutes: 20
            seconds: 0
    action:
        service: light.turn_off
        entity_id: group.front_room_lights

#     AUTOMATION - Front Room Subwoofer   #
  - alias: 'Kodi playing turn on subwoofer'
    trigger:
        platform: state
        entity: media_player.kodi_front_room, media_player.spmc_front_room
        to: 'playing'
        from: 'idle'
    action:
        service: homeassistant.turn_on
        entity_id: switch.subwoofer

  - alias: 'Kodi not playing turn off subwoofer'
    trigger:
        platform: state
        entity: media_player.kodi_front_room, media_player.spmc_front_room
        to: 'idle'
        from: 'playing'
    action:
        service: homeassistant.turn_off
        entity_id: switch.subwoofer

These are throwing up these errors, but the line references don’t match my configuration.yaml:

2017-09-14 15:14:02 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->trigger->0->for. (See /config/configuration.yaml, line 564). Please check the docs at https://home-assistant.io/components/automation/
2017-09-14 15:14:02 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [entity] is an invalid option for [automation]. Check: automation->trigger->0->entity. (See /config/configuration.yaml, line 564). Please check the docs at https://home-assistant.io/components/automation/
2017-09-14 15:14:02 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [entity] is an invalid option for [automation]. Check: automation->trigger->0->entity. (See /config/configuration.yaml, line 564). Please check the docs at https://home-assistant.io/components/automation/
2017-09-14 15:14:02 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->trigger->0->for. (See /config/configuration.yaml, line 564). Please check the docs at https://home-assistant.io/components/automation/

Can someone tell me what I’m doing wrong please.

Also, how do I combine the default lines:

group: !include groups.yaml
automation: !include automations.yaml

with the groups and automations I’ve created to remove two more errors e.g.

group: !include groups.yaml

    Central Heating:
        name: Central Heating
        entities:
            - climate.hive_heating

Or,

group:

!include groups.yaml
Central Heating:
            name: Central Heating
            entities:
                - climate.hive_heating

Thanks in advance

You need to EITHER split up your configuration by using the includes OR NOT split up you configuration.
You can’t do both.

In other words, once you have the line

!include groups.yaml

ALL your group configuration has to go into the file groups.yaml.

I suspect once you get that straightened out, your other errors will either go away, or become much more clear.

Read more about it here:

Thanks for clearing that up. I’ve removed for now as I don’t mind collapsing rows.

I’ve worked out why most of my automations don’t work - using the mqtt payloads was cuasing problems, and using the entity_ids solved almost all the problems. There’s only one of my automations that’s still not working and I think that’s because it involves kodi.

Here’s the error I’m getting:

2017-09-14 20:12:53 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID media_player.kodi_front_room, media_player.spmc_front_room is an invalid entity id for dictionary value @ data['condition'][0]['conditions'][0]['entity_id']. Got None
extra keys not allowed @ data['condition'][0]['conditions'][0]['for']. Got None
extra keys not allowed @ data['condition'][0]['conditions'][0]['state']. Got None
not a valid value for dictionary value @ data['condition'][0]['conditions'][0]['condition']. Got None. (See /config/configuration.yaml, line 558). Please check the docs at https://home-assistant.io/components/automation/

and here’s the automation:

  - alias: 'Front room lights off when no motion and kodi spmc idle for 20 minutes'
    trigger:
        platform: state
        entity_id: binary_sensor.motion_front_top, binary_sensor.motion_front_window
        to: 'off'
    condition: 
        condition: and
        conditions:
          - condition: state
            entity_id: media_player.kodi_front_room, media_player.spmc_front_room
            state: idle
            for:
                minutes: 20
          - condition: state
            entity_id: binary_sensor.motion_front_top, binary_sensor.motion_front_window
            to: off
            for:
                minutes: 20
    action:
        service: light.turn_off
        entity_id: group.front_room_lights

It works fine when I take out the ‘and’:

  • alias: ‘Front room lights off when no motion and kodi spmc idle for 25 minutes’
    trigger:
    platform: state
    entity_id: binary_sensor.motion_front_top, binary_sensor.motion_front_window
    to: ‘off’
    for:
    minutes: 25
    action:
    service: light.turn_off
    entity_id: group.front_room_lights

I’m desperate for the kodi bit as otherwise if we’re watching a movie and sitting still the lights will go off which is annoying having to wave our arms every 15-20 mins!!!

- alias: 'Front room lights off when no motion and kodi spmc idle for 20 minutes'
  trigger:
    platform: state
    entity_id: binary_sensor.motion_front_top, binary_sensor.motion_front_window
    to: 'off'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: 'media_player.kodi_front_room'
        state: 'idle'
        for:
          minutes: 20
      - condition: state
        entity_id: 'media_player.spmc_front_room'
        state: 'idle'
        for:
          minutes: 20
      - condition: state
        entity_id: 'binary_sensor.motion_front_top'
        state: 'off'
        for:
          minutes: 20
      - condition: state
        entity_id: 'binary_sensor.motion_front_window'
        state: 'off'
        for:
          minutes: 20
  action:
    service: light.turn_off
    entity_id: group.front_room_lights
1 Like

Thanks - that worked!