From f9d16b227c571694d74f94f4603b637a432ffa3a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 27 Aug 2025 06:04:44 +0000 Subject: [PATCH] Add charge_state to Tuya siren alarm --- .../components/tuya/binary_sensor.py | 8 ++- homeassistant/components/tuya/const.py | 1 + .../tuya/snapshots/test_binary_sensor.ambr | 49 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 3119bd5793f..08645b49e4c 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -287,7 +287,13 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { ), # Siren Alarm # https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu - "sgbj": (TAMPER_BINARY_SENSOR,), + "sgbj": ( + TuyaBinarySensorEntityDescription( + key=DPCode.CHARGE_STATE, + device_class=BinarySensorDeviceClass.BATTERY_CHARGING, + ), + TAMPER_BINARY_SENSOR, + ), # Water Detector # https://developer.tuya.com/en/docs/iot/categorysj?id=Kaiuz3iub2sli "sj": ( diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 7a80a51726d..e4a180472de 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -142,6 +142,7 @@ class DPCode(StrEnum): CH2O_VALUE = "ch2o_value" CH4_SENSOR_STATE = "ch4_sensor_state" CH4_SENSOR_VALUE = "ch4_sensor_value" + CHARGE_STATE = "charge_state" CHILD_LOCK = "child_lock" # Child lock CISTERN = "cistern" CLEAN_AREA = "clean_area" diff --git a/tests/components/tuya/snapshots/test_binary_sensor.ambr b/tests/components/tuya/snapshots/test_binary_sensor.ambr index 2a032b1577c..c0251d6cea4 100644 --- a/tests/components/tuya/snapshots/test_binary_sensor.ambr +++ b/tests/components/tuya/snapshots/test_binary_sensor.ambr @@ -1175,6 +1175,55 @@ 'state': 'off', }) # --- +# name: test_platform_setup_and_discovery[binary_sensor.siren_charging-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.siren_charging', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + '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.okwwus27jhqqe2mijbgscharge_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_platform_setup_and_discovery[binary_sensor.siren_charging-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'battery_charging', + 'friendly_name': 'Siren Charging', + }), + 'context': , + 'entity_id': 'binary_sensor.siren_charging', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_platform_setup_and_discovery[binary_sensor.siren_tamper-entry] EntityRegistryEntrySnapshot({ 'aliases': set({