jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
198 stars 48 forks source link

Missing device in Hubitat, referenced in HA automation, causes HA validation to fail and not start correctly #222

Closed zaphod2020 closed 1 year ago

zaphod2020 commented 1 year ago

I removed a device from my hubitat hub. The device was referenced by a HA automation. The HA YAML validation fails with the errors below, and will not start up correctly (it does not load the automations at all).

2023-07-14 19:57:01.839 ERROR (MainThread) [homeassistant.config] Unknown error calling automation config validator Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config.py", line 864, in async_process_component_config await config_validator.async_validate_config(hass, config) File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 261, in async_validate_config await asyncio.gather( File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 242, in _try_async_validateconfig> return await _async_validate_config_item(hass, config, False, True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 177, in _async_validate_config_item automation_config[CONF_TRIGGER] = await async_validate_trigger_config( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/trigger.py", line 240, in async_validate_trigger_config conf = await platform.async_validate_trigger_config(hass, conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/device_automation/trigger.py", line 49, in async_validate_trigg> return await async_validate_device_automation_config( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/device_automation/helpers.py", line 107, in async_validate_devi> await getattr(platform, DYNAMIC_VALIDATOR[automation_type])(hass, config), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hubitat/device_trigger.py", line 87, in async_validate_trigger_config hubitatdevice, = get_hubitat_device(hass, device.id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hubitat/device_trigger.py", line 194, in get_hubitat_device raise DeviceError(f"Invalid Hubitat ID for device {device_id}") custom_components.hubitat.error.DeviceError: Invalid Hubitat ID for device 81320d04668fe94a2f980a5765fc2571 2023-07-14 19:57:01.852 ERROR (MainThread) [homeassistant.setup] Setup failed for automation: Invalid config.

zaphod2020 commented 1 year ago

HA v2023.7.2. Of course, this may well be an HA problem, but wanted you to be aware.

jason0x43 commented 1 year ago

I think HA could probably handle exceptions thrown by integrations a bit more gracefully, but I also think this integration could deal with that situation without throwing an exception. I'll have an update out in the next day or two.