Add initial support for Tuya wg2 category

This commit is contained in:
epenet 2025-07-30 15:12:21 +00:00
parent 749fc318ca
commit 3fdd8b437f
6 changed files with 214 additions and 1 deletions

View File

@ -229,7 +229,8 @@ 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_INFORMATION = "master_information"
MASTER_STATE = "master_state"
MACH_OPERATE = "mach_operate"
MANUAL_FEED = "manual_feed"
MATERIAL = "material" # Material

View File

@ -1077,6 +1077,18 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
),
*BATTERY_SENSORS,
),
# Zigbee gateway
# Undocumented
"wg2": (
TuyaSensorEntityDescription(
key=DPCode.MASTER_INFORMATION,
translation_key="master_information",
),
TuyaSensorEntityDescription(
key=DPCode.MASTER_STATE,
translation_key="master_state",
),
),
# Thermostat
# https://developer.tuya.com/en/docs/iot/f?id=K9gf45ld5l0t9
"wk": (*BATTERY_SENSORS,),

View File

@ -699,6 +699,16 @@
"charging": "[%key:common::state::charging%]",
"charge_done": "Charge done"
}
},
"master_information": {
"name": "Master information"
},
"master_state": {
"name": "Master state",
"state": {
"normal": "[%key:common::state::normal%]",
"alarm": "Alarm"
}
}
},
"switch": {

View File

@ -158,6 +158,10 @@ DEVICE_MOCKS = {
# https://github.com/orgs/home-assistant/discussions/288
# unsupported device - no platforms
],
"wg2_zigbee_gateway": [
# https://github.com/orgs/home-assistant/discussions/430
Platform.SENSOR,
],
"wk_wifi_smart_gas_boiler_thermostat": [
# 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

@ -2233,6 +2233,102 @@
'state': '0.0',
})
# ---
# name: test_platform_setup_and_discovery[wg2_zigbee_gateway][sensor.x5_zigbee_gateway_master_information-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': 'sensor',
'entity_category': None,
'entity_id': 'sensor.x5_zigbee_gateway_master_information',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Master information',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'master_information',
'unique_id': 'tuya.bf79ca977d67322eb2o68mmaster_information',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[wg2_zigbee_gateway][sensor.x5_zigbee_gateway_master_information-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'X5 Zigbee Gateway Master information',
}),
'context': <ANY>,
'entity_id': 'sensor.x5_zigbee_gateway_master_information',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '',
})
# ---
# name: test_platform_setup_and_discovery[wg2_zigbee_gateway][sensor.x5_zigbee_gateway_master_state-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': 'sensor',
'entity_category': None,
'entity_id': 'sensor.x5_zigbee_gateway_master_state',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Master state',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'master_state',
'unique_id': 'tuya.bf79ca977d67322eb2o68mmaster_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[wg2_zigbee_gateway][sensor.x5_zigbee_gateway_master_state-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'X5 Zigbee Gateway Master state',
}),
'context': <ANY>,
'entity_id': 'sensor.x5_zigbee_gateway_master_state',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'normal',
})
# ---
# name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][sensor.wifi_smart_gas_boiler_thermostat_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': set({