2019-02-13 21:21:14 +01:00
|
|
|
"""Support for Abode Security System binary sensors."""
|
2019-10-12 22:02:12 +02:00
|
|
|
import abodepy.helpers.constants as CONST
|
|
|
|
|
2017-08-29 08:34:19 -07:00
|
|
|
from homeassistant.components.binary_sensor import BinarySensorDevice
|
|
|
|
|
2020-03-04 14:54:28 -08:00
|
|
|
from . import AbodeDevice
|
2020-02-23 22:38:05 +01:00
|
|
|
from .const import DOMAIN
|
2019-03-20 22:56:46 -07:00
|
|
|
|
2017-08-20 10:55:48 -04:00
|
|
|
|
2019-10-13 11:01:04 -07:00
|
|
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
2019-11-08 22:35:45 -08:00
|
|
|
"""Set up Abode binary sensor devices."""
|
2019-10-13 11:01:04 -07:00
|
|
|
data = hass.data[DOMAIN]
|
2017-08-20 10:55:48 -04:00
|
|
|
|
2019-07-31 12:25:30 -07:00
|
|
|
device_types = [
|
|
|
|
CONST.TYPE_CONNECTIVITY,
|
|
|
|
CONST.TYPE_MOISTURE,
|
|
|
|
CONST.TYPE_MOTION,
|
|
|
|
CONST.TYPE_OCCUPANCY,
|
|
|
|
CONST.TYPE_OPENING,
|
|
|
|
]
|
2017-08-20 10:55:48 -04:00
|
|
|
|
2019-11-08 22:35:45 -08:00
|
|
|
entities = []
|
2017-08-20 10:55:48 -04:00
|
|
|
|
2019-10-13 11:01:04 -07:00
|
|
|
for device in data.abode.get_devices(generic_type=device_types):
|
2019-11-08 22:35:45 -08:00
|
|
|
entities.append(AbodeBinarySensor(data, device))
|
2017-08-20 10:55:48 -04:00
|
|
|
|
2019-11-08 22:35:45 -08:00
|
|
|
async_add_entities(entities)
|
2017-08-20 10:55:48 -04:00
|
|
|
|
|
|
|
|
2017-08-29 08:34:19 -07:00
|
|
|
class AbodeBinarySensor(AbodeDevice, BinarySensorDevice):
|
|
|
|
"""A binary sensor implementation for Abode device."""
|
|
|
|
|
2017-08-20 10:55:48 -04:00
|
|
|
@property
|
|
|
|
def is_on(self):
|
|
|
|
"""Return True if the binary sensor is on."""
|
2017-08-29 08:34:19 -07:00
|
|
|
return self._device.is_on
|
2017-08-20 10:55:48 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def device_class(self):
|
|
|
|
"""Return the class of the binary sensor."""
|
2017-09-18 08:39:41 -07:00
|
|
|
return self._device.generic_type
|