Home Assistant Community

Automation yaml works in YAMLlint but error "extra keys not allowed @ data['condition']"

automation
Tags: #<Tag:0x00007f3754468100>
#1

Hallo Cogniscenti!
I have a small bruise on my forehead from trying to work out what I am doing wrong here. I have run the whole of this automation.yaml through YAMLlint and I get the green OK. But when I reload HA I get the following error message:

 Apr 12 23:48:25 hassbian2 hass[1067]: 2019-04-12 23:48:25 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: extra keys not allowed @ data['condition'][0]['conditions'][0]['conditions'][1]['option']. Got None
Apr 12 23:48:25 hassbian2 hass[1067]: not a valid value for dictionary value @ data['condition'][0]['conditions'][0]['conditions'][1]['condition']. Got None. (See /home/homeassistant/.homeassistant/automations.yaml, line 14). Please check the docs at https://home-assistant.io/component/automation/

I have an input_select for each day of the week. The drop down list for each day consists of “standard”, “short” and “long”:

pool_pump_mon:
  name: Pool pump Mon
  options:
    - Standard
    - Short
    - Long
  initial: Standard
  icon: mdi:calendar-today

Here is the automation.yaml - any suggestions on what I am doing wrong, or a better way to do it would be much appreciated:

#Pool pump turns off at the same time every day - independent of input_select
- alias: "Pool pump timer off"
  trigger:
    platform: time
    at: '19:00:00'
  action:
    - service: switch.turn_off
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned off'

- alias: Set Pool Pump Short Duration
  trigger:
    platform: time
    at: '18:00:00'
  condition:
    condition: or
    conditions: 
      - condition: and
        conditions:
          - condition: time
            weekday: mon
          - condition: state
            entity_id: input_boolean.pool_pump_mon
            option: 'short'
      - condition: and
        conditions:
          - condition: time
            weekday: tue
          - condition: state
            entity_id: input_boolean.pool_pump_tue
            option: 'short'
      - condition: and
        conditions:
          - condition: time
            weekday: wed
          - condition: state
            entity_id: input_boolean.pool_pump_wed
            option: 'short'
      - condition: and
        conditions:
          - condition: time
            weekday: thu
          - condition: state
            entity_id: input_boolean.pool_pump_thu
            option: 'short'
      - condition: and
        conditions:
          - condition: time
            weekday: fri
          - condition: state
            entity_id: input_boolean.pool_pump_fri
            option: 'short'
      - condition: and
        conditions:
          - condition: time
            weekday: sat
          - condition: state
            entity_id: input_boolean.pool_pump_sat
            option: 'short'
      - condition: and
        conditions:
          - condition: time
            weekday: sun
          - condition: state
            entity_id: input_boolean.pool_pump_sun
            option: 'short'
  action:
    - service: switch.turn_on
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned on - short pump day'

- alias: Set Pool Pump Long Duration
  trigger:
    platform: time
    at: '12:00:00'
  condition:
    condition: or
    conditions: 
      - condition: and
        conditions:
          - condition: time
            weekday: mon
          - condition: state
            entity_id: input_boolean.pool_pump_mon
            option: 'long'
      - condition: and
        conditions:
          - condition: time
            weekday: tue
          - condition: state
            entity_id: input_boolean.pool_pump_tue
            option: 'long'
      - condition: and
        conditions:
          - condition: time
            weekday: wed
          - condition: state
            entity_id: input_boolean.pool_pump_wed
            option: 'long'
      - condition: and
        conditions:
          - condition: time
            weekday: thu
          - condition: state
            entity_id: input_boolean.pool_pump_thu
            option: 'long'
      - condition: and
        conditions:
          - condition: time
            weekday: fri
          - condition: state
            entity_id: input_boolean.pool_pump_fri
            option: 'long'
      - condition: and
        conditions:
          - condition: time
            weekday: sat
          - condition: state
            entity_id: input_boolean.pool_pump_sat
            option: 'long'
      - condition: and
        conditions:
          - condition: time
            weekday: sun
          - condition: state
            entity_id: input_boolean.pool_pump_sun
            option: 'long'
  action:
    - service: switch.turn_on
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned on - long pump day'      
  
