From 18c1953bc54deb52ccec1a86e003262a709628f1 Mon Sep 17 00:00:00 2001 From: Samuel Xiao <40679757+XiaoLing-git@users.noreply.github.com> Date: Sat, 28 Jun 2025 02:16:21 +0800 Subject: [PATCH] Add lock models to switchbot cloud (#147569) --- homeassistant/components/switchbot_cloud/__init__.py | 7 ++++++- .../components/switchbot_cloud/binary_sensor.py | 9 ++++++++- homeassistant/components/switchbot_cloud/sensor.py | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/switchbot_cloud/__init__.py b/homeassistant/components/switchbot_cloud/__init__.py index 7b7f60589f0..b87a569abda 100644 --- a/homeassistant/components/switchbot_cloud/__init__.py +++ b/homeassistant/components/switchbot_cloud/__init__.py @@ -153,7 +153,12 @@ async def make_device_data( ) devices_data.vacuums.append((device, coordinator)) - if isinstance(device, Device) and device.device_type.startswith("Smart Lock"): + if isinstance(device, Device) and device.device_type in [ + "Smart Lock", + "Smart Lock Lite", + "Smart Lock Pro", + "Smart Lock Ultra", + ]: coordinator = await coordinator_for_device( hass, entry, api, device, coordinators_by_id ) diff --git a/homeassistant/components/switchbot_cloud/binary_sensor.py b/homeassistant/components/switchbot_cloud/binary_sensor.py index 752c428fa6c..cd0e6e8968c 100644 --- a/homeassistant/components/switchbot_cloud/binary_sensor.py +++ b/homeassistant/components/switchbot_cloud/binary_sensor.py @@ -48,10 +48,18 @@ BINARY_SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES = { CALIBRATION_DESCRIPTION, DOOR_OPEN_DESCRIPTION, ), + "Smart Lock Lite": ( + CALIBRATION_DESCRIPTION, + DOOR_OPEN_DESCRIPTION, + ), "Smart Lock Pro": ( CALIBRATION_DESCRIPTION, DOOR_OPEN_DESCRIPTION, ), + "Smart Lock Ultra": ( + CALIBRATION_DESCRIPTION, + DOOR_OPEN_DESCRIPTION, + ), } @@ -69,7 +77,6 @@ async def async_setup_entry( for description in BINARY_SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES[ device.device_type ] - if device.device_type in BINARY_SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES ) diff --git a/homeassistant/components/switchbot_cloud/sensor.py b/homeassistant/components/switchbot_cloud/sensor.py index 9920717a8d7..5a424ea7892 100644 --- a/homeassistant/components/switchbot_cloud/sensor.py +++ b/homeassistant/components/switchbot_cloud/sensor.py @@ -134,8 +134,10 @@ SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES = { BATTERY_DESCRIPTION, CO2_DESCRIPTION, ), - "Smart Lock Pro": (BATTERY_DESCRIPTION,), "Smart Lock": (BATTERY_DESCRIPTION,), + "Smart Lock Lite": (BATTERY_DESCRIPTION,), + "Smart Lock Pro": (BATTERY_DESCRIPTION,), + "Smart Lock Ultra": (BATTERY_DESCRIPTION,), } @@ -151,7 +153,6 @@ async def async_setup_entry( SwitchBotCloudSensor(data.api, device, coordinator, description) for device, coordinator in data.devices.sensors for description in SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES[device.device_type] - if device.device_type in SENSOR_DESCRIPTIONS_BY_DEVICE_TYPES )