Switchbot nightlatch feature (#98620)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Michal Jál 2023-08-30 06:03:08 +02:00 committed by GitHub
parent 6e8b3837b0
commit d7d989b9fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -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()

View File

@ -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"]
}

View File

@ -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

View File

@ -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