Automation Error Service call, Delay, then Choose

I keep getting an error in logs regarding the below automation action and I’m not sure exactly what the error is identifying.

Is it because a service call, and delay is not possible before choose conditions or is there an issue with the syntax or indents?

Automation Action

  action:
  - service: script.close_all_blinds
    delay:
      seconds: 90
  - choose:
     # If All Blinds Closed
      - conditions:
          - condition: numeric_state
            entity_id: sensor.blinds_open_count
            state: 0
        sequence:
          - service: notify.mobile_app_iphone_m
            data:
              message: All Blinds Closed
              title: ''
        # If Any Blinds NOT Closed
      - conditions:
          - condition: numeric_state
            entity_id: sensor.blinds_open_count
            above: 0
        sequence:
          - service: notify.mobile_app_iphone_m
            data:
              message: '{{sensor.list_blinds_open}}'
              title: ''

Error in Logs

Logger: homeassistant.components.automation
Source: components/automation/config.py:108
Integration: Automation (documentation, issues)
First occurred: 8:46:28 AM (6 occurrences)
Last logged: 8:49:45 AM

Automation with alias 'Close Blinds' could not be validated and has been disabled: extra keys not allowed @ data['action'][0]['service']. Got 'script.close_all_blinds'
Automation with alias 'Close Blinds' could not be validated and has been disabled: extra keys not allowed @ data['action'][2]['choose'][0]['conditions'][0]['state']. Got 0

Show the automation in full, please.

I’m not sure why you are getting the first error but the second error is because “state:” is not valid for a numeric_state. Only “above:” or “below:”.

if you want it to check for a state equal to 0 then just use a state condition instead of a numeric_state condition.

And that might fix the first one since the syntax is invalid for the condition.

try fixing that and see what you get.

- condition: state
  entity_id: sensor.blinds_open_count
  state: '0'

EDIT: I just saw the other error.

you need to add a - in front of “delay:”

- service: script.close_all_blinds
- delay:
    seconds: 90
- choose:
.
.
1 Like

I’ve made the changes you suggested and there is no error in the logs, so hopefully it runs as expected and no logged error at runtime.

Been working with HA for a while now and I still can’t get to grips with when single quote marks are needed and when they aren’t. So it appears that they are required if it’s state but not if it’s numeric_state?

This is my edited automation in full now:

- alias: Close Blinds
  id: close_blinds
  mode: single
  trigger:
  - platform: numeric_state
    entity_id: sensor.bedroom_light_sensor_illuminance
    below: 26
    for:
      minutes: 2
  - platform: sun
    event: sunset
    offset: '-00:10:00'
  condition:
  - condition: state
    entity_id: sun.sun
    attribute: rising
    state: false
  action:
  - service: script.close_all_blinds
  - delay:
      seconds: 90
  - choose:
     # If All Blinds Closed
      - conditions:
          - condition: state
            entity_id: sensor.blinds_open_count
            state: '0'
        sequence:
          - service: notify.mobile_app_iphone_m
            data:
              message: All Blinds Closed
              title: ''
        # If Any Blinds NOT Closed
      - conditions:
          - condition: numeric_state
            entity_id: sensor.blinds_open_count
            above: 0
        sequence:
          - service: notify.mobile_app_iphone_m
            data:
              message: '{{sensor.list_blinds_open}}'
              title: '' 

You only need the quotes around any value that could be misinterpreted to not be a string. Ex. numbers or boolean values (‘on’ or ‘off’).

the numeric_state internally converts the state to a number if it can be converted so you don’t need the quotes.

1 Like

I just tested running the actions in Dev Tools and I get the below error now:

Logger: homeassistant.components.automation.close_blinds
Source: components/automation/__init__.py:690
Integration: Automation (documentation, issues)
First occurred: 12:37:49 PM (1 occurrences)
Last logged: 12:37:49 PM

Error while executing automation automation.close_blinds: extra keys not allowed @ data['value']

I’m not seeing anything wrong with that automation and I definitely don’t see any key called “value”.

So I’m not sure what to try next.

Maybe it’s some syntax error in another unrelated automation that is off enough that it thinks the mentioned automation has the “value” key?

1 Like

After a few hours of going back and to between the scripts and the automation, trying different things, I found it was an issue with the script that was being called. I had used value for one of the blinds instead of position.

I wish the logs would identify it as a script issue rather than the automation that calls the script.

Thanks for your help as your advice fixed the actual automation.

1 Like