Suddenly got an error at restart that automations couldn’t be set up
Can you copy the full error log and paste it here as text please?
2023-08-11 14:31:10.255 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: automation
2023-08-11 14:31:10.257 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: automation')
2023-08-11 14:31:10.235 ERROR (MainThread) [homeassistant.setup] Error during setup of component automation
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 288, in _async_setup_component
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 259, in async_setup
await _async_process_config(hass, config, component)
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 976, in _async_process_config
entities = await _create_automation_entities(hass, updated_automation_configs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 860, in _create_automation_entities
cond_func = await _async_process_if(hass, name, config_block)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 989, in _async_process_if
checks.append(await condition.async_from_config(hass, if_config))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 246, in async_from_config
return cast(ConditionCheckerType, await factory(hass, config))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/device_automation/condition.py", line 55, in async_condition_from_config
return trace_condition_function(platform.async_condition_from_config(hass, config))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/binary_sensor/device_condition.py", line 317, in async_condition_from_config
state_config = condition.state_validate_config(hass, state_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 1022, in state_validate_config
config[CONF_ENTITY_ID] = er.async_validate_entity_ids(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1395, in async_validate_entity_ids
return [async_validate_entity_id(registry, item) for item in entity_ids_or_uuids]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1395, in <listcomp>
return [async_validate_entity_id(registry, item) for item in entity_ids_or_uuids]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1364, in async_validate_entity_id
raise vol.Invalid(f"Unknown entity registry entry {entity_id_or_uuid}")
voluptuous.error.Invalid: Unknown entity registry entry 702f5fe57949392deaaef8d89966e2f4
2023-08-11 14:31:10.255 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: automation
2023-08-11 14:31:10.257 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: automation')
Hmm that’s not very helpful. What happens if you run a config check?
it says the usual - Config will not prevent Home Assistant from starting
Rename automations.yaml to automations.old
create an empty automations.yaml
restart HA
does that work ?
that worked - at least automations are showing up now on the visual editor. I guess one of those automations was breaking things up then?
Yes, now the work is finding which one.
Yeah. Paste the back from the old file a few at a time until you find the issue.
This is the solution. I troubleshooted it and learned the hard way not to delete devices abruptly - a single device deletion called this mayhem. Also for anyone reading this afterwards - MINIMIZE the use of DEVICE in triggers - do states instead. That will simplify troubleshooting vs. looking at random IDs and having to read entire automation
Ok. While I strongly agree with your stance on device automations, you may have just found a bug.
In a recent release the behaviour of device automations was changed. Rather than disappearing completely a device automation that used an unavailable device should now report as unavailable. It seems that instead it is creating the mess of issues you reported above.
We should open an issue about this. Can you post the automation that caused the issue (if you still have your automations.old file)?
Also what version of home assistant are you on?
Edit:
For my reference this is the PR: Set automations which fail validation unavailable by emontnemery · Pull Request #94856 · home-assistant/core · GitHub
Others with this issue:
Hello all
This happened to me again out of the blue after a complete rebuild and updates
After a complete destruction of the HA vm on proxmox I re-install HA OS and all the addons and integration i had before.
I restarted HAOS af ter each addition
As I’m adding z-wave devices and i started to add simple automation this situation happed for the 3rd time.
I tried to rename automation .yaml to old this was more a disaster than before because it goes way beyond my comfort zone.
I deleted and destroyed the HA VM again and recreated it.
After each step I created a backup (just in case)
As i added addons and integrations nothing happened.
I added z-wave js ui addon and the js integration as per instructions and so far all is fine.
I truly believe that the root cause of this were all the updates from HA and the integrations that were not aligned.
I will continue to add integrations and automations and continued to create full backups and see where this goes
The cause is that you are using device automations, and the way missing devices in automations are handled has changed, possibly including a bug.
If you keep adding back the same faulty automation without changing it you will get the same result.
You did not answer any of my questions so I can’t help you.
@tom_l
Same thing happened to me.
What would be the info needed to debug it?
I’ve updated from 2023.8.1 to 2023.8.2 and also use device automation. However I certainly did not delete any of them that are used in automations.
You would need to remove all the automations from your automations.yaml file, reload or restart the add them back one at a time reloading in-between to find the automation at fault.
Okay, I’ve dug through the logs, found the ID it was erroring on, found it in the automations.yaml and changed the triggers and conditions from device based to state based (glad I’ve already had them in other automations and could just copy them)
Thank you, nevertheless!
I think it was this one (I did retain Automations.old). Device that caused it is the one in “Condition”
- id: '1691345676498'
alias: Princess Window R Open/Close
description: ''
trigger:
- platform: time
at: '21:00:00'
condition:
- type: is_open
condition: device
device_id: a84a65093ec671a93f09e00a34769ce9
entity_id: 702f5fe57949392deaaef8d89966e2f4
domain: binary_sensor
action:
- type: turn_on
device_id: 287d6dfad0dc0c36c5b8fd09238e5742
entity_id: light.king_bulb_ceiling
domain: light
brightness_pct: 90
alias: Turn on King Bulb
- service: notify.alexa_media_sphere
data:
data:
type: tts
message: Princess right window is open
mode: single
Version - wise:
Home Assistant 2023.8.2
Supervisor 2023.08.1
Operating System 10.4
Frontend 20230802.0 - latest
this is actually very simple (I am not technical at all myself) - all you do is go into File Editor → rename Automations to .old and then click + to create file automations.yaml. That’s it. You then restart and all starts working. Then just copy across from automations.old little by little to identify the culprit and quash it.
Are any of the devices used in that automation unavailable?
Yes, the one in Condition was