mirror of
https://github.com/home-assistant/core
synced 2024-08-02 23:40:32 +02: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 fiblary3.client.v4.models import DeviceModel, SceneModel
|
||||
|
||||
from homeassistant.components.lock import ENTITY_ID_FORMAT, LockEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
@ -33,27 +35,21 @@ async def async_setup_entry(
|
||||
class FibaroLock(FibaroDevice, LockEntity):
|
||||
"""Representation of a Fibaro Lock."""
|
||||
|
||||
def __init__(self, fibaro_device):
|
||||
def __init__(self, fibaro_device: DeviceModel | SceneModel) -> None:
|
||||
"""Initialize the Fibaro device."""
|
||||
self._state = False
|
||||
super().__init__(fibaro_device)
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
||||
|
||||
def lock(self, **kwargs: Any) -> None:
|
||||
"""Lock the device."""
|
||||
self.action("secure")
|
||||
self._state = True
|
||||
self._attr_is_locked = True
|
||||
|
||||
def unlock(self, **kwargs: Any) -> None:
|
||||
"""Unlock the device."""
|
||||
self.action("unsecure")
|
||||
self._state = False
|
||||
self._attr_is_locked = False
|
||||
|
||||
@property
|
||||
def is_locked(self) -> bool:
|
||||
"""Return true if device is locked."""
|
||||
return self._state
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update device state."""
|
||||
self._state = self.current_binary_state
|
||||
self._attr_is_locked = self.current_binary_state
|
||||
|
Loading…
Reference in New Issue
Block a user