Hi,
I have installed hassio, with some funcional rest componente switches, and the zigbee add-on, but I’m struggling now with the first automation. (the switch are working OK, but not with automation, I tried a “sensor” as trigger, and now “time” as in following exemple:
Could you look at it and see is something is wrong…
Thanks!
I am assuming you used the UI automation editor to make the automation. Restart HA or reload automations from the Configuration > General page. Then check the states page again.
Yes, first with automation editor and restart and then doing it directly on the automation file, and restart… And I have: automation: !include automations.yaml on my configuration file…
Under states/current entities, I have a “group.all_automations” on, but all the automations on this group are from zigbee and all are on… Is this the place to look for the automation?
It is not there. And is strange that wen I try to use the automation editor it save the code to the automation file, but dos not give the option to edit the automation I just saved… is this normal?
No error in the editor, and the alteration is visible in the file, I guess HA is riding the file, because if I make code error it give me the feedback on the validation…
That sounds really unlikely… Save some really obvious error into your automations.yaml and go into the config panel->general->“check config”. See if it picks it up. Maybe your editor is showing you errors but homeassistant isn’t actually reading that file. Otherwise hass isn’t really restarting…
Also, i’d format the automation this way (at least this is what works in mine):
- id: '1536979650570'
alias: table On
trigger:
platform: time
at: '14:24:00'
action:
service: switch.turn_on
data:
entity_id: switch.table
-I made some really obvious error into automations.yaml for testing thats the result:
Error loading /config/configuration.yaml: while scanning a simple key in “/config/automations.yaml”, line 3, column 1 could not find expected ‘:’ in “/config/automations.yaml”, line 4, column 1
So you add the automation using the automation editor, and afterwards you cannot edit it or see it in the same editor? yes (and after that tried to wright the code miself)
-If you manually check your automation.yaml file, do you see the automation? yes:
/config/configuration.yaml:
- id: '1536979650570'
alias: table On
trigger:
platform: time
at: '14:24:00'
action:
service: switch.turn_on
data:
entity_id: switch.table
I have this log:
019-07-16 21:44:01 ERROR (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key “automation”. Check lines 18 and 69.
I had some code from zigbee pen with an automation section on the configuration.yaml: probably this is the problem, right?
Do I move all this code to the automation.yaml, group.yaml…respectively, or can I put it all in a zigbee.yaml ?
Thanks for you patience…
#zigbee
input_boolean:
zigbee_permit_join:
name: Allow devices to join
initial: off
icon: mdi:cellphone-wireless
timer:
zigbee_permit_join:
name: Time remaining
duration: 600 # Updated this to the number of seconds you wish
sensor:
- platform: mqtt
name: Bridge state
state_topic: "zigbee2mqtt/bridge/state"
icon: mdi:router-wireless
group:
zigbee_group:
name: Zigbee
entities:
- input_boolean.zigbee_permit_join
- timer.zigbee_permit_join
- sensor.bridge_state
automation:
- id: enable_zigbee_join
alias: Enable Zigbee joining
hide_entity: true
trigger:
platform: state
entity_id: input_boolean.zigbee_permit_join
to: 'on'
action:
- service: mqtt.publish
data:
topic: zigbee2mqtt/bridge/config/permit_join
payload: 'true'
- service: timer.start
data:
entity_id: timer.zigbee_permit_join
- id: disable_zigbee_join
alias: Disable Zigbee joining
trigger:
- entity_id: input_boolean.zigbee_permit_join
platform: state
to: 'off'
action:
- data:
payload: 'false'
topic: zigbee2mqtt/bridge/config/permit_join
service: mqtt.publish
- data:
entity_id: timer.zigbee_permit_join
service: timer.cancel
hide_entity: true
- id: disable_zigbee_join_timer
alias: Disable Zigbee joining by timer
hide_entity: true
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.zigbee_permit_join
action:
- service: mqtt.publish
data:
topic: zigbee2mqtt/bridge/config/permit_join
payload: 'false'
- service: input_boolean.turn_off
data:
entity_id: input_boolean.zigbee_permit_join
Just a small thing that gave me a problem when I tried my first automation using the automation editor:
I clicked the Save button, but found the that automation did not seem to be saving correctly. Only after a few tries did I notice that I had to scroll up to the top of the automation editing window to see that there was an error message displayed at the top that was preventing it from saving. There was no indication that the Save had or hadn’t worked otherwise.
Yes, that’s the problem. You have multiple automation: sections, so it will only load automations from the last one (which is empty)… You’ve got to find the other one and delete it.
Since you have
automation: !include automations.yaml
the first thing I’d do is to check your automations.yaml file and check to see if you put another automation: in there… If you did, you need to delete it… Otherwise check in other places in your config.yml.
PS to answer your question, you need to put this into your automation.yml and delete the automation: part if you are using !include. Leave the other stuff as it is
Problem solved!
With all the automations in the automations.yaml, everything is working.
Thanks for you patience and support!
This was a good lesson… I need to make a nice tutorial about the basis of file organisation python, indentation etc…