Add Deadlock (SecureMode) support to the Yale Access Bluetooth integration (#144107)

Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Michael Podhorodecki 2025-07-05 07:07:13 +10:00 committed by GitHub
parent 9a5cbe483b
commit ca85ffc068
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 58 additions and 10 deletions

View File

@ -28,5 +28,5 @@
"documentation": "https://www.home-assistant.io/integrations/august", "documentation": "https://www.home-assistant.io/integrations/august",
"iot_class": "cloud_push", "iot_class": "cloud_push",
"loggers": ["pubnub", "yalexs"], "loggers": ["pubnub", "yalexs"],
"requirements": ["yalexs==8.10.0", "yalexs-ble==2.6.0"] "requirements": ["yalexs==8.10.0", "yalexs-ble==3.0.0"]
} }

View File

@ -13,5 +13,5 @@
"documentation": "https://www.home-assistant.io/integrations/yale", "documentation": "https://www.home-assistant.io/integrations/yale",
"iot_class": "cloud_push", "iot_class": "cloud_push",
"loggers": ["socketio", "engineio", "yalexs"], "loggers": ["socketio", "engineio", "yalexs"],
"requirements": ["yalexs==8.10.0", "yalexs-ble==2.6.0"] "requirements": ["yalexs==8.10.0", "yalexs-ble==3.0.0"]
} }

View File

@ -32,7 +32,11 @@ from .util import async_find_existing_service_info, bluetooth_callback_matcher
type YALEXSBLEConfigEntry = ConfigEntry[YaleXSBLEData] type YALEXSBLEConfigEntry = ConfigEntry[YaleXSBLEData]
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.LOCK, Platform.SENSOR] PLATFORMS: list[Platform] = [
Platform.BINARY_SENSOR,
Platform.LOCK,
Platform.SENSOR,
]
async def async_setup_entry(hass: HomeAssistant, entry: YALEXSBLEConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: YALEXSBLEConfigEntry) -> bool:

View File

@ -0,0 +1,11 @@
{
"entity": {
"lock": {
"secure_mode": {
"state": {
"locked": "mdi:shield-lock"
}
}
}
}
}

View File

@ -12,6 +12,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import YALEXSBLEConfigEntry from . import YALEXSBLEConfigEntry
from .entity import YALEXSBLEEntity from .entity import YALEXSBLEEntity
from .models import YaleXSBLEData
async def async_setup_entry( async def async_setup_entry(
@ -20,13 +21,15 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback, async_add_entities: AddConfigEntryEntitiesCallback,
) -> None: ) -> None:
"""Set up locks.""" """Set up locks."""
async_add_entities([YaleXSBLELock(entry.runtime_data)]) async_add_entities(
[YaleXSBLELock(entry.runtime_data), YaleXSBLESecureModeLock(entry.runtime_data)]
)
class YaleXSBLELock(YALEXSBLEEntity, LockEntity): class YaleXSBLEBaseLock(YALEXSBLEEntity, LockEntity):
"""A yale xs ble lock.""" """A yale xs ble lock."""
_attr_name = None _secure_mode: bool = False
@callback @callback
def _async_update_state( def _async_update_state(
@ -39,11 +42,13 @@ class YaleXSBLELock(YALEXSBLEEntity, LockEntity):
self._attr_is_jammed = False self._attr_is_jammed = False
lock_state = new_state.lock lock_state = new_state.lock
if lock_state is LockStatus.LOCKED: if lock_state is LockStatus.LOCKED:
self._attr_is_locked = True self._attr_is_locked = not self._secure_mode
elif lock_state is LockStatus.LOCKING: elif lock_state is LockStatus.LOCKING:
self._attr_is_locking = True self._attr_is_locking = True
elif lock_state is LockStatus.UNLOCKING: elif lock_state is LockStatus.UNLOCKING:
self._attr_is_unlocking = True self._attr_is_unlocking = True
elif lock_state is LockStatus.SECUREMODE:
self._attr_is_locked = True
elif lock_state in ( elif lock_state in (
LockStatus.UNKNOWN_01, LockStatus.UNKNOWN_01,
LockStatus.UNKNOWN_06, LockStatus.UNKNOWN_06,
@ -57,6 +62,29 @@ class YaleXSBLELock(YALEXSBLEEntity, LockEntity):
"""Unlock the lock.""" """Unlock the lock."""
await self._device.unlock() await self._device.unlock()
class YaleXSBLELock(YaleXSBLEBaseLock, LockEntity):
"""A yale xs ble lock not in secure mode."""
_attr_name = None
async def async_lock(self, **kwargs: Any) -> None: async def async_lock(self, **kwargs: Any) -> None:
"""Lock the lock.""" """Lock the lock."""
await self._device.lock() await self._device.lock()
class YaleXSBLESecureModeLock(YaleXSBLEBaseLock):
"""A yale xs ble lock in secure mode."""
_attr_entity_registry_enabled_default = False
_attr_translation_key = "secure_mode"
_secure_mode = True
def __init__(self, data: YaleXSBLEData) -> None:
"""Initialize the entity."""
super().__init__(data)
self._attr_unique_id = f"{self._device.address}_secure_mode"
async def async_lock(self, **kwargs: Any) -> None:
"""Lock the lock."""
await self._device.securemode()

View File

@ -12,5 +12,5 @@
"dependencies": ["bluetooth_adapters"], "dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/yalexs_ble", "documentation": "https://www.home-assistant.io/integrations/yalexs_ble",
"iot_class": "local_push", "iot_class": "local_push",
"requirements": ["yalexs-ble==2.6.0"] "requirements": ["yalexs-ble==3.0.0"]
} }

View File

@ -51,6 +51,11 @@
"battery_voltage": { "battery_voltage": {
"name": "Battery voltage" "name": "Battery voltage"
} }
},
"lock": {
"secure_mode": {
"name": "Secure mode"
}
} }
} }
} }

2
requirements_all.txt generated
View File

@ -3150,7 +3150,7 @@ yalesmartalarmclient==0.4.3
# homeassistant.components.august # homeassistant.components.august
# homeassistant.components.yale # homeassistant.components.yale
# homeassistant.components.yalexs_ble # homeassistant.components.yalexs_ble
yalexs-ble==2.6.0 yalexs-ble==3.0.0
# homeassistant.components.august # homeassistant.components.august
# homeassistant.components.yale # homeassistant.components.yale

View File

@ -2600,7 +2600,7 @@ yalesmartalarmclient==0.4.3
# homeassistant.components.august # homeassistant.components.august
# homeassistant.components.yale # homeassistant.components.yale
# homeassistant.components.yalexs_ble # homeassistant.components.yalexs_ble
yalexs-ble==2.6.0 yalexs-ble==3.0.0
# homeassistant.components.august # homeassistant.components.august
# homeassistant.components.yale # homeassistant.components.yale