diff --git a/homeassistant/components/tuya/type_information.py b/homeassistant/components/tuya/type_information.py index 00ac7b377011bf..a61a4717387b70 100644 --- a/homeassistant/components/tuya/type_information.py +++ b/homeassistant/components/tuya/type_information.py @@ -105,12 +105,12 @@ class BitmapTypeInformation(TypeInformation[int]): @classmethod def _from_json(cls, dpcode: str, type_data: str) -> Self | None: """Load JSON string and return a BitmapTypeInformation object.""" - if not (parsed := json_loads_object(type_data)): + if not (parsed := cast(dict[str, Any] | None, json_loads_object(type_data))): return None return cls( dpcode=dpcode, type_data=type_data, - **cast(dict[str, list[str]], parsed), + label=parsed["label"], ) diff --git a/tests/components/tuya/fixtures/msp_5t7esmqqh92ssbe5.json b/tests/components/tuya/fixtures/msp_5t7esmqqh92ssbe5.json new file mode 100644 index 00000000000000..6b8058ba9782c4 --- /dev/null +++ b/tests/components/tuya/fixtures/msp_5t7esmqqh92ssbe5.json @@ -0,0 +1,54 @@ +{ + "endpoint": "https://apigw.tuyaeu.com", + "mqtt_connected": true, + "disabled_by": null, + "disabled_polling": false, + "name": "Slimme kattenbak", + "category": "msp", + "product_id": "5t7esmqqh92ssbe5", + "product_name": "Automatic Cat Litter Box", + "online": false, + "sub": false, + "time_zone": "+02:00", + "active_time": "2025-07-25T06:46:38+00:00", + "create_time": "2025-07-25T06:46:38+00:00", + "update_time": "2025-07-25T06:46:38+00:00", + "function": { + "deodorization": { + "type": "Boolean", + "value": "{}" + } + }, + "status_range": { + "cat_weight": { + "type": "Integer", + "value": "{\"unit\":\"g\",\"min\":600,\"max\":10000,\"scale\":0,\"step\":1}" + }, + "excretion_times_day": { + "type": "Integer", + "value": "{\"unit\":\"times\",\"min\":0,\"max\":60,\"scale\":0,\"step\":1}" + }, + "excretion_time_day": { + "type": "Integer", + "value": "{\"unit\":\"s\",\"min\":0,\"max\":1800,\"scale\":0,\"step\":1}" + }, + "deodorization": { + "type": "Boolean", + "value": "{}" + }, + "fault": { + "type": "Bitmap", + "value": "{\"label\":[\"motor_fault\",\"program_fault\",\"g_sensor_fault\"],\"maxlen\":3}" + } + }, + "status": { + "cat_weight": 4999, + "excretion_times_day": 1, + "excretion_time_day": 93, + "deodorization": false, + "fault": 0 + }, + "set_up": true, + "support_local": true, + "warnings": null +} diff --git a/tests/components/tuya/snapshots/test_init.ambr b/tests/components/tuya/snapshots/test_init.ambr index ff8e26e2fb3354..09044d6a22e461 100644 --- a/tests/components/tuya/snapshots/test_init.ambr +++ b/tests/components/tuya/snapshots/test_init.ambr @@ -619,6 +619,37 @@ 'via_device_id': None, }) # --- +# name: test_device_registry[5ebss29hqqmse7t5psm] + 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', + '5ebss29hqqmse7t5psm', + ), + }), + 'labels': set({ + }), + 'manufacturer': 'Tuya', + 'model': 'Automatic Cat Litter Box', + 'model_id': '5t7esmqqh92ssbe5', + 'name': 'Slimme kattenbak', + 'name_by_user': None, + 'primary_config_entry': , + 'serial_number': None, + 'sw_version': None, + 'via_device_id': None, + }) +# --- # name: test_device_registry[5gfyvvg48bsxbbnjzc] DeviceRegistryEntrySnapshot({ 'area_id': None, diff --git a/tests/components/tuya/snapshots/test_sensor.ambr b/tests/components/tuya/snapshots/test_sensor.ambr index 4753fa09335c93..7253e2f6a4c7a8 100644 --- a/tests/components/tuya/snapshots/test_sensor.ambr +++ b/tests/components/tuya/snapshots/test_sensor.ambr @@ -16914,6 +16914,167 @@ 'state': '77.0', }) # --- +# name: test_platform_setup_and_discovery[sensor.slimme_kattenbak_cat_weight-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.slimme_kattenbak_cat_weight', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 0, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Cat weight', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'cat_weight', + 'unique_id': 'tuya.5ebss29hqqmse7t5psmcat_weight', + 'unit_of_measurement': 'g', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.slimme_kattenbak_cat_weight-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'weight', + 'friendly_name': 'Slimme kattenbak Cat weight', + 'state_class': , + 'unit_of_measurement': 'g', + }), + 'context': , + 'entity_id': 'sensor.slimme_kattenbak_cat_weight', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unavailable', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.slimme_kattenbak_excretion_duration-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.slimme_kattenbak_excretion_duration', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Excretion duration', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'excretion_time_day', + 'unique_id': 'tuya.5ebss29hqqmse7t5psmexcretion_time_day', + 'unit_of_measurement': 's', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.slimme_kattenbak_excretion_duration-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'duration', + 'friendly_name': 'Slimme kattenbak Excretion duration', + 'state_class': , + 'unit_of_measurement': 's', + }), + 'context': , + 'entity_id': 'sensor.slimme_kattenbak_excretion_duration', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unavailable', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.slimme_kattenbak_excretion_times_day-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.slimme_kattenbak_excretion_times_day', + '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': 'Excretion times (day)', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'excretion_times_day', + 'unique_id': 'tuya.5ebss29hqqmse7t5psmexcretion_times_day', + 'unit_of_measurement': 'times', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.slimme_kattenbak_excretion_times_day-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Slimme kattenbak Excretion times (day)', + 'unit_of_measurement': 'times', + }), + 'context': , + 'entity_id': 'sensor.slimme_kattenbak_excretion_times_day', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unavailable', + }) +# --- # name: test_platform_setup_and_discovery[sensor.smart_odor_eliminator_pro_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': set({