Add mute support to Tuya wg2 category (gateway) (#150122)

This commit is contained in:
epenet
2025-08-10 17:44:26 +02:00
committed by GitHub
parent 1b7cb418eb
commit efe519faad
8 changed files with 336 additions and 2 deletions

View File

@@ -314,8 +314,8 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
),
TAMPER_BINARY_SENSOR,
),
# Zigbee gateway
# Undocumented
# Gateway control
# https://developer.tuya.com/en/docs/iot/wg?id=Kbcdadk79ejok
"wg2": (
TuyaBinarySensorEntityDescription(
key=DPCode.MASTER_STATE,

View File

@@ -785,6 +785,15 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = {
entity_category=EntityCategory.CONFIG,
),
),
# Gateway control
# https://developer.tuya.com/en/docs/iot/wg?id=Kbcdadk79ejok
"wg2": (
SwitchEntityDescription(
key=DPCode.MUFFLING,
translation_key="mute",
entity_category=EntityCategory.CONFIG,
),
),
# Thermostat
# https://developer.tuya.com/en/docs/iot/f?id=K9gf45ld5l0t9
"wk": (

View File

@@ -433,10 +433,23 @@ DEVICE_MOCKS = {
"wfcon_b25mh8sxawsgndck": [
# https://github.com/home-assistant/core/issues/149704
],
"wg2_haclbl0qkqlf2qds": [
# https://github.com/orgs/home-assistant/discussions/517
Platform.BINARY_SENSOR,
Platform.SWITCH,
],
"wg2_nwxr8qcu4seltoro": [
# https://github.com/orgs/home-assistant/discussions/430
Platform.BINARY_SENSOR,
],
"wg2_setmxeqgs63xwopm": [
# https://github.com/orgs/home-assistant/discussions/539
Platform.BINARY_SENSOR,
],
"wg2_v7owd9tzcaninc36": [
# https://github.com/orgs/home-assistant/discussions/539
# SDK information is empty
],
"wk_6kijc7nd": [
# https://github.com/home-assistant/core/issues/136513
Platform.CLIMATE,

View File

@@ -0,0 +1,77 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"name": "Home Gateway",
"category": "wg2",
"product_id": "haclbl0qkqlf2qds",
"product_name": "Multi-mode Gateway",
"online": false,
"sub": true,
"time_zone": "+03:00",
"active_time": "2025-08-03T10:30:30+00:00",
"create_time": "2025-08-03T10:30:30+00:00",
"update_time": "2025-08-03T10:30:30+00:00",
"function": {
"switch_alarm_sound": {
"type": "Boolean",
"value": {}
},
"muffling": {
"type": "Boolean",
"value": {}
},
"master_state": {
"type": "Enum",
"value": {
"range": ["normal", "alarm"]
}
},
"factory_reset": {
"type": "Boolean",
"value": {}
},
"alarm_active": {
"type": "String",
"value": {
"maxlen": 255
}
}
},
"status_range": {
"switch_alarm_sound": {
"type": "Boolean",
"value": {}
},
"muffling": {
"type": "Boolean",
"value": {}
},
"master_state": {
"type": "Enum",
"value": {
"range": ["normal", "alarm"]
}
},
"factory_reset": {
"type": "Boolean",
"value": {}
},
"alarm_active": {
"type": "String",
"value": {
"maxlen": 255
}
}
},
"status": {
"switch_alarm_sound": false,
"muffling": false,
"master_state": "normal",
"factory_reset": false,
"alarm_active": ""
},
"set_up": false,
"support_local": true
}

View File

@@ -0,0 +1,68 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"name": "Gateway",
"category": "wg2",
"product_id": "setmxeqgs63xwopm",
"product_name": "",
"online": true,
"sub": true,
"time_zone": "+00:00",
"active_time": "2021-11-26T13:33:58+00:00",
"create_time": "2021-11-26T13:33:58+00:00",
"update_time": "2021-11-26T13:33:58+00:00",
"function": {
"switch_alarm_sound": {
"type": "Boolean",
"value": {}
},
"master_state": {
"type": "Enum",
"value": {
"range": ["normal", "alarm"]
}
},
"factory_reset": {
"type": "Boolean",
"value": {}
},
"alarm_active": {
"type": "String",
"value": {
"maxlen": 255
}
}
},
"status_range": {
"switch_alarm_sound": {
"type": "Boolean",
"value": {}
},
"master_state": {
"type": "Enum",
"value": {
"range": ["normal", "alarm"]
}
},
"factory_reset": {
"type": "Boolean",
"value": {}
},
"alarm_active": {
"type": "String",
"value": {
"maxlen": 255
}
}
},
"status": {
"switch_alarm_sound": false,
"master_state": "normal",
"factory_reset": false,
"alarm_active": ""
},
"set_up": false,
"support_local": true
}

View File

@@ -0,0 +1,21 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"name": "Gateway2",
"category": "wg2",
"product_id": "v7owd9tzcaninc36",
"product_name": "Gateway",
"online": false,
"sub": true,
"time_zone": "+01:00",
"active_time": "2023-07-16T09:32:51+00:00",
"create_time": "2023-07-16T09:32:51+00:00",
"update_time": "2023-07-16T09:32:51+00:00",
"function": {},
"status_range": {},
"status": {},
"set_up": false,
"support_local": true
}

View File

@@ -391,6 +391,104 @@
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[binary_sensor.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': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.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.mpowx36sgqexmtes2gwmaster_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[binary_sensor.gateway_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'problem',
'friendly_name': 'Gateway Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.gateway_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[binary_sensor.home_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': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.home_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.sdq2flqkq0lblcah2gwmaster_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[binary_sensor.home_gateway_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'problem',
'friendly_name': 'Home Gateway Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.home_gateway_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_platform_setup_and_discovery[binary_sensor.human_presence_office_occupancy-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -1837,6 +1837,54 @@
'state': 'on',
})
# ---
# name: test_platform_setup_and_discovery[switch.home_gateway_mute-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': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.home_gateway_mute',
'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': 'Mute',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'mute',
'unique_id': 'tuya.sdq2flqkq0lblcah2gwmuffling',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[switch.home_gateway_mute-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Home Gateway Mute',
}),
'context': <ANY>,
'entity_id': 'switch.home_gateway_mute',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_platform_setup_and_discovery[switch.hvac_meter_socket_1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({