mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Switchbot nightlatch feature (#98620)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
6e8b3837b0
commit
d7d989b9fb
@ -4,7 +4,7 @@ from typing import Any
|
||||
import switchbot
|
||||
from switchbot.const import LockStatus
|
||||
|
||||
from homeassistant.components.lock import LockEntity
|
||||
from homeassistant.components.lock import LockEntity, LockEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -34,6 +34,8 @@ class SwitchBotLock(SwitchbotEntity, LockEntity):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator)
|
||||
self._async_update_attrs()
|
||||
if self._device.is_night_latch_enabled():
|
||||
self._attr_supported_features = LockEntityFeature.OPEN
|
||||
|
||||
def _async_update_attrs(self) -> None:
|
||||
"""Update the entity attributes."""
|
||||
@ -53,5 +55,13 @@ class SwitchBotLock(SwitchbotEntity, LockEntity):
|
||||
|
||||
async def async_unlock(self, **kwargs: Any) -> None:
|
||||
"""Unlock the lock."""
|
||||
if self._device.is_night_latch_enabled():
|
||||
self._last_run_success = await self._device.unlock_without_unlatch()
|
||||
else:
|
||||
self._last_run_success = await self._device.unlock()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_open(self, **kwargs: Any) -> None:
|
||||
"""Open the lock."""
|
||||
self._last_run_success = await self._device.unlock()
|
||||
self.async_write_ha_state()
|
||||
|
@ -39,5 +39,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/switchbot",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["switchbot"],
|
||||
"requirements": ["PySwitchbot==0.38.0"]
|
||||
"requirements": ["PySwitchbot==0.39.1"]
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ PyRMVtransport==0.3.3
|
||||
PySocks==1.7.1
|
||||
|
||||
# homeassistant.components.switchbot
|
||||
PySwitchbot==0.38.0
|
||||
PySwitchbot==0.39.1
|
||||
|
||||
# homeassistant.components.switchmate
|
||||
PySwitchmate==0.5.1
|
||||
|
@ -86,7 +86,7 @@ PyRMVtransport==0.3.3
|
||||
PySocks==1.7.1
|
||||
|
||||
# homeassistant.components.switchbot
|
||||
PySwitchbot==0.38.0
|
||||
PySwitchbot==0.39.1
|
||||
|
||||
# homeassistant.components.syncthru
|
||||
PySyncThru==0.7.10
|
||||
|
Loading…
x
Reference in New Issue
Block a user