I have the below automation and two scripts below. The majority of the time it works perfectly, as expected. However, from time to time, it either fails to work at all or partly works (some entities trigger but others don’t).
The strange thing is, if I go to my automation yaml, and delete then reinsert one character at random, then save and restart, the automation works successfully again.
What could cause that? Is there an issue with coding? It’s unusual behaviour, especially if I don’t have to even save in between changing the character in the yaml file.
Automation
- alias: Weekday Wake
trigger:
platform: state
entity_id: binary_sensor.staircase_sensor_motion
to: 'on'
condition:
condition: and
conditions:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: time
after: '06:00:00'
before: '07:30:00'
- condition: template
value_template: "{{ (is_state('sensor.m_iphone_battery_state', 'Not Charging') or is_state ('sensor.r_iphone_battery_state', 'Not Charging')) and is_state ('media_player.sky_q','off') }}"
action:
- service: script.weekday_wake
- service: script.morning_living_room
Thanks Tom. I tried the first steps of the troubleshooting but it appears I have duplicates of every automation, for some reason. All my automations were created directly in the yaml file and that file only shows one instance of each automation.
However, in the automation configuration every one is listed twice. In each case one instance is turned on, the other turned off. When I hover over the clock, I get the message ‘Only automations that have a unique ID assigned are debuggable’.
I have no idea where the duplicate automations have come from. Example below.
Thanks for both replies. But can anyone explain why HA would create duplicates for every automation as I definitely haven’t done that, and I’ve been careful to only create each one within yaml.
how about add the unique_id first and then verify the duplicates exist after. If they still exist, make sure they aren’t deletable. If they are deletable, that means the system got confused at some point due to a lack of unique_id’s. Just delete the duplicates at that point through the entity list.
Think of the unique_id as a “name” for a registry. If you register your name, the system knows you by that name. Then if you change your name, the system still knows your old name but not your new one. So it just creates a new registry. At that point, it looks like a duplicate, however nothing is attached to the old name because it’s now attached to the new name.
Not sure where you deleted them but now check the Configuration / Devices / Entities page too. “Restored” (poor name) automations need to be deleted from there too.