From d0c5f291fc3cf2a99791da70a3fa6e1140b8bffa Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 26 Aug 2025 11:46:53 +0200 Subject: [PATCH] Add Tuya test fixtures (#151185) --- tests/components/tuya/__init__.py | 2 + .../tuya/fixtures/swtz_3rzngbyy.json | 116 +++++++++++++++ .../tuya/fixtures/xdd_shx9mmadyyeaq88t.json | 139 ++++++++++++++++++ .../components/tuya/snapshots/test_init.ambr | 62 ++++++++ .../components/tuya/snapshots/test_light.ambr | 83 +++++++++++ .../tuya/snapshots/test_switch.ambr | 48 ++++++ 6 files changed, 450 insertions(+) create mode 100644 tests/components/tuya/fixtures/swtz_3rzngbyy.json create mode 100644 tests/components/tuya/fixtures/xdd_shx9mmadyyeaq88t.json diff --git a/tests/components/tuya/__init__.py b/tests/components/tuya/__init__.py index 1fdc28bcb9f1..0b1a8793228f 100644 --- a/tests/components/tuya/__init__.py +++ b/tests/components/tuya/__init__.py @@ -179,6 +179,7 @@ DEVICE_MOCKS = [ "sp_rjKXWRohlvOTyLBu", # https://github.com/home-assistant/core/issues/149704 "sp_rudejjigkywujjvs", # https://github.com/home-assistant/core/issues/146164 "sp_sdd5f5f2dl5wydjf", # https://github.com/home-assistant/core/issues/144087 + "swtz_3rzngbyy", # https://github.com/orgs/home-assistant/discussions/688 "tdq_1aegphq4yfd50e6b", # https://github.com/home-assistant/core/issues/143209 "tdq_9htyiowaf5rtdhrv", # https://github.com/home-assistant/core/issues/143209 "tdq_cq1p0nt0a4rixnex", # https://github.com/home-assistant/core/issues/146845 @@ -215,6 +216,7 @@ DEVICE_MOCKS = [ "wsdcg_yqiqbaldtr0i7mru", # https://github.com/home-assistant/core/issues/136223 "wxkg_ja5osu5g", # https://github.com/orgs/home-assistant/discussions/482 "wxkg_l8yaz4um5b3pwyvf", # https://github.com/home-assistant/core/issues/93975 + "xdd_shx9mmadyyeaq88t", # https://github.com/home-assistant/core/issues/151141 "ydkt_jevroj5aguwdbs2e", # https://github.com/orgs/home-assistant/discussions/288 "ygsb_l6ax0u6jwbz82atk", # https://github.com/home-assistant/core/issues/146319 "ykq_bngwdjsr", # https://github.com/orgs/home-assistant/discussions/482 diff --git a/tests/components/tuya/fixtures/swtz_3rzngbyy.json b/tests/components/tuya/fixtures/swtz_3rzngbyy.json new file mode 100644 index 000000000000..9eab932c4cbb --- /dev/null +++ b/tests/components/tuya/fixtures/swtz_3rzngbyy.json @@ -0,0 +1,116 @@ +{ + "endpoint": "https://apigw.tuyaeu.com", + "mqtt_connected": true, + "disabled_by": null, + "disabled_polling": false, + "name": "Grillh\u0151m\u00e9r\u0151", + "category": "swtz", + "product_id": "3rzngbyy", + "product_name": "Cooking Thermometer", + "online": false, + "sub": true, + "time_zone": "+02:00", + "active_time": "2025-08-17T19:59:22+00:00", + "create_time": "2025-08-17T19:59:22+00:00", + "update_time": "2025-08-17T19:59:22+00:00", + "function": { + "cook_temperature": { + "type": "Integer", + "value": { + "unit": "\u2103", + "min": -300, + "max": 3000, + "scale": 1, + "step": 1 + } + }, + "cook_temperature_2": { + "type": "Integer", + "value": { + "unit": "\u2103", + "min": -300, + "max": 3000, + "scale": 1, + "step": 1 + } + }, + "temp_unit_convert": { + "type": "Enum", + "value": { + "range": ["c", "f"] + } + }, + "alarm_switch": { + "type": "Boolean", + "value": {} + } + }, + "status_range": { + "battery_percentage": { + "type": "Integer", + "value": { + "unit": "%", + "min": 0, + "max": 100, + "scale": 0, + "step": 1 + } + }, + "temp_current": { + "type": "Integer", + "value": { + "unit": "\u2103", + "min": -300, + "max": 3000, + "scale": 1, + "step": 1 + } + }, + "temp_current_2": { + "type": "Integer", + "value": { + "unit": "\u2103", + "min": -300, + "max": 3000, + "scale": 1, + "step": 1 + } + }, + "cook_temperature": { + "type": "Integer", + "value": { + "unit": "\u2103", + "min": -300, + "max": 3000, + "scale": 1, + "step": 1 + } + }, + "cook_temperature_2": { + "type": "Integer", + "value": { + "unit": "\u2103", + "min": -300, + "max": 3000, + "scale": 1, + "step": 1 + } + }, + "temp_unit_convert": { + "type": "Enum", + "value": { + "range": ["c", "f"] + } + } + }, + "status": { + "battery_percentage": 100, + "temp_current": 290, + "temp_current_2": 290, + "cook_temperature": -300, + "cook_temperature_2": -300, + "temp_unit_convert": "c" + }, + "set_up": false, + "support_local": true +} diff --git a/tests/components/tuya/fixtures/xdd_shx9mmadyyeaq88t.json b/tests/components/tuya/fixtures/xdd_shx9mmadyyeaq88t.json new file mode 100644 index 000000000000..99bc7f7b256d --- /dev/null +++ b/tests/components/tuya/fixtures/xdd_shx9mmadyyeaq88t.json @@ -0,0 +1,139 @@ +{ + "endpoint": "https://apigw.tuyaeu.com", + "mqtt_connected": true, + "disabled_by": null, + "disabled_polling": false, + "name": "Plafond bureau ", + "category": "xdd", + "product_id": "shx9mmadyyeaq88t", + "product_name": "Five way ceiling lamp", + "online": true, + "sub": false, + "time_zone": "+01:00", + "active_time": "2023-11-10T15:45:03+00:00", + "create_time": "2023-11-10T15:45:03+00:00", + "update_time": "2023-11-10T15:45:03+00:00", + "function": { + "switch_led": { + "type": "Boolean", + "value": {} + }, + "work_mode": { + "type": "Enum", + "value": { + "range": ["white", "colour", "scene", "music"] + } + }, + "bright_value": { + "type": "Integer", + "value": { + "min": 10, + "max": 1000, + "scale": 0, + "step": 1 + } + }, + "temp_value": { + "type": "Integer", + "value": { + "min": 0, + "max": 1000, + "scale": 0, + "step": 1 + } + }, + "colour_data": { + "type": "Json", + "value": {} + }, + "countdown": { + "type": "Integer", + "value": { + "unit": "s", + "min": 0, + "max": 86400, + "scale": 0, + "step": 1 + } + }, + "music_data": { + "type": "String", + "value": { + "maxlen": 255 + } + }, + "control_data": { + "type": "String", + "value": { + "maxlen": 255 + } + }, + "do_not_disturb": { + "type": "Boolean", + "value": {} + } + }, + "status_range": { + "switch_led": { + "type": "Boolean", + "value": {} + }, + "work_mode": { + "type": "Enum", + "value": { + "range": ["white", "colour", "scene", "music"] + } + }, + "bright_value": { + "type": "Integer", + "value": { + "min": 10, + "max": 1000, + "scale": 0, + "step": 1 + } + }, + "temp_value": { + "type": "Integer", + "value": { + "min": 0, + "max": 1000, + "scale": 0, + "step": 1 + } + }, + "colour_data": { + "type": "Json", + "value": {} + }, + "countdown": { + "type": "Integer", + "value": { + "unit": "s", + "min": 0, + "max": 86400, + "scale": 0, + "step": 1 + } + }, + "do_not_disturb": { + "type": "Boolean", + "value": {} + } + }, + "status": { + "switch_led": true, + "work_mode": "white", + "bright_value": 946, + "temp_value": 689, + "colour_data": { + "h": 308, + "s": 381, + "v": 1000 + }, + "countdown": 0, + "do_not_disturb": false + }, + "set_up": true, + "support_local": true +} diff --git a/tests/components/tuya/snapshots/test_init.ambr b/tests/components/tuya/snapshots/test_init.ambr index a70d38c6fbca..12e43619d9ea 100644 --- a/tests/components/tuya/snapshots/test_init.ambr +++ b/tests/components/tuya/snapshots/test_init.ambr @@ -5672,6 +5672,37 @@ 'via_device_id': None, }) # --- +# name: test_device_registry[t88qaeyydamm9xhsddx] + DeviceRegistryEntrySnapshot({ + 'area_id': None, + 'config_entries': , + 'config_entries_subentries': , + 'configuration_url': None, + 'connections': set({ + }), + 'disabled_by': None, + 'entry_type': None, + 'hw_version': None, + 'id': , + 'identifiers': set({ + tuple( + 'tuya', + 't88qaeyydamm9xhsddx', + ), + }), + 'labels': set({ + }), + 'manufacturer': 'Tuya', + 'model': 'Five way ceiling lamp', + 'model_id': 'shx9mmadyyeaq88t', + 'name': 'Plafond bureau ', + 'name_by_user': None, + 'primary_config_entry': , + 'serial_number': None, + 'sw_version': None, + 'via_device_id': None, + }) +# --- # name: test_device_registry[tcdk0skzcpisexj2zc] DeviceRegistryEntrySnapshot({ 'area_id': None, @@ -6416,6 +6447,37 @@ 'via_device_id': None, }) # --- +# name: test_device_registry[yybgnzr3ztws] + DeviceRegistryEntrySnapshot({ + 'area_id': None, + 'config_entries': , + 'config_entries_subentries': , + 'configuration_url': None, + 'connections': set({ + }), + 'disabled_by': None, + 'entry_type': None, + 'hw_version': None, + 'id': , + 'identifiers': set({ + tuple( + 'tuya', + 'yybgnzr3ztws', + ), + }), + 'labels': set({ + }), + 'manufacturer': 'Tuya', + 'model': 'Cooking Thermometer (unsupported)', + 'model_id': '3rzngbyy', + 'name': 'Grillhőmérő', + 'name_by_user': None, + 'primary_config_entry': , + 'serial_number': None, + 'sw_version': None, + 'via_device_id': None, + }) +# --- # name: test_device_registry[z7cu5t8bl9tt9fabjd] DeviceRegistryEntrySnapshot({ 'area_id': None, diff --git a/tests/components/tuya/snapshots/test_light.ambr b/tests/components/tuya/snapshots/test_light.ambr index c04cee4a46df..c84d14d2de3c 100644 --- a/tests/components/tuya/snapshots/test_light.ambr +++ b/tests/components/tuya/snapshots/test_light.ambr @@ -2347,6 +2347,89 @@ 'state': 'unavailable', }) # --- +# name: test_platform_setup_and_discovery[light.plafond_bureau-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'max_color_temp_kelvin': 6500, + 'max_mireds': 500, + 'min_color_temp_kelvin': 2000, + 'min_mireds': 153, + 'supported_color_modes': list([ + , + , + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'light', + 'entity_category': None, + 'entity_id': 'light.plafond_bureau', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + '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': 0, + 'translation_key': None, + 'unique_id': 'tuya.t88qaeyydamm9xhsddxswitch_led', + 'unit_of_measurement': None, + }) +# --- +# name: test_platform_setup_and_discovery[light.plafond_bureau-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'brightness': 241, + 'color_mode': , + 'color_temp': 260, + 'color_temp_kelvin': 3832, + 'friendly_name': 'Plafond bureau ', + 'hs_color': tuple( + 26.903, + 38.001, + ), + 'max_color_temp_kelvin': 6500, + 'max_mireds': 500, + 'min_color_temp_kelvin': 2000, + 'min_mireds': 153, + 'rgb_color': tuple( + 255, + 202, + 158, + ), + 'supported_color_modes': list([ + , + , + ]), + 'supported_features': , + 'xy_color': tuple( + 0.43, + 0.368, + ), + }), + 'context': , + 'entity_id': 'light.plafond_bureau', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_platform_setup_and_discovery[light.pokerlamp_1-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/tuya/snapshots/test_switch.ambr b/tests/components/tuya/snapshots/test_switch.ambr index 97ba2e47e110..9a737c1a7487 100644 --- a/tests/components/tuya/snapshots/test_switch.ambr +++ b/tests/components/tuya/snapshots/test_switch.ambr @@ -5948,6 +5948,54 @@ 'state': 'off', }) # --- +# name: test_platform_setup_and_discovery[switch.plafond_bureau_do_not_disturb-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': , + 'entity_id': 'switch.plafond_bureau_do_not_disturb', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Do not disturb', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'do_not_disturb', + 'unique_id': 'tuya.t88qaeyydamm9xhsddxdo_not_disturb', + 'unit_of_measurement': None, + }) +# --- +# name: test_platform_setup_and_discovery[switch.plafond_bureau_do_not_disturb-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Plafond bureau Do not disturb', + }), + 'context': , + 'entity_id': 'switch.plafond_bureau_do_not_disturb', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_platform_setup_and_discovery[switch.powerplug_5_socket_1-entry] EntityRegistryEntrySnapshot({ 'aliases': set({