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
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: ''
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.