mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
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:
parent
9a5cbe483b
commit
ca85ffc068
@ -28,5 +28,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/august",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["pubnub", "yalexs"],
|
||||
"requirements": ["yalexs==8.10.0", "yalexs-ble==2.6.0"]
|
||||
"requirements": ["yalexs==8.10.0", "yalexs-ble==3.0.0"]
|
||||
}
|
||||
|
@ -13,5 +13,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/yale",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["socketio", "engineio", "yalexs"],
|
||||
"requirements": ["yalexs==8.10.0", "yalexs-ble==2.6.0"]
|
||||
"requirements": ["yalexs==8.10.0", "yalexs-ble==3.0.0"]
|
||||
}
|
||||
|
@ -32,7 +32,11 @@ from .util import async_find_existing_service_info, bluetooth_callback_matcher
|
||||
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:
|
||||
|
11
homeassistant/components/yalexs_ble/icons.json
Normal file
11
homeassistant/components/yalexs_ble/icons.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"entity": {
|
||||
"lock": {
|
||||
"secure_mode": {
|
||||
"state": {
|
||||
"locked": "mdi:shield-lock"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import YALEXSBLEConfigEntry
|
||||
from .entity import YALEXSBLEEntity
|
||||
from .models import YaleXSBLEData
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
@ -20,13 +21,15 @@ async def async_setup_entry(
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""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."""
|
||||
|
||||
_attr_name = None
|
||||
_secure_mode: bool = False
|
||||
|
||||
@callback
|
||||
def _async_update_state(
|
||||
@ -39,11 +42,13 @@ class YaleXSBLELock(YALEXSBLEEntity, LockEntity):
|
||||
self._attr_is_jammed = False
|
||||
lock_state = new_state.lock
|
||||
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:
|
||||
self._attr_is_locking = True
|
||||
elif lock_state is LockStatus.UNLOCKING:
|
||||
self._attr_is_unlocking = True
|
||||
elif lock_state is LockStatus.SECUREMODE:
|
||||
self._attr_is_locked = True
|
||||
elif lock_state in (
|
||||
LockStatus.UNKNOWN_01,
|
||||
LockStatus.UNKNOWN_06,
|
||||
@ -57,6 +62,29 @@ class YaleXSBLELock(YALEXSBLEEntity, LockEntity):
|
||||
"""Unlock the lock."""
|
||||
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:
|
||||
"""Lock the 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()
|
||||
|
@ -12,5 +12,5 @@
|
||||
"dependencies": ["bluetooth_adapters"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/yalexs_ble",
|
||||
"iot_class": "local_push",
|
||||
"requirements": ["yalexs-ble==2.6.0"]
|
||||
"requirements": ["yalexs-ble==3.0.0"]
|
||||
}
|
||||
|
@ -51,6 +51,11 @@
|
||||
"battery_voltage": {
|
||||
"name": "Battery voltage"
|
||||
}
|
||||
},
|
||||
"lock": {
|
||||
"secure_mode": {
|
||||
"name": "Secure mode"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -3150,7 +3150,7 @@ yalesmartalarmclient==0.4.3
|
||||
# homeassistant.components.august
|
||||
# homeassistant.components.yale
|
||||
# homeassistant.components.yalexs_ble
|
||||
yalexs-ble==2.6.0
|
||||
yalexs-ble==3.0.0
|
||||
|
||||
# homeassistant.components.august
|
||||
# homeassistant.components.yale
|
||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -2600,7 +2600,7 @@ yalesmartalarmclient==0.4.3
|
||||
# homeassistant.components.august
|
||||
# homeassistant.components.yale
|
||||
# homeassistant.components.yalexs_ble
|
||||
yalexs-ble==2.6.0
|
||||
yalexs-ble==3.0.0
|
||||
|
||||
# homeassistant.components.august
|
||||
# homeassistant.components.yale
|
||||
|
Loading…
x
Reference in New Issue
Block a user