2019-10-13 18:01:04 +00:00
|
|
|
"""Support for the Abode Security System locks."""
|
2019-10-12 20:02:12 +00:00
|
|
|
import abodepy.helpers.constants as CONST
|
|
|
|
|
2017-08-29 15:34:19 +00:00
|
|
|
from homeassistant.components.lock import LockDevice
|
|
|
|
|
2019-10-13 18:01:04 +00:00
|
|
|
from . import AbodeDevice
|
|
|
|
from .const import DOMAIN
|
2019-03-21 05:56:46 +00:00
|
|
|
|
2017-08-29 15:34:19 +00:00
|
|
|
|
2019-10-13 18:01:04 +00:00
|
|
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Set up Abode lock devices."""
|
2019-10-13 18:01:04 +00:00
|
|
|
data = hass.data[DOMAIN]
|
2017-08-29 15:34:19 +00:00
|
|
|
|
2019-11-09 06:35:45 +00:00
|
|
|
entities = []
|
|
|
|
|
2017-09-18 15:39:41 +00:00
|
|
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_LOCK):
|
2019-11-09 06:35:45 +00:00
|
|
|
entities.append(AbodeLock(data, device))
|
2017-09-18 15:39:41 +00:00
|
|
|
|
2019-11-09 06:35:45 +00:00
|
|
|
async_add_entities(entities)
|
2017-08-29 15:34:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AbodeLock(AbodeDevice, LockDevice):
|
|
|
|
"""Representation of an Abode lock."""
|
|
|
|
|
|
|
|
def lock(self, **kwargs):
|
|
|
|
"""Lock the device."""
|
|
|
|
self._device.lock()
|
|
|
|
|
|
|
|
def unlock(self, **kwargs):
|
|
|
|
"""Unlock the device."""
|
|
|
|
self._device.unlock()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_locked(self):
|
|
|
|
"""Return true if device is on."""
|
|
|
|
return self._device.is_locked
|