I am playing around for some time to do some automation. Tried to figure out why is seems so hard sometimes to make automations work.
First of all, I included group.all_automations as entity in the default_view groups in groups.yaml, but for some reason, it is not shown. (so I removed the default_view to see the automations pane)
More important: editing automations.yaml using the UI does not support all options (i.e. using the time platform does not allow to enter the minutes entity) For some reason (I think it is the linter) the automations.yaml gets reformatted when you save changes made with the UI.
I created this automation for example, very structured in the same way as all the examples and documentation on this site:
- id: automation
alias: My brilliant automation
trigger:
- at: '00:00:00'
platform: time
action:
- entity_id: switch.tkb_home_plug_switch
service: switch.turn_off
Because I added an id here, I can see it in the configuration UI and edit it. When I do so, it starts indicating that the service is empty, showing {}. I assume that this is because the editor expects the much more difficult to enter json format. If I press save, my automation is gone, because an empty data block is inserted. But, oke, letś re-entering the json and press save. Now my automations.yaml looks like:
- action:
- entity_id: switch.tkb_home_plug_switch
service: switch.turn_off
id: automation1
alias: My brilliant automation
trigger:
- at: '00:00:00'
platform: time
This seems hard to read for me and doesn correspond to the documented format.
But it can be even more strange. I defined 7 automations or actions if you like using a text editor. Each automation has an unique id, but it seems that the automations work fine if the have all the same id. Only the automations with a unique id are visible in the UI for editing.
I have defined somewhere the following automation:
- action: - entity_id: switch.fibaro_fgs222_meterkast_switch_2 service: switch.turn_on - entity_id: switch.fibaro_fgs223_buiten_switch service: switch.turn_on - entity_id: switch.fibaro_fgs222_meterkast_switch service: script.turn_on id: '2018005' alias: Buitenverlichting aan (lichtsensor) condition: - condition: time after: 06:30 before: '23:00' trigger: - entity_id: sensor.multi_sensor_2_luminance below: '100' platform: numeric_state
It works fine, but now I copy it to add another one. I alter the Id to be unique and I get no errors when loading it in home assistant. Even when I change the time from 06:30 to 09.30. However, when I change the time to 15:30, and try to reload the automations, home assistent presents me this error:
Invalid config for [automation]: extra keys not allowed @ data[‘condition’][0][‘after’]. Got None
extra keys not allowed @ data[‘condition’][0][‘before’]. Got None
not a valid value for dictionary value @ data[‘condition’][0][‘condition’]. Got None
required key not provided @ data[‘condition’][0][‘entity_id’]. Got None.
This makes it very hard to automate… It is not clear to me what goes wrong, and how to debug…
Any suggestions?