Hi
I have a strange issue just started recently
I have an Automation that keeps Run Action when I restart Homeassistant
This only started few weeks ago, I deleted the automation and re-wrote it but still will run on restart or reboot
Here is the yaml file
alias: Gate Opened
description: “”
triggers:
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
You can use the </> button like this… How to format your code in forum posts
OR… Here is an example of how to fix formatting from the site FAQ Page. How to help us help you - or How to ask a good question.
The automation is executed when the gate is opened.
But for some strange reason is also triggered when homeassistant is restarted, this also includes times shen updated
This only started happenjng a few week back. Was nevef the cass before
This led me to replace the gate sensor thinking it may bd problem
I also deleted and re-created the automation
I have similar automations on the windows but they dont get affected
The automations were created using thd UI not YAML
I meant to ask if the automation also triggers unwanted in case your HA restarts, and the gate is closed.
My guess is that the automation is triggered by a state change from unavailable to on (opened). If that is indeed the case, it will only trigger when the gate is open at the time of the restart, and not when the gate is closed.
- trigger: state
entity_id: binary_sensor.your_gate
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 4
Ensure you replace binary_sensor.your_gate with the actual entity_id of your gate’s Binary Sensor.
After you make the modification and save it (using the Automation Editor), restart Home Assistant and check if the automation is still triggered shortly after startup.
when I changed to the suggested from: ‘off’ to:‘on’
Try to save and get the error Message malformed: required key not provided @ data[‘triggers’][0][‘trigger’]
The gate trigger is a simple door sense Sonoff (SNZB-04P)
Should I use other option in place of OFF & ON
Tried Opene & close but obviously these are not correct either
The State Trigger I posted is correct. The error message indicates you may have copied it incorrectly because it is missing a “required key”.
The State Trigger I posted is completely different from the existing Device Trigger in your automation.
The recommendation is to replace the entire Device Trigger with a State Trigger.
Hi. I have this working however it always shows the gate is open after add this edit
Is there something else I need to do so it shows that5 the gate has closed again
Also it rings again when the gate is closed
I found the original problem
Is a broken magnet, somehow broke into 2 pieces and was sitting just on the edge of the sensor position.
So I replaced the magnet I reverted my original automation and all works correctly
I had thought it was the sensor so replaced it, but all my other window and doors were ok. so looked a bit deeper by putting the sensor on my work desk then saw it worked on the desk…
The problem was home assistant was seeing the gate open,