From 5034371341a7ba469514b96fef19e7acaa3fa679 Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Wed, 11 Oct 2017 20:19:36 -0400 Subject: [PATCH 1/2] Added super attributes to Wink binary sensors --- .../components/binary_sensor/wink.py | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/binary_sensor/wink.py b/homeassistant/components/binary_sensor/wink.py index 05de0b51aa8fa6..96ef371c1cad14 100644 --- a/homeassistant/components/binary_sensor/wink.py +++ b/homeassistant/components/binary_sensor/wink.py @@ -87,7 +87,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): _LOGGER.info("Device isn't a sensor, skipping") -class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity): +class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice): """Representation of a Wink binary sensor.""" def __init__(self, wink, hass): @@ -117,6 +117,11 @@ def device_class(self): """Return the class of this sensor, from DEVICE_CLASSES.""" return SENSOR_TYPES.get(self.capability) + @property + def device_state_attributes(self): + """Return the state attributes.""" + return super().device_state_attributes + class WinkSmokeDetector(WinkBinarySensorDevice): """Representation of a Wink Smoke detector.""" @@ -124,9 +129,9 @@ class WinkSmokeDetector(WinkBinarySensorDevice): @property def device_state_attributes(self): """Return the state attributes.""" - return { - 'test_activated': self.wink.test_activated() - } + _attributes = super().device_state_attributes + _attributes['test_activated'] = self.wink.test_activated() + return _attributes class WinkHub(WinkBinarySensorDevice): @@ -135,11 +140,11 @@ class WinkHub(WinkBinarySensorDevice): @property def device_state_attributes(self): """Return the state attributes.""" - return { - 'update_needed': self.wink.update_needed(), - 'firmware_version': self.wink.firmware_version(), - 'pairing_mode': self.wink.pairing_mode() - } + _attributes = super().device_state_attributes + _attributes['update_needed'] = self.wink.update_needed() + _attributes['firmware_version'] = self.wink.firmware_version() + _attributes['pairing_mode'] = self.wink.pairing_mode() + return _attributes class WinkRemote(WinkBinarySensorDevice): @@ -148,12 +153,12 @@ class WinkRemote(WinkBinarySensorDevice): @property def device_state_attributes(self): """Return the state attributes.""" - return { - 'button_on_pressed': self.wink.button_on_pressed(), - 'button_off_pressed': self.wink.button_off_pressed(), - 'button_up_pressed': self.wink.button_up_pressed(), - 'button_down_pressed': self.wink.button_down_pressed() - } + _attributes = super().device_state_attributes + _attributes['button_on_pressed'] = self.wink.button_on_pressed() + _attributes['button_off_pressed'] = self.wink.button_off_pressed() + _attributes['button_up_pressed'] = self.wink.button_up_pressed() + _attributes['button_down_pressed'] = self.wink.button_down_pressed() + return _attributes @property def device_class(self): @@ -167,10 +172,10 @@ class WinkButton(WinkBinarySensorDevice): @property def device_state_attributes(self): """Return the state attributes.""" - return { - 'pressed': self.wink.pressed(), - 'long_pressed': self.wink.long_pressed() - } + _attributes = super().device_state_attributes + _attributes['pressed'] = self.wink.pressed() + _attributes['long_pressed'] = self.wink.long_pressed() + return _attributes class WinkGang(WinkBinarySensorDevice): From c1bc4e48a371faa93b787be25af91c4cc3c6028f Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Mon, 16 Oct 2017 08:34:59 -0400 Subject: [PATCH 2/2] Removed unused import. --- homeassistant/components/binary_sensor/wink.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/binary_sensor/wink.py b/homeassistant/components/binary_sensor/wink.py index 96ef371c1cad14..e0bf23ecee24f6 100644 --- a/homeassistant/components/binary_sensor/wink.py +++ b/homeassistant/components/binary_sensor/wink.py @@ -9,7 +9,6 @@ from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.wink import WinkDevice, DOMAIN -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__)