my other automations dont have the ‘-’ in front of alias so did a quick test without it but. The component didnt error to the point of total failure like before but gave this in the log.
So i put the - in and I got the same breaking error as before where the automation component wont load at all. I’m thinking that without the ‘-’ is best but there must be some other indentation issue…
I really dont understand why I am having so much trouble with this automation the above error is what I get with this code below. This is killing me! I’ve spent so many hours trying to work out what is wrong and I dont understand why it fails yet is just like my working automations (except for additional spaces in front of everything… ) I see so much variation in the use of ‘-’ in the docs and other peoples examples that I dont know where I should and shouldnt use them.
#- id: alarm_armed_away
alias: '[Alarm] Away Mode Armed'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'armed_away'
action:
- service: notify.Pushbullet
data:
message: 'Alarm Away Mode Armed'
# data:
# message: 'The house alarm has been switched on in away mode. Goodbye'
# service: notify.example_phone_tts
#- id: alarm_armed_home
alias: '[Alarm] Home Mode Armed'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'armed_home'
action:
- service: notify.Pushbullet
data:
message: 'Alarm Home Mode Armed'
# data:
# message: 'The house alarm has been switched on in home mode'
# service: notify.example_phone_tts
#- id: alarm_arming_away
# alias: '[Alarm] Away Mode Arming'
# trigger:
# - platform: state
# entity_id: alarm_control_panel.house
# to: 'pending'
# action:
# - data:
# message: 'House alarm activating, ensure all doors and windows are closed'
# service: notify.example_phone_tts
#- id: alarm_disarmed
alias: '[Alarm] Disarmed'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'disarmed'
action:
- service: notify.Pushbullet
data:
message: 'Alarm Disabled'
# target: email/[email protected]
- service: switch.turn_off
entity_id: switch.alarm_siren1_switch
# - data:
# message: 'The house alarm has been Deactivated'
# service: notify.example_phone_tts
#- id: alarm_triggered
alias: '[Alarm] Triggered'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'triggered'
action:
- service: switch.turn_on
entity_id: switch.alarm_siren1_switch
- service: notify.Pushbullet
data:
message: 'ALARM TRIGGERED!!! {{ states[states.alarm_control_panel.house.attributes.changed_by.split(".")[0]][ states.alarm_control_panel.house.attributes.changed_by.split(".")[1]].name }}'
# target: email/[email protected]
#- id: alarm_warning
alias: '[Alarm] Warning'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'warning'
action:
- service: notify.Pushbullet
data:
message: 'ALARM Warning {{ states[states.alarm_control_panel.house.attributes.changed_by.split(".")[0]][ states.alarm_control_panel.house.attributes.changed_by.split(".")[1]].name }}'
# target: email/[email protected]
# - data:
# message: 'Hello, the house alarm has been tripped. Please deactivate'
# service: notify.example_phone_tts
So I have #'d out things above as they are from the original code but I either dont need it yet or it has been for testing.
It would be awesome if someone can point out the errors for me please
If you have an automations.yaml then the alias: needs a - because they are then a list, same for trigger platforms to have multiple triggers the platforms have to have - before them, same for actions to have multiple service calls they have to have - before them, same for lists of entity_id’s they have to have - before each, so an example…
The alias’ below are a list as it is called by automation old: !include automation.yaml from the configuration.yaml file
- alias: "Send notification upon Greenhouse Door Closed"
initial_state: 'on'
trigger:
- platform: state <---- this dash is not strictly needed but I always put them in as I like everything to line up :(
entity_id: switch.rfl_greenhouse_door_closed
to: 'off'
action:
- service: switch.turn_off <----- dashes needed as this is a list of service calls
- entity_id: switch.rfl_greenhouse_door_open1 <------ dashes needed as this is a list of entity_ids
- entity_id: switch.rfl_greenhouse_door_open2
- entity_id: switch.rfl_greenhouse_door_open3
- service: switch.turn_on
entity_id: switch.rfl_greenhouse_door_closed
- service: notify.mypushbullet
data:
message: 'Greenhouse Door Closed'
- alias: MQTT Sign Plant Data Update
initial_state: 'off'
trigger:
- platform: numeric_state <----- dashes needed as this is a list of triggers
- entity_id: sensor.miflora_bird_of_paradise_moisture
- entity_id: sensor.miflora_trailing_plant_bathroom_moisture,
- entity_id: sensor.miflora_volcano_fern_moisture,
- entity_id: sensor.miflora_flowering_fern_moisture
below: 15
- platform: numeric_state
entity_id: sensor.miflora_bird_of_paradise_battery, sensor.miflora_trailing_plant_bathroom_battery, sensor.miflora_volcano_fern_battery, sensor.miflora_flowering_fern_battery <- no dash needed here as they are on the same line ;)
below: 5
above: 1
- platform: numeric_state
entity_id: sensor.miflora_bird_of_paradise_conductivity, sensor.miflora_trailing_plant_bathroom_conductivity, sensor.miflora_volcano_fern_conductivity, sensor.miflora_flowering_fern_conductivity
below: 25
action:
- service: mqtt.publish
data_template:
topic: "cmnd/MQTTSign/PLANT"
payload_template: '{{ trigger.from_state.attributes.friendly_name }} NEEDS Attention!'
Yaml is very picky about spaces and indentation and lists I hope this helps
If your automations are in the configuration.yaml then the then the alias doesn’t need a dash but you would need to precede each automation with …
The above code a have there is in its own alarm_automation.yaml which is in a folder (all of my automations have their own files in this folder) called by an include from the config. I’ll have another try using your tips, thanks
whenever I try to use the ‘-’ in front of the alias, I get the error as per just above where it talks about ‘expected a dictionary’ etc…
Hopefully @gazoscalvertos can help me. I think perhaps part of my issue is because I am using a folder with automation files in it rather than the single automation.yaml in the same folder as the config.yaml.
I split all the automations out of the alarm automation from above and now just get the single error:
2017-11-17 09:45:12 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’]. Got None. (See ?, line ?). Please check the docs at Automation - Home Assistant
From memory its an indentation issue when it states ‘required key not provided’. I couldnt see where the problem is though.
#- id: alarm_armed_away
alias: '[Alarm] Away Mode Armed'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'armed_away'
action:
- service: notify.Pushbullet
data:
message: 'Alarm Away Mode Armed'
# data:
# message: 'The house alarm has been switched on in away mode. Goodbye'
# service: notify.example_phone_tts
alarm_armed_home.yaml
#- id: alarm_armed_home
alias: '[Alarm] Home Mode Armed'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'armed_home'
action:
- service: notify.Pushbullet
data:
message: 'Alarm Home Mode Armed'
# data:
# message: 'The house alarm has been switched on in home mode'
# service: notify.example_phone_tts
alarm_arming_away.yaml (currently not in use)
#- id: alarm_arming_away
# alias: '[Alarm] Away Mode Arming'
# trigger:
# - platform: state
# entity_id: alarm_control_panel.house
# to: 'pending'
# action:
# - data:
# message: 'House alarm activating, ensure all doors and windows are closed'
# service: notify.example_phone_tts
alarm_disarmed.yaml
#- id: alarm_disarmed
alias: '[Alarm] Disarmed'
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'disarmed'
action:
- service: notify.Pushbullet
data:
message: 'Alarm Disabled'
# target: email/[email protected]
- service: switch.turn_off
entity_id: switch.alarm_siren1_switch
# - data:
# message: 'The house alarm has been Deactivated'
# service: notify.example_phone_tts
unfortunately the change to the message with the ‘>’ didnt work either. I reall;y dont feel like commenting out lines I think its time to admit defeat and give up on it. I just reverted back to the original automation.yaml that is supplied on the Git repo, changed the entity ID of the siren and commented out the notification stuff that doesnt apply to me and it works fine, which proves that the code is good until it gets split up…
A strange thing I have found with this alarm system is that the clock shows the correct time when viewing it on my local network but when i use my phone, it shows the time 1.5 hours ahead… using my phone is through the duckdns address so I tried with my laptop also via duckdns… my laptop has the correct time! I have no idea why the time shows incorrectly on my phone.
The only real difference I can see is the indentation after trigger and action.
A good way to test your automation is to add ‘group.all_automations’ to a view in your groups.yaml then add the following to your customize.yaml:
group.all_automations:
hidden: false
after your restart HA you should see all of your automations listed. You can then click each one and manually tigger the automation, hopefully identifying which one is causing the issue
I have noticed something similar too. It has to be with the way polymer (the underlying web code) retrieves its time. I may look for an alternative method to do this.