From ddab50edcc82f42006ecc0948aa206f7f3c97124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <77412126+ChayoteJarocho@users.noreply.github.com> Date: Tue, 17 Mar 2026 14:41:57 -0600 Subject: [PATCH] Add binary sensor support for Tuya WG2 alarm panel (Duosmart C30) (#165833) --- .../components/tuya/binary_sensor.py | 5 ++ .../tuya/snapshots/test_binary_sensor.ambr | 51 +++++++++++++++++++ .../components/tuya/snapshots/test_init.ambr | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 06bd42853ea..bc8ff393746 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -317,6 +317,11 @@ BINARY_SENSORS: dict[DeviceCategory, tuple[TuyaBinarySensorEntityDescription, .. entity_category=EntityCategory.DIAGNOSTIC, on_value="alarm", ), + TuyaBinarySensorEntityDescription( + key=DPCode.CHARGE_STATE, + device_class=BinarySensorDeviceClass.BATTERY_CHARGING, + entity_category=EntityCategory.DIAGNOSTIC, + ), ), DeviceCategory.WK: ( TuyaBinarySensorEntityDescription( diff --git a/tests/components/tuya/snapshots/test_binary_sensor.ambr b/tests/components/tuya/snapshots/test_binary_sensor.ambr index 205a8b6ae8f..5519325b177 100644 --- a/tests/components/tuya/snapshots/test_binary_sensor.ambr +++ b/tests/components/tuya/snapshots/test_binary_sensor.ambr @@ -101,6 +101,57 @@ 'state': 'off', }) # --- +# name: test_platform_setup_and_discovery[binary_sensor.c30_charging-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.c30_charging', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Charging', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Charging', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'tuya.rirsc4vhpbv2whkp2gwcharge_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_platform_setup_and_discovery[binary_sensor.c30_charging-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'battery_charging', + 'friendly_name': 'C30 Charging', + }), + 'context': , + 'entity_id': 'binary_sensor.c30_charging', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_platform_setup_and_discovery[binary_sensor.cat_feeder_feeding-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/tuya/snapshots/test_init.ambr b/tests/components/tuya/snapshots/test_init.ambr index 369f119271b..566552d239c 100644 --- a/tests/components/tuya/snapshots/test_init.ambr +++ b/tests/components/tuya/snapshots/test_init.ambr @@ -7150,7 +7150,7 @@ 'labels': set({ }), 'manufacturer': 'Tuya', - 'model': 'C30 (unsupported)', + 'model': 'C30', 'model_id': 'pkhw2vbphv4csrir', 'name': 'C30', 'name_by_user': None,