Add basic lock support for fibaro (#38962)
Added very basic support for locks in the Fibaro integration.pull/39372/head
parent
989a040b67
commit
6348f130bc
|
@ -44,6 +44,7 @@ FIBARO_COMPONENTS = [
|
|||
"light",
|
||||
"scene",
|
||||
"sensor",
|
||||
"lock",
|
||||
"switch",
|
||||
]
|
||||
|
||||
|
@ -67,6 +68,7 @@ FIBARO_TYPEMAP = {
|
|||
"com.fibaro.setpoint": "climate",
|
||||
"com.fibaro.FGT001": "climate",
|
||||
"com.fibaro.thermostatDanfoss": "climate",
|
||||
"com.fibaro.doorLock": "lock",
|
||||
}
|
||||
|
||||
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema(
|
||||
|
@ -220,6 +222,8 @@ class FibaroController:
|
|||
device_type = "switch"
|
||||
elif "open" in device.actions:
|
||||
device_type = "cover"
|
||||
elif "secure" in device.actions:
|
||||
device_type = "lock"
|
||||
elif "value" in device.properties:
|
||||
if device.properties.value in ("true", "false"):
|
||||
device_type = "binary_sensor"
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
"""Support for Fibaro locks."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.lock import DOMAIN, LockEntity
|
||||
|
||||
from . import FIBARO_DEVICES, FibaroDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Fibaro locks."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
add_entities(
|
||||
[FibaroLock(device) for device in hass.data[FIBARO_DEVICES]["lock"]], True
|
||||
)
|
||||
|
||||
|
||||
class FibaroLock(FibaroDevice, LockEntity):
|
||||
"""Representation of a Fibaro Lock."""
|
||||
|
||||
def __init__(self, fibaro_device):
|
||||
"""Initialize the Fibaro device."""
|
||||
self._state = False
|
||||
super().__init__(fibaro_device)
|
||||
self.entity_id = f"{DOMAIN}.{self.ha_id}"
|
||||
|
||||
def lock(self, **kwargs):
|
||||
"""Lock the device."""
|
||||
self.action("secure")
|
||||
self._state = True
|
||||
|
||||
def unlock(self, **kwargs):
|
||||
"""Unlock the device."""
|
||||
self.action("unsecure")
|
||||
self._state = False
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
"""Return true if device is locked."""
|
||||
return self._state
|
||||
|
||||
def update(self):
|
||||
"""Update device state."""
|
||||
self._state = self.current_binary_state
|
Loading…
Reference in New Issue