From 031ee71adffa5cd1cda13b7402cad6d6c9b81ed9 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Wed, 12 Dec 2018 11:06:22 -0500 Subject: [PATCH] Add ZHA device handler library (#19099) * event foundation * implement quirks * lock zha-quirks version * allow quirks handling to be toggled on and off * revert event commit * disable warning * update requirements_all * Remove fix in favor of #19141 #19141 should be what ultimately corrects this issue. * review comment --- .coveragerc | 1 + homeassistant/components/zha/__init__.py | 13 +++++++++++-- homeassistant/components/zha/const.py | 1 + requirements_all.txt | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index 8d98a0c23e0..a33a58f3571 100644 --- a/.coveragerc +++ b/.coveragerc @@ -407,6 +407,7 @@ omit = homeassistant/components/zha/__init__.py homeassistant/components/zha/const.py + homeassistant/components/zha/event.py homeassistant/components/zha/entities/* homeassistant/components/zha/helpers.py homeassistant/components/*/zha.py diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index 41659ae47df..e685deed1c6 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -28,12 +28,13 @@ from .const import ( DATA_ZHA_CONFIG, DATA_ZHA_CORE_COMPONENT, DATA_ZHA_DISPATCHERS, DATA_ZHA_RADIO, DEFAULT_BAUDRATE, DEFAULT_DATABASE_NAME, DEFAULT_RADIO_TYPE, DOMAIN, ZHA_DISCOVERY_NEW, RadioType, - EVENTABLE_CLUSTERS, DATA_ZHA_CORE_EVENTS) + EVENTABLE_CLUSTERS, DATA_ZHA_CORE_EVENTS, ENABLE_QUIRKS) REQUIREMENTS = [ 'bellows==0.7.0', 'zigpy==0.2.0', 'zigpy-xbee==0.1.1', + 'zha-quirks==0.0.5' ] DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({ @@ -51,6 +52,7 @@ CONFIG_SCHEMA = vol.Schema({ vol.Optional(CONF_DATABASE): cv.string, vol.Optional(CONF_DEVICE_CONFIG, default={}): vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}), + vol.Optional(ENABLE_QUIRKS, default=True): cv.boolean, }) }, extra=vol.ALLOW_EXTRA) @@ -94,7 +96,8 @@ async def async_setup(hass, config): context={'source': config_entries.SOURCE_IMPORT}, data={ CONF_USB_PATH: conf[CONF_USB_PATH], - CONF_RADIO_TYPE: conf.get(CONF_RADIO_TYPE).value + CONF_RADIO_TYPE: conf.get(CONF_RADIO_TYPE).value, + ENABLE_QUIRKS: conf[ENABLE_QUIRKS] } )) return True @@ -105,6 +108,12 @@ async def async_setup_entry(hass, config_entry): Will automatically load components to support devices found on the network. """ + if config_entry.data.get(ENABLE_QUIRKS): + # needs to be done here so that the ZHA module is finished loading + # before zhaquirks is imported + # pylint: disable=W0611, W0612 + import zhaquirks # noqa + global APPLICATION_CONTROLLER hass.data[DATA_ZHA] = hass.data.get(DATA_ZHA, {}) diff --git a/homeassistant/components/zha/const.py b/homeassistant/components/zha/const.py index 7da6f826c44..a148eccf53f 100644 --- a/homeassistant/components/zha/const.py +++ b/homeassistant/components/zha/const.py @@ -30,6 +30,7 @@ CONF_DEVICE_CONFIG = 'device_config' CONF_RADIO_TYPE = 'radio_type' CONF_USB_PATH = 'usb_path' DATA_DEVICE_CONFIG = 'zha_device_config' +ENABLE_QUIRKS = 'enable_quirks' DEFAULT_RADIO_TYPE = 'ezsp' DEFAULT_BAUDRATE = 57600 diff --git a/requirements_all.txt b/requirements_all.txt index db2165edcf6..ff6cc9cee1d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1670,6 +1670,9 @@ zengge==0.2 # homeassistant.components.zeroconf zeroconf==0.21.3 +# homeassistant.components.zha +zha-quirks==0.0.5 + # homeassistant.components.climate.zhong_hong zhong_hong_hvac==1.0.9