- alias: Set Pool Pump Standard Duration
  trigger:
    platform: time
    at: '14:30:00'
  condition:
    condition: or
    conditions: 
      - condition: and
        conditions:
          - condition: time
            weekday: mon
          - condition: state
            entity_id: input_boolean.pool_pump_mon
            option: 'standard'
      - condition: and
        conditions:
          - condition: time
            weekday: tue
          - condition: state
            entity_id: input_boolean.pool_pump_tue
            option: 'standard'
      - condition: and
        conditions:
          - condition: time
            weekday: wed
          - condition: state
            entity_id: input_boolean.pool_pump_wed
            option: 'standard'
      - condition: and
        conditions:
          - condition: time
            weekday: thu
          - condition: state
            entity_id: input_boolean.pool_pump_thu
            option: 'standard'
      - condition: and
        conditions:
          - condition: time
            weekday: fri
          - condition: state
            entity_id: input_boolean.pool_pump_fri
            option: 'standard'
      - condition: and
        conditions:
          - condition: time
            weekday: sat
          - condition: state
            entity_id: input_boolean.pool_pump_sat
            option: 'standard'
      - condition: and
        conditions:
          - condition: time
            weekday: sun
          - condition: state
            entity_id: input_boolean.pool_pump_sun
            option: 'standard'
  action:
    - service: switch.turn_on
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned on - standard pump day'
0 Likes

#2

Your entity_ids are entered as “input_boolean” instead of “input_select”.

1 Like

#3

According to the documentation for State Condition it uses entity_id and state

- condition: state
  entity_id:
  state:

All of your State Conditions use option.

2 Likes

#4

And if I’m deciphering correctly, it also looks like your time conditions are serving no purpose since every day of the week is listed…?

0 Likes

#5

If you use a template condition, you can substantially reduce the size of each automation.

Here’s the ‘Short Duration’ automation with a template condition.

  • The first line of value_template gets today’s abbreviated name (assuming your locale uses the English language: mon, tue, wed, thu, fri, sat, or sun).
  • The second line appends today’s name to input_select.pool_pump_ to create an entity_id (for example: input_select.pool_pump_fri). Then it checks if the state of that entity_id is equal to ‘short’.
- alias: "Set Pool Pump Short Duration"
  trigger:
    platform: time
    at: '18:00:00'
  condition:
    condition: template
    value_template: >-
      {% set today = now().strftime('%a')|lower %}
      {{ is_state('input_select.pool_pump_'~today, 'short') }}
  action:
    - service: switch.turn_on
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned on - short pump day'

The other two automations use the same template as the one above except they check for ‘long’ and ‘standard’ as opposed to ‘short’.

Set Pool Pump Long Duration
- alias: "Set Pool Pump Long Duration"
  trigger:
    platform: time
    at: '12:00:00'
  condition:
    condition: template
    value_template: >-
      {% set today = now().strftime('%a')|lower %}
      {{ is_state('input_select.pool_pump_'~today, 'long') }}
  action:
    - service: switch.turn_on
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned on - long pump day'      
Set Pool Pump Standard Duration
- alias: "Set Pool Pump Standard Duration"
  trigger:
    platform: time
    at: '14:30:00'
  condition:
    condition: template
    value_template: >-
      {% set today = now().strftime('%a')|lower %}
      {{ is_state('input_select.pool_pump_'~today, 'standard') }}
  action:
    - service: switch.turn_on
      data: 
        entity_id: switch.fibaro_system_fgs213_switch_switch_2
    - service: notify.paul_dev_email
      data:
        title: 'Bownham House Notification'
        message: 'Pool pump turned on - standard pump day'
2 Likes

#6

Good spot, thanks jparthum, my initial automation used input_boolean and then I started getting ambitious!

I was wanting to have the automation check each day of the week and the setting of the input_select for that day of the week.

Thanks 123 for picking that up. I find the instructions in the HA pages can be ambiguous at times.
AND MANY THANKS for the template, this looks very neat (and gives another reason why I should learn to use Python). I’ve been away so not had a chance to see if it works. I will let you know!

1 Like

#7

Update on the automation with the template : Fantastic! I have trialled it on a light (I try to avoid playing with the on/off switch on the 1.4kW pump!) and it is working as intended. I was thrown for a while until I realised that the case of Short /Long /Standard made a difference.
If I wanted to have the drop down list with inicaps would I have the template as
{{ is_state(‘input_select.pool_pump_’~today, ‘short’ | lower) }}?
Thanks very much for your help.

0 Likes