From c67d035366fb5acc42468fd1aac975628ab6c025 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 14 May 2020 12:19:59 +0200 Subject: [PATCH] Rename zigbee to xbee (#35613) --- .coveragerc | 2 +- .../components/{zigbee => xbee}/__init__.py | 62 +++++++++---------- .../{zigbee => xbee}/binary_sensor.py | 12 ++-- .../components/{zigbee => xbee}/light.py | 10 +-- homeassistant/components/xbee/manifest.json | 7 +++ .../components/{zigbee => xbee}/sensor.py | 20 +++--- .../components/{zigbee => xbee}/switch.py | 12 ++-- homeassistant/components/zigbee/manifest.json | 7 --- requirements_all.txt | 2 +- 9 files changed, 62 insertions(+), 72 deletions(-) rename homeassistant/components/{zigbee => xbee}/__init__.py (88%) rename homeassistant/components/{zigbee => xbee}/binary_sensor.py (54%) rename homeassistant/components/{zigbee => xbee}/light.py (61%) create mode 100644 homeassistant/components/xbee/manifest.json rename homeassistant/components/{zigbee => xbee}/sensor.py (84%) rename homeassistant/components/{zigbee => xbee}/switch.py (50%) delete mode 100644 homeassistant/components/zigbee/manifest.json diff --git a/.coveragerc b/.coveragerc index ffbcda1b56a..282db156e65 100644 --- a/.coveragerc +++ b/.coveragerc @@ -914,7 +914,7 @@ omit = homeassistant/components/zha/light.py homeassistant/components/zha/sensor.py homeassistant/components/zhong_hong/climate.py - homeassistant/components/zigbee/* + homeassistant/components/xbee/* homeassistant/components/ziggo_mediabox_xl/media_player.py homeassistant/components/zoneminder/* homeassistant/components/supla/* diff --git a/homeassistant/components/zigbee/__init__.py b/homeassistant/components/xbee/__init__.py similarity index 88% rename from homeassistant/components/zigbee/__init__.py rename to homeassistant/components/xbee/__init__.py index 2fa8291538e..31e2d6dc495 100644 --- a/homeassistant/components/zigbee/__init__.py +++ b/homeassistant/components/xbee/__init__.py @@ -1,4 +1,4 @@ -"""Support for Zigbee devices.""" +"""Support for XBee Zigbee devices.""" from binascii import hexlify, unhexlify import logging @@ -23,9 +23,9 @@ from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) -DOMAIN = "zigbee" +DOMAIN = "xbee" -SIGNAL_ZIGBEE_FRAME_RECEIVED = "zigbee_frame_received" +SIGNAL_XBEE_FRAME_RECEIVED = "xbee_frame_received" CONF_BAUD = "baud" @@ -58,28 +58,28 @@ PLATFORM_SCHEMA = vol.Schema( def setup(hass, config): - """Set up the connection to the Zigbee device.""" + """Set up the connection to the XBee Zigbee device.""" usb_device = config[DOMAIN].get(CONF_DEVICE, DEFAULT_DEVICE) baud = int(config[DOMAIN].get(CONF_BAUD, DEFAULT_BAUD)) try: ser = Serial(usb_device, baud) except SerialException as exc: - _LOGGER.exception("Unable to open serial port for Zigbee: %s", exc) + _LOGGER.exception("Unable to open serial port for XBee: %s", exc) return False zigbee_device = ZigBee(ser) def close_serial_port(*args): - """Close the serial port we're using to communicate with the Zigbee.""" + """Close the serial port we're using to communicate with the XBee.""" zigbee_device.zb.serial.close() def _frame_received(frame): - """Run when a Zigbee frame is received. + """Run when a XBee Zigbee frame is received. Pickles the frame, then encodes it into base64 since it contains non JSON serializable binary. """ - dispatcher_send(hass, SIGNAL_ZIGBEE_FRAME_RECEIVED, frame) + dispatcher_send(hass, SIGNAL_XBEE_FRAME_RECEIVED, frame) hass.data[DOMAIN] = zigbee_device hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, close_serial_port) @@ -92,12 +92,10 @@ def frame_is_relevant(entity, frame): """Test whether the frame is relevant to the entity.""" if frame.get("source_addr_long") != entity.config.address: return False - if "samples" not in frame: - return False - return True + return "samples" in frame -class ZigBeeConfig: +class XBeeConfig: """Handle the fetching of configuration from the config file.""" def __init__(self, config): @@ -115,7 +113,7 @@ class ZigBeeConfig: """Return the address of the device. If an address has been provided, unhexlify it, otherwise return None - as we're talking to our local Zigbee device. + as we're talking to our local XBee device. """ address = self._config.get("address") if address is not None: @@ -128,7 +126,7 @@ class ZigBeeConfig: return self._should_poll -class ZigBeePinConfig(ZigBeeConfig): +class XBeePinConfig(XBeeConfig): """Handle the fetching of configuration from the configuration file.""" @property @@ -137,11 +135,11 @@ class ZigBeePinConfig(ZigBeeConfig): return self._config["pin"] -class ZigBeeDigitalInConfig(ZigBeePinConfig): - """A subclass of ZigBeePinConfig.""" +class XBeeDigitalInConfig(XBeePinConfig): + """A subclass of XBeePinConfig.""" def __init__(self, config): - """Initialise the Zigbee Digital input config.""" + """Initialise the XBee Zigbee Digital input config.""" super().__init__(config) self._bool2state, self._state2bool = self.boolean_maps @@ -177,15 +175,15 @@ class ZigBeeDigitalInConfig(ZigBeePinConfig): return self._state2bool -class ZigBeeDigitalOutConfig(ZigBeePinConfig): - """A subclass of ZigBeePinConfig. +class XBeeDigitalOutConfig(XBeePinConfig): + """A subclass of XBeePinConfig. Set _should_poll to default as False instead of True. The value will still be overridden by the presence of a 'poll' config entry. """ def __init__(self, config): - """Initialize the Zigbee Digital out.""" + """Initialize the XBee Zigbee Digital out.""" super().__init__(config) self._bool2state, self._state2bool = self.boolean_maps self._should_poll = config.get("poll", False) @@ -227,8 +225,8 @@ class ZigBeeDigitalOutConfig(ZigBeePinConfig): return self._state2bool -class ZigBeeAnalogInConfig(ZigBeePinConfig): - """Representation of a Zigbee GPIO pin set to analog in.""" +class XBeeAnalogInConfig(XBeePinConfig): + """Representation of a XBee Zigbee GPIO pin set to analog in.""" @property def max_voltage(self): @@ -236,7 +234,7 @@ class ZigBeeAnalogInConfig(ZigBeePinConfig): return float(self._config.get("max_volts", DEFAULT_ADC_MAX_VOLTS)) -class ZigBeeDigitalIn(Entity): +class XBeeDigitalIn(Entity): """Representation of a GPIO pin configured as a digital input.""" def __init__(self, config, device): @@ -268,7 +266,7 @@ class ZigBeeDigitalIn(Entity): ] self.schedule_update_ha_state() - async_dispatcher_connect(self.hass, SIGNAL_ZIGBEE_FRAME_RECEIVED, handle_frame) + async_dispatcher_connect(self.hass, SIGNAL_XBEE_FRAME_RECEIVED, handle_frame) @property def name(self): @@ -316,11 +314,11 @@ class ZigBeeDigitalIn(Entity): self._state = self._config.state2bool[sample[pin_name]] -class ZigBeeDigitalOut(ZigBeeDigitalIn): +class XBeeDigitalOut(XBeeDigitalIn): """Representation of a GPIO pin configured as a digital input.""" def _set_state(self, state): - """Initialize the Zigbee digital out device.""" + """Initialize the XBee Zigbee digital out device.""" try: self._device.set_gpio_pin( self._config.pin, self._config.bool2state[state], self._config.address @@ -333,7 +331,7 @@ class ZigBeeDigitalOut(ZigBeeDigitalIn): ) return except ZigBeeException as exc: - _LOGGER.exception("Unable to set digital pin on Zigbee device: %s", exc) + _LOGGER.exception("Unable to set digital pin on XBee device: %s", exc) return self._state = state if not self.should_poll: @@ -348,7 +346,7 @@ class ZigBeeDigitalOut(ZigBeeDigitalIn): self._set_state(False) def update(self): - """Ask the Zigbee device what its output is set to.""" + """Ask the XBee device what its output is set to.""" try: pin_state = self._device.get_gpio_pin( self._config.pin, self._config.address @@ -362,17 +360,17 @@ class ZigBeeDigitalOut(ZigBeeDigitalIn): return except ZigBeeException as exc: _LOGGER.exception( - "Unable to get output pin status from Zigbee device: %s", exc + "Unable to get output pin status from XBee device: %s", exc ) return self._state = self._config.state2bool[pin_state] -class ZigBeeAnalogIn(Entity): +class XBeeAnalogIn(Entity): """Representation of a GPIO pin configured as an analog input.""" def __init__(self, config, device): - """Initialize the ZigBee analog in device.""" + """Initialize the XBee analog in device.""" self._config = config self._device = device self._value = None @@ -398,7 +396,7 @@ class ZigBeeAnalogIn(Entity): ) self.schedule_update_ha_state() - async_dispatcher_connect(self.hass, SIGNAL_ZIGBEE_FRAME_RECEIVED, handle_frame) + async_dispatcher_connect(self.hass, SIGNAL_XBEE_FRAME_RECEIVED, handle_frame) @property def name(self): diff --git a/homeassistant/components/zigbee/binary_sensor.py b/homeassistant/components/xbee/binary_sensor.py similarity index 54% rename from homeassistant/components/zigbee/binary_sensor.py rename to homeassistant/components/xbee/binary_sensor.py index fe35b54a88f..47c7515ddc7 100644 --- a/homeassistant/components/zigbee/binary_sensor.py +++ b/homeassistant/components/xbee/binary_sensor.py @@ -3,7 +3,7 @@ import voluptuous as vol from homeassistant.components.binary_sensor import BinarySensorEntity -from . import DOMAIN, PLATFORM_SCHEMA, ZigBeeDigitalIn, ZigBeeDigitalInConfig +from . import DOMAIN, PLATFORM_SCHEMA, XBeeDigitalIn, XBeeDigitalInConfig CONF_ON_STATE = "on_state" @@ -14,12 +14,10 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_ON_STATE): vol.In(ST def setup_platform(hass, config, add_entities, discovery_info=None): - """Set up the Zigbee binary sensor platform.""" + """Set up the XBee Zigbee binary sensor platform.""" zigbee_device = hass.data[DOMAIN] - add_entities( - [ZigBeeBinarySensor(ZigBeeDigitalInConfig(config), zigbee_device)], True - ) + add_entities([XBeeBinarySensor(XBeeDigitalInConfig(config), zigbee_device)], True) -class ZigBeeBinarySensor(ZigBeeDigitalIn, BinarySensorEntity): - """Use ZigBeeDigitalIn as binary sensor.""" +class XBeeBinarySensor(XBeeDigitalIn, BinarySensorEntity): + """Use XBeeDigitalIn as binary sensor.""" diff --git a/homeassistant/components/zigbee/light.py b/homeassistant/components/xbee/light.py similarity index 61% rename from homeassistant/components/zigbee/light.py rename to homeassistant/components/xbee/light.py index 10bb87aa426..76ed8120166 100644 --- a/homeassistant/components/zigbee/light.py +++ b/homeassistant/components/xbee/light.py @@ -1,9 +1,9 @@ -"""Support for Zigbee lights.""" +"""Support for XBee Zigbee lights.""" import voluptuous as vol from homeassistant.components.light import LightEntity -from . import DOMAIN, PLATFORM_SCHEMA, ZigBeeDigitalOut, ZigBeeDigitalOutConfig +from . import DOMAIN, PLATFORM_SCHEMA, XBeeDigitalOut, XBeeDigitalOutConfig CONF_ON_STATE = "on_state" @@ -18,8 +18,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( def setup_platform(hass, config, add_entities, discovery_info=None): """Create and add an entity based on the configuration.""" zigbee_device = hass.data[DOMAIN] - add_entities([ZigBeeLight(ZigBeeDigitalOutConfig(config), zigbee_device)]) + add_entities([XBeeLight(XBeeDigitalOutConfig(config), zigbee_device)]) -class ZigBeeLight(ZigBeeDigitalOut, LightEntity): - """Use ZigBeeDigitalOut as light.""" +class XBeeLight(XBeeDigitalOut, LightEntity): + """Use XBeeDigitalOut as light.""" diff --git a/homeassistant/components/xbee/manifest.json b/homeassistant/components/xbee/manifest.json new file mode 100644 index 00000000000..9d70751e230 --- /dev/null +++ b/homeassistant/components/xbee/manifest.json @@ -0,0 +1,7 @@ +{ + "domain": "xbee", + "name": "XBee", + "documentation": "https://www.home-assistant.io/integrations/xbee", + "requirements": ["xbee-helper==0.0.7"], + "codeowners": [] +} diff --git a/homeassistant/components/zigbee/sensor.py b/homeassistant/components/xbee/sensor.py similarity index 84% rename from homeassistant/components/zigbee/sensor.py rename to homeassistant/components/xbee/sensor.py index 0c709a6d1a5..4a392691032 100644 --- a/homeassistant/components/zigbee/sensor.py +++ b/homeassistant/components/xbee/sensor.py @@ -1,4 +1,4 @@ -"""Support for Zigbee sensors.""" +"""Support for XBee Zigbee sensors.""" from binascii import hexlify import logging @@ -8,13 +8,7 @@ from xbee_helper.exceptions import ZigBeeException, ZigBeeTxFailure from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.entity import Entity -from . import ( - DOMAIN, - PLATFORM_SCHEMA, - ZigBeeAnalogIn, - ZigBeeAnalogInConfig, - ZigBeeConfig, -) +from . import DOMAIN, PLATFORM_SCHEMA, XBeeAnalogIn, XBeeAnalogInConfig, XBeeConfig _LOGGER = logging.getLogger(__name__) @@ -33,7 +27,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( def setup_platform(hass, config, add_entities, discovery_info=None): - """Set up the Zigbee platform. + """Set up the XBee Zigbee platform. Uses the 'type' config value to work out which type of Zigbee sensor we're dealing with and instantiates the relevant classes to handle it. @@ -44,13 +38,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None): try: sensor_class, config_class = TYPE_CLASSES[typ] except KeyError: - _LOGGER.exception("Unknown Zigbee sensor type: %s", typ) + _LOGGER.exception("Unknown XBee Zigbee sensor type: %s", typ) return add_entities([sensor_class(config_class(config), zigbee_device)], True) -class ZigBeeTemperatureSensor(Entity): +class XBeeTemperatureSensor(Entity): """Representation of XBee Pro temperature sensor.""" def __init__(self, config, device): @@ -90,6 +84,6 @@ class ZigBeeTemperatureSensor(Entity): # This must be below the classes to which it refers. TYPE_CLASSES = { - "temperature": (ZigBeeTemperatureSensor, ZigBeeConfig), - "analog": (ZigBeeAnalogIn, ZigBeeAnalogInConfig), + "temperature": (XBeeTemperatureSensor, XBeeConfig), + "analog": (XBeeAnalogIn, XBeeAnalogInConfig), } diff --git a/homeassistant/components/zigbee/switch.py b/homeassistant/components/xbee/switch.py similarity index 50% rename from homeassistant/components/zigbee/switch.py rename to homeassistant/components/xbee/switch.py index f5b73f5d328..cdb0d2677c5 100644 --- a/homeassistant/components/zigbee/switch.py +++ b/homeassistant/components/xbee/switch.py @@ -1,9 +1,9 @@ -"""Support for Zigbee switches.""" +"""Support for XBee Zigbee switches.""" import voluptuous as vol from homeassistant.components.switch import SwitchEntity -from . import DOMAIN, PLATFORM_SCHEMA, ZigBeeDigitalOut, ZigBeeDigitalOutConfig +from . import DOMAIN, PLATFORM_SCHEMA, XBeeDigitalOut, XBeeDigitalOutConfig CONF_ON_STATE = "on_state" @@ -15,10 +15,10 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_ON_STATE): vol.In(ST def setup_platform(hass, config, add_entities, discovery_info=None): - """Set up the Zigbee switch platform.""" + """Set up the XBee Zigbee switch platform.""" zigbee_device = hass.data[DOMAIN] - add_entities([ZigBeeSwitch(ZigBeeDigitalOutConfig(config), zigbee_device)]) + add_entities([XBeeSwitch(XBeeDigitalOutConfig(config), zigbee_device)]) -class ZigBeeSwitch(ZigBeeDigitalOut, SwitchEntity): - """Representation of a Zigbee Digital Out device.""" +class XBeeSwitch(XBeeDigitalOut, SwitchEntity): + """Representation of a XBee Zigbee Digital Out device.""" diff --git a/homeassistant/components/zigbee/manifest.json b/homeassistant/components/zigbee/manifest.json deleted file mode 100644 index 6940aaef7dc..00000000000 --- a/homeassistant/components/zigbee/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "domain": "zigbee", - "name": "Zigbee", - "documentation": "https://www.home-assistant.io/integrations/zigbee", - "requirements": ["xbee-helper==0.0.7"], - "codeowners": [] -} diff --git a/requirements_all.txt b/requirements_all.txt index a4b01b38b3a..7c6b6d8b7a8 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2194,7 +2194,7 @@ wled==0.3.0 # homeassistant.components.wunderlist wunderpy2==0.1.6 -# homeassistant.components.zigbee +# homeassistant.components.xbee xbee-helper==0.0.7 # homeassistant.components.xbox_live