mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Code cleanup fibaro lock (#73389)
* Code cleanup fibaro lock * Adjust typings as suggested in code review
This commit is contained in:
parent
9d13252142
commit
4813e6e420
@ -3,6 +3,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from fiblary3.client.v4.models import DeviceModel, SceneModel
|
||||||
|
|
||||||
from homeassistant.components.lock import ENTITY_ID_FORMAT, LockEntity
|
from homeassistant.components.lock import ENTITY_ID_FORMAT, LockEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
@ -33,27 +35,21 @@ async def async_setup_entry(
|
|||||||
class FibaroLock(FibaroDevice, LockEntity):
|
class FibaroLock(FibaroDevice, LockEntity):
|
||||||
"""Representation of a Fibaro Lock."""
|
"""Representation of a Fibaro Lock."""
|
||||||
|
|
||||||
def __init__(self, fibaro_device):
|
def __init__(self, fibaro_device: DeviceModel | SceneModel) -> None:
|
||||||
"""Initialize the Fibaro device."""
|
"""Initialize the Fibaro device."""
|
||||||
self._state = False
|
|
||||||
super().__init__(fibaro_device)
|
super().__init__(fibaro_device)
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
||||||
|
|
||||||
def lock(self, **kwargs: Any) -> None:
|
def lock(self, **kwargs: Any) -> None:
|
||||||
"""Lock the device."""
|
"""Lock the device."""
|
||||||
self.action("secure")
|
self.action("secure")
|
||||||
self._state = True
|
self._attr_is_locked = True
|
||||||
|
|
||||||
def unlock(self, **kwargs: Any) -> None:
|
def unlock(self, **kwargs: Any) -> None:
|
||||||
"""Unlock the device."""
|
"""Unlock the device."""
|
||||||
self.action("unsecure")
|
self.action("unsecure")
|
||||||
self._state = False
|
self._attr_is_locked = False
|
||||||
|
|
||||||
@property
|
def update(self) -> None:
|
||||||
def is_locked(self) -> bool:
|
|
||||||
"""Return true if device is locked."""
|
|
||||||
return self._state
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
self._state = self.current_binary_state
|
self._attr_is_locked = self.current_binary_state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user