From c7bd0fe909e3864ec2c34559091d7bd5855b6dad Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 14 Oct 2019 20:11:43 +0200 Subject: [PATCH] Fix ZHA regressions caused by "Support async validation of device trigger" (#27401) * Revert "Support async validation of device trigger (#27333)" This reverts commit fdf4f398a79e775e11dc9fdd391a8b53f7b773c5. * Revert only ZHA changes * Fix whitespace * Restore ZHA changes but add check to make sure ZHA is loaded * Address review comment * Remove additional check --- homeassistant/components/zha/device_trigger.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/zha/device_trigger.py b/homeassistant/components/zha/device_trigger.py index 8d74ae108a2..cdd62b11d1e 100644 --- a/homeassistant/components/zha/device_trigger.py +++ b/homeassistant/components/zha/device_trigger.py @@ -25,14 +25,14 @@ async def async_validate_trigger_config(hass, config): """Validate config.""" config = TRIGGER_SCHEMA(config) - trigger = (config[CONF_TYPE], config[CONF_SUBTYPE]) - zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID]) - - if ( - zha_device.device_automation_triggers is None - or trigger not in zha_device.device_automation_triggers - ): - raise InvalidDeviceAutomationConfig + if "zha" in hass.config.components: + trigger = (config[CONF_TYPE], config[CONF_SUBTYPE]) + zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID]) + if ( + zha_device.device_automation_triggers is None + or trigger not in zha_device.device_automation_triggers + ): + raise InvalidDeviceAutomationConfig return config