From 4813e6e42068b01173b015331aef8da1bcfcc784 Mon Sep 17 00:00:00 2001 From: rappenze Date: Tue, 21 Jun 2022 09:55:08 +0200 Subject: [PATCH] Code cleanup fibaro lock (#73389) * Code cleanup fibaro lock * Adjust typings as suggested in code review --- homeassistant/components/fibaro/lock.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/fibaro/lock.py b/homeassistant/components/fibaro/lock.py index ac4ce658b65..e8fc4ca7180 100644 --- a/homeassistant/components/fibaro/lock.py +++ b/homeassistant/components/fibaro/lock.py @@ -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