Add initial support for Tuya wg2 category

This commit is contained in:
epenet
2025-07-30 15:12:21 +00:00
parent ae48179e95
commit 7fb64e0d21
5 changed files with 153 additions and 1 deletions

View File

@@ -314,6 +314,15 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
),
TAMPER_BINARY_SENSOR,
),
# Zigbee gateway
# Undocumented
"wg2": (
TuyaBinarySensorEntityDescription(
key=DPCode.MASTER_STATE,
device_class=BinarySensorDeviceClass.PROBLEM,
on_value="alarm",
),
),
# Thermostatic Radiator Valve
# Not documented
"wkf": (

View File

@@ -229,7 +229,7 @@ class DPCode(StrEnum):
LIGHT_MODE = "light_mode"
LOCK = "lock" # Lock / Child lock
MASTER_MODE = "master_mode" # alarm mode
MASTER_STATE = "master_state" # alarm state
MASTER_STATE = "master_state"
MACH_OPERATE = "mach_operate"
MANUAL_FEED = "manual_feed"
MATERIAL = "material" # Material

View File

@@ -335,6 +335,10 @@ DEVICE_MOCKS = {
Platform.CLIMATE,
Platform.SWITCH,
],
"wg2_nwxr8qcu4seltoro": [
# https://github.com/orgs/home-assistant/discussions/430
Platform.BINARY_SENSOR,
],
"wk_fi6dne5tu4t1nm6j": [
# https://github.com/orgs/home-assistant/discussions/243
Platform.CLIMATE,

View File

@@ -0,0 +1,90 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"terminal_id": "1752690839034sq255y",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"id": "bf79ca977d67322eb2o68m",
"name": "X5 Zigbee Gateway",
"category": "wg2",
"product_id": "nwxr8qcu4seltoro",
"product_name": "X5",
"online": true,
"sub": true,
"time_zone": "+02:00",
"active_time": "2025-07-14T10:19:21+00:00",
"create_time": "2025-07-14T10:19:21+00:00",
"update_time": "2025-07-14T10:19:21+00:00",
"function": {
"master_state": {
"type": "Enum",
"value": {
"range": ["normal", "alarm"]
}
},
"factory_reset": {
"type": "Boolean",
"value": {}
},
"master_language": {
"type": "Enum",
"value": {
"range": [
"chinese_simplified",
"chinese_traditional",
"english",
"french",
"italian",
"german",
"spanish",
"portuguese",
"russian",
"japanese"
]
}
}
},
"status_range": {
"master_state": {
"type": "Enum",
"value": {
"range": ["normal", "alarm"]
}
},
"master_information": {
"type": "String",
"value": {
"maxlen": 255
}
},
"factory_reset": {
"type": "Boolean",
"value": {}
},
"master_language": {
"type": "Enum",
"value": {
"range": [
"chinese_simplified",
"chinese_traditional",
"english",
"french",
"italian",
"german",
"spanish",
"portuguese",
"russian",
"japanese"
]
}
}
},
"status": {
"master_state": "normal",
"master_information": "",
"factory_reset": false,
"master_language": "chinese_simplified"
},
"set_up": false,
"support_local": true
}

View File

@@ -685,6 +685,55 @@
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[wg2_nwxr8qcu4seltoro][binary_sensor.x5_zigbee_gateway_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.x5_zigbee_gateway_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'tuya.bf79ca977d67322eb2o68mmaster_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[wg2_nwxr8qcu4seltoro][binary_sensor.x5_zigbee_gateway_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'problem',
'friendly_name': 'X5 Zigbee Gateway Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.x5_zigbee_gateway_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[ywbj_gf9dejhmzffgdyfj][binary_sensor.smoke_detector_upstairs_smoke-entry]
EntityRegistryEntrySnapshot({
'aliases': set({