diff --git a/homeassistant/components/binary_sensor/zigbee.py b/homeassistant/components/binary_sensor/zigbee.py index 8fccb777e9b..72b2499b190 100644 --- a/homeassistant/components/binary_sensor/zigbee.py +++ b/homeassistant/components/binary_sensor/zigbee.py @@ -3,6 +3,8 @@ homeassistant.components.binary_sensor.zigbee Contains functionality to use a ZigBee device as a binary sensor. """ + +from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.zigbee import ( ZigBeeDigitalIn, ZigBeeDigitalInConfig) @@ -15,5 +17,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None): Create and add an entity based on the configuration. """ add_entities([ - ZigBeeDigitalIn(hass, ZigBeeDigitalInConfig(config)) + ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config)) ]) + + +class ZigBeeBinarySensor(ZigBeeDigitalIn, BinarySensorDevice): + """ + Use multiple inheritance to turn a ZigBeeDigitalIn into a + BinarySensorDevice. + """ + pass diff --git a/homeassistant/components/light/zigbee.py b/homeassistant/components/light/zigbee.py index 1d846ce89a8..6e1831d79bd 100644 --- a/homeassistant/components/light/zigbee.py +++ b/homeassistant/components/light/zigbee.py @@ -3,6 +3,8 @@ homeassistant.components.light.zigbee Contains functionality to use a ZigBee device as a light. """ + +from homeassistant.components.light import Light from homeassistant.components.zigbee import ( ZigBeeDigitalOut, ZigBeeDigitalOutConfig) @@ -15,5 +17,13 @@ def setup_platform(hass, config, add_entities, discovery_info=None): Create and add an entity based on the configuration. """ add_entities([ - ZigBeeDigitalOut(hass, ZigBeeDigitalOutConfig(config)) + ZigBeeLight(hass, ZigBeeDigitalOutConfig(config)) ]) + + +class ZigBeeLight(ZigBeeDigitalOut, Light): + """ + Use multiple inheritance to turn an instance of ZigBeeDigitalOut into a + Light. + """ + pass diff --git a/homeassistant/components/sensor/zigbee.py b/homeassistant/components/sensor/zigbee.py index 732e4e97792..33d4f72ed76 100644 --- a/homeassistant/components/sensor/zigbee.py +++ b/homeassistant/components/sensor/zigbee.py @@ -60,7 +60,8 @@ class ZigBeeTemperatureSensor(Entity): def update(self, *args): self._temp = zigbee.DEVICE.get_temperature(self._config.address) -# This must be below the ZigBeeTemperatureSensor which it references. + +# This must be below the classes to which it refers. TYPE_CLASSES = { "temperature": (ZigBeeTemperatureSensor, zigbee.ZigBeeConfig), "analog": (zigbee.ZigBeeAnalogIn, zigbee.ZigBeeAnalogInConfig) diff --git a/homeassistant/components/switch/zigbee.py b/homeassistant/components/switch/zigbee.py index 7e13593a94e..3570db8f2ed 100644 --- a/homeassistant/components/switch/zigbee.py +++ b/homeassistant/components/switch/zigbee.py @@ -3,6 +3,8 @@ homeassistant.components.switch.zigbee Contains functionality to use a ZigBee device as a switch. """ + +from homeassistant.components.switch import SwitchDevice from homeassistant.components.zigbee import ( ZigBeeDigitalOut, ZigBeeDigitalOutConfig) @@ -15,5 +17,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None): Create and add an entity based on the configuration. """ add_entities([ - ZigBeeDigitalOut(hass, ZigBeeDigitalOutConfig(config)) + ZigBeeSwitch(hass, ZigBeeDigitalOutConfig(config)) ]) + + +class ZigBeeSwitch(ZigBeeDigitalOut, SwitchDevice): + """ + Use multiple inheritance to turn a ZigBeeDigitalOut into a SwitchDevice. + """ + pass diff --git a/homeassistant/components/zigbee.py b/homeassistant/components/zigbee.py index 41a9d02f014..2d7c87d7e5f 100644 --- a/homeassistant/components/zigbee.py +++ b/homeassistant/components/zigbee.py @@ -10,8 +10,8 @@ import logging from binascii import unhexlify from homeassistant.core import JobPriority -from homeassistant.const import EVENT_HOMEASSISTANT_STOP, STATE_ON, STATE_OFF -from homeassistant.helpers.entity import Entity, ToggleEntity +from homeassistant.const import EVENT_HOMEASSISTANT_STOP +from homeassistant.helpers.entity import Entity DOMAIN = "zigbee" @@ -194,7 +194,7 @@ class ZigBeeAnalogInConfig(ZigBeePinConfig): class ZigBeeDigitalIn(Entity): """ - ToggleEntity to represent a GPIO pin configured as a digital input. + Represents a GPIO pin configured as a digital input. """ def __init__(self, hass, config): self._config = config @@ -211,12 +211,11 @@ class ZigBeeDigitalIn(Entity): def should_poll(self): return self._config.should_poll - @property - def state(self): - return STATE_ON if self.is_on else STATE_OFF - @property def is_on(self): + """ + Returns True if the Entity is on, else False. + """ return self._state def update(self): @@ -229,7 +228,7 @@ class ZigBeeDigitalIn(Entity): self._state = self._config.state2bool[pin_state] -class ZigBeeDigitalOut(ZigBeeDigitalIn, ToggleEntity): +class ZigBeeDigitalOut(ZigBeeDigitalIn): """ Adds functionality to ZigBeeDigitalIn to control an output. """ @@ -243,15 +242,21 @@ class ZigBeeDigitalOut(ZigBeeDigitalIn, ToggleEntity): self.update_ha_state() def turn_on(self, **kwargs): + """ + Set the digital output to its 'on' state. + """ self._set_state(True) def turn_off(self, **kwargs): + """ + Set the digital output to its 'off' state. + """ self._set_state(False) class ZigBeeAnalogIn(Entity): """ - Entity to represent a GPIO pin configured as an analog input. + Represents a GPIO pin configured as an analog input. """ def __init__(self, hass, config): self._config = config