Add Tuya test fixtures (#151972)

This commit is contained in:
epenet
2025-09-09 14:28:25 +02:00
committed by GitHub
parent 58edc3742a
commit 9ea438024d
8 changed files with 527 additions and 1 deletions
+3
View File
@@ -185,6 +185,7 @@ DEVICE_MOCKS = [
"sgbj_ulv4nnue7gqp0rjk", # https://github.com/home-assistant/core/issues/149704
"sj_rzeSU2h9uoklxEwq", # https://github.com/home-assistant/core/issues/150683
"sj_tgvtvdoc", # https://github.com/orgs/home-assistant/discussions/482
"sjz_ftbc8rp8ipksdfpv", # https://github.com/orgs/home-assistant/discussions/51
"sp_6bmk1remyscwyx6i", # https://github.com/orgs/home-assistant/discussions/842
"sp_drezasavompxpcgm", # https://github.com/home-assistant/core/issues/149704
"sp_nzauwyj3mcnjnf35", # https://github.com/home-assistant/core/issues/141278
@@ -211,6 +212,7 @@ DEVICE_MOCKS = [
"wg2_tmwhss6ntjfc7prs", # https://github.com/home-assistant/core/issues/150662
"wg2_v7owd9tzcaninc36", # https://github.com/orgs/home-assistant/discussions/539
"wk_6kijc7nd", # https://github.com/home-assistant/core/issues/136513
"wk_IAYz2WK1th0cMLmL", # https://github.com/orgs/home-assistant/discussions/842
"wk_aqoouq7x", # https://github.com/home-assistant/core/issues/146263
"wk_ccpwojhalfxryigz", # https://github.com/home-assistant/core/issues/145551
"wk_cpmgn2cf", # https://github.com/orgs/home-assistant/discussions/684
@@ -219,6 +221,7 @@ DEVICE_MOCKS = [
"wk_gogb05wrtredz3bs", # https://github.com/home-assistant/core/issues/136337
"wk_y5obtqhuztqsf2mj", # https://github.com/home-assistant/core/issues/139735
"wkcz_gc4b1mdw7kebtuyz", # https://github.com/home-assistant/core/issues/135617
"wnykq_kzwdw5bpxlbs9h9g", # https://github.com/orgs/home-assistant/discussions/842
"wnykq_npbbca46yiug8ysk", # https://github.com/orgs/home-assistant/discussions/539
"wnykq_om518smspsaltzdi", # https://github.com/home-assistant/core/issues/150662
"wnykq_rqhxdyusjrwxyff6", # https://github.com/home-assistant/core/issues/133173
+5 -1
View File
@@ -208,7 +208,11 @@ async def _create_device(hass: HomeAssistant, mock_device_code: str) -> Customer
}
device.status = details["status"]
for key, value in device.status.items():
if device.status_range[key].type == "Json":
# Some devices to not provide a status_range for all status DPs
dp_type = device.status_range.get(key)
if dp_type is None:
dp_type = device.function[key]
if dp_type.type == "Json":
device.status[key] = json_dumps(value)
return device
@@ -0,0 +1,143 @@
{
"endpoint": "https://apigw.tuyaus.com",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"name": "mesa",
"category": "sjz",
"product_id": "ftbc8rp8ipksdfpv",
"product_name": "geniodesk",
"online": true,
"sub": false,
"time_zone": "-03:00",
"active_time": "2025-06-16T19:48:57+00:00",
"create_time": "2025-06-16T19:48:57+00:00",
"update_time": "2025-06-22T21:26:09+00:00",
"function": {
"up_down": {
"type": "Enum",
"value": {
"range": ["up", "down", "stop"]
}
},
"level": {
"type": "Enum",
"value": {
"range": ["level_1", "level_2", "level_3", "level_4"]
}
},
"child_lock": {
"type": "Boolean",
"value": {}
},
"height": {
"type": "Integer",
"value": {
"unit": "cm",
"min": 66,
"max": 131,
"scale": 0,
"step": 1
}
},
"height_inch": {
"type": "Integer",
"value": {
"max": 520,
"min": 250,
"scale": 1,
"step": 1,
"unit": "inch"
}
},
"metric_inch_flag": {
"type": "Boolean",
"value": {}
},
"percent_high": {
"type": "Integer",
"value": {
"max": 100,
"min": 0,
"scale": 0,
"step": 1,
"unit": ""
}
},
"clock_time": {
"type": "Integer",
"value": {
"max": 150,
"min": 30,
"scale": 0,
"step": 30,
"unit": "min"
}
},
"clock_flag": {
"type": "Boolean",
"value": {}
}
},
"status_range": {
"up_down": {
"type": "Enum",
"value": {
"range": ["up", "down", "stop"]
}
},
"work_state": {
"type": "Enum",
"value": {
"range": ["up", "down", "stop"]
}
},
"level": {
"type": "Enum",
"value": {
"range": ["level_1", "level_2", "level_3", "level_4"]
}
},
"child_lock": {
"type": "Boolean",
"value": {}
},
"fault": {
"type": "Raw",
"value": {
"label": ["ov_cr", "motor_fault"],
"maxlen": 2
}
},
"height": {
"type": "Integer",
"value": {
"unit": "cm",
"min": 66,
"max": 131,
"scale": 0,
"step": 1
}
},
"flag": {
"type": "Boolean",
"value": {}
}
},
"status": {
"up_down": "stop",
"work_state": "stop",
"level": "level_1",
"child_lock": false,
"fault": 0,
"height": 77,
"height_inch": 250,
"metric_inch_flag": true,
"percent_high": 0,
"flag": false,
"clock_time": 30,
"clock_flag": false
},
"set_up": false,
"support_local": true
}
@@ -0,0 +1,130 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"name": "El termostato de la cocina",
"category": "wk",
"product_id": "IAYz2WK1th0cMLmL",
"product_name": "thermostat",
"online": true,
"sub": false,
"time_zone": "+01:00",
"active_time": "2018-12-04T17:50:07+00:00",
"create_time": "2018-12-04T17:50:07+00:00",
"update_time": "2025-09-03T07:44:16+00:00",
"function": {
"switch": {
"type": "Boolean",
"value": {}
},
"child_lock": {
"type": "Boolean",
"value": {}
},
"eco": {
"type": "Boolean",
"value": {}
},
"upper_temp": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 0,
"max": 100,
"scale": 0,
"step": 5
}
},
"Mode": {
"type": "Enum",
"value": {
"range": ["0", "1"]
}
},
"program": {
"type": "Raw",
"value": {
"maxlen": 128
}
},
"tempSwitch": {
"type": "Enum",
"value": {
"range": ["0", "1"]
}
},
"TempSet": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 10,
"max": 70,
"scale": 1,
"step": 5
}
}
},
"status_range": {
"eco": {
"type": "Boolean",
"value": {}
},
"switch": {
"type": "Boolean",
"value": {}
},
"child_lock": {
"type": "Boolean",
"value": {}
},
"upper_temp": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 0,
"max": 100,
"scale": 0,
"step": 5
}
},
"floorTemp": {
"type": "Integer",
"value": {
"max": 198,
"min": 0,
"scale": 0,
"step": 5,
"unit": "\u2103"
}
},
"floortempFunction": {
"type": "Boolean",
"value": {}
},
"TempSet": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 10,
"max": 70,
"scale": 1,
"step": 5
}
}
},
"status": {
"switch": false,
"upper_temp": 55,
"eco": true,
"child_lock": false,
"Mode": 1,
"program": "DwYoDwceHhQoORceOhceOxceAAkoAAoeHhQoORceOhceOxceAAkoAAoeHhQoORceOhceOxce",
"floorTemp": 0,
"tempSwitch": 0,
"floortempFunction": true,
"TempSet": 41
},
"set_up": true,
"support_local": true
}
@@ -0,0 +1,40 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"name": "IR Minero",
"category": "wnykq",
"product_id": "kzwdw5bpxlbs9h9g",
"product_name": "Smart IR ",
"online": true,
"sub": false,
"time_zone": "+02:00",
"active_time": "2023-05-07T19:07:20+00:00",
"create_time": "2023-05-07T19:07:20+00:00",
"update_time": "2025-09-03T07:44:22+00:00",
"function": {
"ir_send": {
"type": "String",
"value": {
"maxlen": 3072
}
}
},
"status_range": {
"ir_study_code": {
"type": "Raw",
"value": {
"maxlen": 128
}
}
},
"status": {
"ir_send": {
"control": "study_exit"
},
"ir_study_code": "UAjyBn0ALQh9AMMEfQBFBBoB5wO+CmUEvAC2BrwA1QG9CtYGnABrA30A/Eh9APYGqgiwAn0AhAR9AIMEnQCiBPoAyAOdBYMEfQCEBA0I9AGcAIQJfQAyB30ADQOUUdwKfQDCBH0AZQ59AIMEfQCECX4Kowm7ALYGgwQwdQ=="
},
"set_up": false,
"support_local": true
}
@@ -299,6 +299,71 @@
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[climate.el_termostato_de_la_cocina-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.HEAT_COOL: 'heat_cool'>,
]),
'max_temp': 35,
'min_temp': 7,
'target_temp_step': 1.0,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.el_termostato_de_la_cocina',
'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': None,
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <ClimateEntityFeature: 384>,
'translation_key': None,
'unique_id': 'tuya.LmLMc0ht1KW2zYAIkw',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[climate.el_termostato_de_la_cocina-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 5.5,
'friendly_name': 'El termostato de la cocina',
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.HEAT_COOL: 'heat_cool'>,
]),
'max_temp': 35,
'min_temp': 7,
'supported_features': <ClimateEntityFeature: 384>,
'target_temp_step': 1.0,
}),
'context': <ANY>,
'entity_id': 'climate.el_termostato_de_la_cocina',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[climate.kabinet-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@@ -1363,6 +1363,37 @@
'via_device_id': None,
})
# ---
# name: test_device_registry[LmLMc0ht1KW2zYAIkw]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': None,
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'tuya',
'LmLMc0ht1KW2zYAIkw',
),
}),
'labels': set({
}),
'manufacturer': 'Tuya',
'model': 'thermostat',
'model_id': 'IAYz2WK1th0cMLmL',
'name': 'El termostato de la cocina',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_device_registry[NVjuXIQ6QH9eZLHCzc]
DeviceRegistryEntrySnapshot({
'area_id': None,
@@ -3037,6 +3068,37 @@
'via_device_id': None,
})
# ---
# name: test_device_registry[g9h9sblxpb5wdwzkqkynw]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': None,
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'tuya',
'g9h9sblxpb5wdwzkqkynw',
),
}),
'labels': set({
}),
'manufacturer': 'Tuya',
'model': 'Smart IR (unsupported)',
'model_id': 'kzwdw5bpxlbs9h9g',
'name': 'IR Minero',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_device_registry[gbq8kiahk57ct0bpncjynx]
DeviceRegistryEntrySnapshot({
'area_id': None,
@@ -6633,6 +6695,37 @@
'via_device_id': None,
})
# ---
# name: test_device_registry[vpfdskpi8pr8cbtfzjs]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': None,
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'tuya',
'vpfdskpi8pr8cbtfzjs',
),
}),
'labels': set({
}),
'manufacturer': 'Tuya',
'model': 'geniodesk (unsupported)',
'model_id': 'ftbc8rp8ipksdfpv',
'name': 'mesa',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_device_registry[vrhdtr5fawoiyth9qdt]
DeviceRegistryEntrySnapshot({
'area_id': None,
@@ -3095,6 +3095,54 @@
'state': 'on',
})
# ---
# name: test_platform_setup_and_discovery[switch.el_termostato_de_la_cocina_child_lock-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.el_termostato_de_la_cocina_child_lock',
'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': 'Child lock',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': 'tuya.LmLMc0ht1KW2zYAIkwchild_lock',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[switch.el_termostato_de_la_cocina_child_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'El termostato de la cocina Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.el_termostato_de_la_cocina_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[switch.elivco_kitchen_socket_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': set({