mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
zha: Add support for XBee radios (#12205)
* zha: Add support for xbee radios * Lint
This commit is contained in:
parent
844337ca42
commit
c7dad113d9
@ -78,7 +78,7 @@ class BinarySensor(zha.Entity, BinarySensorDevice):
|
|||||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
return self._device_class
|
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."""
|
"""Handle commands received to this cluster."""
|
||||||
if command_id == 0:
|
if command_id == 0:
|
||||||
self._state = args[0] & 3
|
self._state = args[0] & 3
|
||||||
|
@ -5,6 +5,7 @@ For more details about this component, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/zha/
|
https://home-assistant.io/components/zha/
|
||||||
"""
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import enum
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -17,13 +18,23 @@ from homeassistant.util import slugify
|
|||||||
REQUIREMENTS = [
|
REQUIREMENTS = [
|
||||||
'bellows==0.5.0',
|
'bellows==0.5.0',
|
||||||
'zigpy==0.0.1',
|
'zigpy==0.0.1',
|
||||||
|
'zigpy-xbee==0.0.1',
|
||||||
]
|
]
|
||||||
|
|
||||||
DOMAIN = 'zha'
|
DOMAIN = 'zha'
|
||||||
|
|
||||||
|
|
||||||
|
class RadioType(enum.Enum):
|
||||||
|
"""Possible options for radio type in config."""
|
||||||
|
|
||||||
|
ezsp = 'ezsp'
|
||||||
|
xbee = 'xbee'
|
||||||
|
|
||||||
|
|
||||||
CONF_BAUDRATE = 'baudrate'
|
CONF_BAUDRATE = 'baudrate'
|
||||||
CONF_DATABASE = 'database_path'
|
CONF_DATABASE = 'database_path'
|
||||||
CONF_DEVICE_CONFIG = 'device_config'
|
CONF_DEVICE_CONFIG = 'device_config'
|
||||||
|
CONF_RADIO_TYPE = 'radio_type'
|
||||||
CONF_USB_PATH = 'usb_path'
|
CONF_USB_PATH = 'usb_path'
|
||||||
DATA_DEVICE_CONFIG = 'zha_device_config'
|
DATA_DEVICE_CONFIG = 'zha_device_config'
|
||||||
|
|
||||||
@ -33,6 +44,8 @@ DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
|
|||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
|
vol.Optional(CONF_RADIO_TYPE, default=RadioType.ezsp):
|
||||||
|
cv.enum(RadioType),
|
||||||
CONF_USB_PATH: cv.string,
|
CONF_USB_PATH: cv.string,
|
||||||
vol.Optional(CONF_BAUDRATE, default=57600): cv.positive_int,
|
vol.Optional(CONF_BAUDRATE, default=57600): cv.positive_int,
|
||||||
CONF_DATABASE: cv.string,
|
CONF_DATABASE: cv.string,
|
||||||
@ -70,16 +83,22 @@ def async_setup(hass, config):
|
|||||||
"""
|
"""
|
||||||
global APPLICATION_CONTROLLER
|
global APPLICATION_CONTROLLER
|
||||||
|
|
||||||
import bellows.ezsp
|
|
||||||
from bellows.zigbee.application import ControllerApplication
|
|
||||||
|
|
||||||
ezsp_ = bellows.ezsp.EZSP()
|
|
||||||
usb_path = config[DOMAIN].get(CONF_USB_PATH)
|
usb_path = config[DOMAIN].get(CONF_USB_PATH)
|
||||||
baudrate = config[DOMAIN].get(CONF_BAUDRATE)
|
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)
|
database = config[DOMAIN].get(CONF_DATABASE)
|
||||||
APPLICATION_CONTROLLER = ControllerApplication(ezsp_, database)
|
APPLICATION_CONTROLLER = ControllerApplication(radio, database)
|
||||||
listener = ApplicationListener(hass, config)
|
listener = ApplicationListener(hass, config)
|
||||||
APPLICATION_CONTROLLER.add_listener(listener)
|
APPLICATION_CONTROLLER.add_listener(listener)
|
||||||
yield from APPLICATION_CONTROLLER.startup(auto_form=True)
|
yield from APPLICATION_CONTROLLER.startup(auto_form=True)
|
||||||
@ -256,7 +275,7 @@ class Entity(entity.Entity):
|
|||||||
"""Handle an attribute updated on this cluster."""
|
"""Handle an attribute updated on this cluster."""
|
||||||
pass
|
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."""
|
"""Handle a ZDO command received on this cluster."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1272,5 +1272,8 @@ zeroconf==0.19.1
|
|||||||
# homeassistant.components.media_player.ziggo_mediabox_xl
|
# homeassistant.components.media_player.ziggo_mediabox_xl
|
||||||
ziggo-mediabox-xl==1.0.0
|
ziggo-mediabox-xl==1.0.0
|
||||||
|
|
||||||
|
# homeassistant.components.zha
|
||||||
|
zigpy-xbee==0.0.1
|
||||||
|
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
zigpy==0.0.1
|
zigpy==0.0.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user