diff --git a/homeassistant/components/binary_sensor/zha.py b/homeassistant/components/binary_sensor/zha.py index 80549037ee1..de7896e595b 100644 --- a/homeassistant/components/binary_sensor/zha.py +++ b/homeassistant/components/binary_sensor/zha.py @@ -78,7 +78,7 @@ class BinarySensor(zha.Entity, BinarySensorDevice): """Return the class of this device, from component DEVICE_CLASSES.""" return self._device_class - def cluster_command(self, aps_frame, tsn, command_id, args): + def cluster_command(self, tsn, command_id, args): """Handle commands received to this cluster.""" if command_id == 0: self._state = args[0] & 3 diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index cf44dea8c1d..58d44b31994 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -5,6 +5,7 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/zha/ """ import asyncio +import enum import logging import voluptuous as vol @@ -17,13 +18,23 @@ from homeassistant.util import slugify REQUIREMENTS = [ 'bellows==0.5.0', 'zigpy==0.0.1', + 'zigpy-xbee==0.0.1', ] DOMAIN = 'zha' + +class RadioType(enum.Enum): + """Possible options for radio type in config.""" + + ezsp = 'ezsp' + xbee = 'xbee' + + CONF_BAUDRATE = 'baudrate' CONF_DATABASE = 'database_path' CONF_DEVICE_CONFIG = 'device_config' +CONF_RADIO_TYPE = 'radio_type' CONF_USB_PATH = 'usb_path' DATA_DEVICE_CONFIG = 'zha_device_config' @@ -33,6 +44,8 @@ DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({ CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ + vol.Optional(CONF_RADIO_TYPE, default=RadioType.ezsp): + cv.enum(RadioType), CONF_USB_PATH: cv.string, vol.Optional(CONF_BAUDRATE, default=57600): cv.positive_int, CONF_DATABASE: cv.string, @@ -70,16 +83,22 @@ def async_setup(hass, config): """ global APPLICATION_CONTROLLER - import bellows.ezsp - from bellows.zigbee.application import ControllerApplication - - ezsp_ = bellows.ezsp.EZSP() usb_path = config[DOMAIN].get(CONF_USB_PATH) baudrate = config[DOMAIN].get(CONF_BAUDRATE) - yield from ezsp_.connect(usb_path, baudrate) + radio_type = config[DOMAIN].get(CONF_RADIO_TYPE) + if radio_type == RadioType.ezsp: + import bellows.ezsp + from bellows.zigbee.application import ControllerApplication + radio = bellows.ezsp.EZSP() + elif radio_type == RadioType.xbee: + import zigpy_xbee.api + from zigpy_xbee.zigbee.application import ControllerApplication + radio = zigpy_xbee.api.XBee() + + yield from radio.connect(usb_path, baudrate) database = config[DOMAIN].get(CONF_DATABASE) - APPLICATION_CONTROLLER = ControllerApplication(ezsp_, database) + APPLICATION_CONTROLLER = ControllerApplication(radio, database) listener = ApplicationListener(hass, config) APPLICATION_CONTROLLER.add_listener(listener) yield from APPLICATION_CONTROLLER.startup(auto_form=True) @@ -256,7 +275,7 @@ class Entity(entity.Entity): """Handle an attribute updated on this cluster.""" pass - def zdo_command(self, aps_frame, tsn, command_id, args): + def zdo_command(self, tsn, command_id, args): """Handle a ZDO command received on this cluster.""" pass diff --git a/requirements_all.txt b/requirements_all.txt index 85ca4e89bd5..ad86e129ae0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1272,5 +1272,8 @@ zeroconf==0.19.1 # homeassistant.components.media_player.ziggo_mediabox_xl ziggo-mediabox-xl==1.0.0 +# homeassistant.components.zha +zigpy-xbee==0.0.1 + # homeassistant.components.zha zigpy==0.0.1