diff --git a/homeassistant/components/august/manifest.json b/homeassistant/components/august/manifest.json index a6b2961c2a0..9dc66084a45 100644 --- a/homeassistant/components/august/manifest.json +++ b/homeassistant/components/august/manifest.json @@ -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"] } diff --git a/homeassistant/components/yale/manifest.json b/homeassistant/components/yale/manifest.json index 4d9ea9ec2c9..fee5b0b8310 100644 --- a/homeassistant/components/yale/manifest.json +++ b/homeassistant/components/yale/manifest.json @@ -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"] } diff --git a/homeassistant/components/yalexs_ble/__init__.py b/homeassistant/components/yalexs_ble/__init__.py index c5183623660..68d64494e41 100644 --- a/homeassistant/components/yalexs_ble/__init__.py +++ b/homeassistant/components/yalexs_ble/__init__.py @@ -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: diff --git a/homeassistant/components/yalexs_ble/icons.json b/homeassistant/components/yalexs_ble/icons.json new file mode 100644 index 00000000000..0b4929cd778 --- /dev/null +++ b/homeassistant/components/yalexs_ble/icons.json @@ -0,0 +1,11 @@ +{ + "entity": { + "lock": { + "secure_mode": { + "state": { + "locked": "mdi:shield-lock" + } + } + } + } +} diff --git a/homeassistant/components/yalexs_ble/lock.py b/homeassistant/components/yalexs_ble/lock.py index 78b92ab9eb1..3d822714fb5 100644 --- a/homeassistant/components/yalexs_ble/lock.py +++ b/homeassistant/components/yalexs_ble/lock.py @@ -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() diff --git a/homeassistant/components/yalexs_ble/manifest.json b/homeassistant/components/yalexs_ble/manifest.json index 2387f5dc15f..b3021bd908e 100644 --- a/homeassistant/components/yalexs_ble/manifest.json +++ b/homeassistant/components/yalexs_ble/manifest.json @@ -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"] } diff --git a/homeassistant/components/yalexs_ble/strings.json b/homeassistant/components/yalexs_ble/strings.json index c79830be3a9..92d807d01f6 100644 --- a/homeassistant/components/yalexs_ble/strings.json +++ b/homeassistant/components/yalexs_ble/strings.json @@ -51,6 +51,11 @@ "battery_voltage": { "name": "Battery voltage" } + }, + "lock": { + "secure_mode": { + "name": "Secure mode" + } } } } diff --git a/requirements_all.txt b/requirements_all.txt index d1a2c2a21ef..8749d653a2f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b4bc9a82158..9e98ca26b18 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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