mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 02:19:31 +00:00
Wink AC and addidtional sensor support (#5670)
* Added door bell sensors * Initial support for AC units. * Added new device service * Quirky Aros AC unit support * Use super() everywhere and error checking for token request. * Ignore camera sensors during setup of alarms. * Added manufacturer/device attributes to all wink devices. * Fixed style errors * Fixed remaining lint errors.
This commit is contained in:
committed by
Paulus Schoutsen
parent
b5f285a789
commit
80a794e587
@@ -4,11 +4,14 @@ Support for Wink binary sensors.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
at https://home-assistant.io/components/binary_sensor.wink/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.components.sensor.wink import WinkDevice
|
||||
from homeassistant.components.wink import WinkDevice, DOMAIN
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['wink']
|
||||
|
||||
# These are the available sensors mapped to binary_sensor class
|
||||
@@ -17,11 +20,14 @@ SENSOR_TYPES = {
|
||||
"brightness": "light",
|
||||
"vibration": "vibration",
|
||||
"loudness": "sound",
|
||||
"noise": "sound",
|
||||
"capturing_audio": "sound",
|
||||
"liquid_detected": "moisture",
|
||||
"motion": "motion",
|
||||
"presence": "occupancy",
|
||||
"co_detected": "gas",
|
||||
"smoke_detected": "smoke"
|
||||
"smoke_detected": "smoke",
|
||||
"capturing_video": None
|
||||
}
|
||||
|
||||
|
||||
@@ -30,26 +36,54 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
import pywink
|
||||
|
||||
for sensor in pywink.get_sensors():
|
||||
if sensor.capability() in SENSOR_TYPES:
|
||||
add_devices([WinkBinarySensorDevice(sensor, hass)])
|
||||
_id = sensor.object_id() + sensor.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
if sensor.capability() in SENSOR_TYPES:
|
||||
add_devices([WinkBinarySensorDevice(sensor, hass)])
|
||||
|
||||
for key in pywink.get_keys():
|
||||
add_devices([WinkBinarySensorDevice(key, hass)])
|
||||
_id = key.object_id() + key.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkBinarySensorDevice(key, hass)])
|
||||
|
||||
for sensor in pywink.get_smoke_and_co_detectors():
|
||||
add_devices([WinkBinarySensorDevice(sensor, hass)])
|
||||
_id = sensor.object_id() + sensor.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkSmokeDetector(sensor, hass)])
|
||||
|
||||
for hub in pywink.get_hubs():
|
||||
add_devices([WinkHub(hub, hass)])
|
||||
_id = hub.object_id() + hub.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkHub(hub, hass)])
|
||||
|
||||
for remote in pywink.get_remotes():
|
||||
add_devices([WinkRemote(remote, hass)])
|
||||
_id = remote.object_id() + remote.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkRemote(remote, hass)])
|
||||
|
||||
for button in pywink.get_buttons():
|
||||
add_devices([WinkButton(button, hass)])
|
||||
_id = button.object_id() + button.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkButton(button, hass)])
|
||||
|
||||
for gang in pywink.get_gangs():
|
||||
add_devices([WinkGang(gang, hass)])
|
||||
_id = gang.object_id() + gang.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkGang(gang, hass)])
|
||||
|
||||
for door_bell_sensor in pywink.get_door_bells():
|
||||
_id = door_bell_sensor.object_id() + door_bell_sensor.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
add_devices([WinkBinarySensorDevice(door_bell_sensor, hass)])
|
||||
|
||||
for camera_sensor in pywink.get_cameras():
|
||||
_id = camera_sensor.object_id() + camera_sensor.name()
|
||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||
try:
|
||||
if camera_sensor.capability() in SENSOR_TYPES:
|
||||
add_devices([WinkBinarySensorDevice(camera_sensor, hass)])
|
||||
except AttributeError:
|
||||
_LOGGER.info("Device isn't a sensor, skipping.")
|
||||
|
||||
|
||||
class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
||||
@@ -58,8 +92,14 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
self._unit_of_measurement = self.wink.unit()
|
||||
self.capability = self.wink.capability()
|
||||
try:
|
||||
self._unit_of_measurement = self.wink.unit()
|
||||
except AttributeError:
|
||||
self._unit_of_measurement = None
|
||||
try:
|
||||
self.capability = self.wink.capability()
|
||||
except AttributeError:
|
||||
self.capability = None
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
@@ -72,17 +112,27 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
||||
return SENSOR_TYPES.get(self.capability)
|
||||
|
||||
|
||||
class WinkHub(WinkDevice, BinarySensorDevice, Entity):
|
||||
"""Representation of a Wink Hub."""
|
||||
class WinkSmokeDetector(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Smoke detector."""
|
||||
|
||||
def __init(self, wink, hass):
|
||||
"""Initialize the hub sensor."""
|
||||
WinkDevice.__init__(self, wink, hass)
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.wink.state()
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {
|
||||
'test_activated': self.wink.test_activated()
|
||||
}
|
||||
|
||||
|
||||
class WinkHub(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Hub."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
@@ -93,17 +143,12 @@ class WinkHub(WinkDevice, BinarySensorDevice, Entity):
|
||||
}
|
||||
|
||||
|
||||
class WinkRemote(WinkDevice, BinarySensorDevice, Entity):
|
||||
class WinkRemote(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Lutron Connected bulb remote."""
|
||||
|
||||
def __init(self, wink, hass):
|
||||
"""Initialize the hub sensor."""
|
||||
WinkDevice.__init__(self, wink, hass)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.wink.state()
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
@@ -115,18 +160,18 @@ class WinkRemote(WinkDevice, BinarySensorDevice, Entity):
|
||||
'button_down_pressed': self.wink.button_down_pressed()
|
||||
}
|
||||
|
||||
@property
|
||||
def sensor_class(self):
|
||||
"""Return the class of this sensor, from SENSOR_CLASSES."""
|
||||
return None
|
||||
|
||||
class WinkButton(WinkDevice, BinarySensorDevice, Entity):
|
||||
|
||||
class WinkButton(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Relay button."""
|
||||
|
||||
def __init(self, wink, hass):
|
||||
"""Initialize the hub sensor."""
|
||||
WinkDevice.__init__(self, wink, hass)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.wink.state()
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
@@ -137,12 +182,12 @@ class WinkButton(WinkDevice, BinarySensorDevice, Entity):
|
||||
}
|
||||
|
||||
|
||||
class WinkGang(WinkDevice, BinarySensorDevice, Entity):
|
||||
class WinkGang(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Relay gang."""
|
||||
|
||||
def __init(self, wink, hass):
|
||||
"""Initialize the gang sensor."""
|
||||
WinkDevice.__init__(self, wink, hass)
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
||||
Reference in New Issue
Block a user