diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index b6adbe92eaf..368820f1522 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -213,6 +213,12 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { state_class=SensorStateClass.MEASUREMENT, suggested_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, ), + TuyaSensorEntityDescription( + key=DPCode.PM10, + translation_key="pm10", + device_class=SensorDeviceClass.PM10, + state_class=SensorStateClass.MEASUREMENT, + ), *BATTERY_SENSORS, ), # CO Detector diff --git a/tests/components/tuya/__init__.py b/tests/components/tuya/__init__.py index ad70e03846d..6aba86680cb 100644 --- a/tests/components/tuya/__init__.py +++ b/tests/components/tuya/__init__.py @@ -26,7 +26,7 @@ DEVICE_MOCKS = [ "clkg_nhyj64w2", # https://github.com/home-assistant/core/issues/136055 "clkg_wltqkykhni0papzj", # https://github.com/home-assistant/core/issues/151635 "co2bj_yakol79dibtswovc", # https://github.com/home-assistant/core/issues/151784 - "co2bj_yrr3eiyiacm31ski", # https://github.com/home-assistant/core/issues/133173 + "co2bj_yrr3eiyiacm31ski", # https://github.com/orgs/home-assistant/discussions/842 "cobj_hcdy5zrq3ikzthws", # https://github.com/orgs/home-assistant/discussions/482 "cs_ipmyy4nigpqcnd8q", # https://github.com/home-assistant/core/pull/148726 "cs_ka2wfrdoogpvgzfi", # https://github.com/home-assistant/core/issues/119865 diff --git a/tests/components/tuya/fixtures/co2bj_yrr3eiyiacm31ski.json b/tests/components/tuya/fixtures/co2bj_yrr3eiyiacm31ski.json index c4657f30012..288430b635d 100644 --- a/tests/components/tuya/fixtures/co2bj_yrr3eiyiacm31ski.json +++ b/tests/components/tuya/fixtures/co2bj_yrr3eiyiacm31ski.json @@ -1,18 +1,14 @@ { - "endpoint": "https://apigw.tuyaus.com", - "mqtt_connected": true, - "disabled_by": null, - "disabled_polling": false, "name": "AQI", "category": "co2bj", "product_id": "yrr3eiyiacm31ski", "product_name": "AIR_DETECTOR ", "online": true, "sub": false, - "time_zone": "+07:00", - "active_time": "2025-01-02T05:14:50+00:00", - "create_time": "2025-01-02T05:14:50+00:00", - "update_time": "2025-01-02T05:14:50+00:00", + "time_zone": "+02:00", + "active_time": "2025-08-31T07:43:45+00:00", + "create_time": "2025-08-31T07:43:45+00:00", + "update_time": "2025-09-05T07:29:11+00:00", "function": { "alarm_volume": { "type": "Enum", @@ -43,6 +39,62 @@ "scale": 0, "step": 1 } + }, + "alarm_ringtone": { + "type": "Enum", + "value": { + "range": [ + "ringtone_1", + "ringtone_2", + "ringtone_3", + "ringtone_4", + "ringtone_5" + ] + } + }, + "maxco2_set": { + "type": "Integer", + "value": { + "max": 2000, + "min": 800, + "scale": 0, + "step": 100, + "unit": "ppm" + } + }, + "temp_unit_convert": { + "type": "Enum", + "value": { + "range": ["c", "f"] + } + }, + "pm25_set": { + "type": "Integer", + "value": { + "max": 75, + "min": 15, + "scale": 0, + "step": 5, + "unit": "\u03bcg/m3" + } + }, + "check_time": { + "type": "Boolean", + "value": {} + }, + "screen_sleep": { + "type": "Boolean", + "value": {} + }, + "screen_sleep_time": { + "type": "Integer", + "value": { + "max": 300, + "min": 10, + "scale": 0, + "step": 10, + "unit": "s" + } } }, "status_range": { @@ -151,21 +203,82 @@ "scale": 3, "step": 1 } + }, + "battery_state": { + "type": "Enum", + "value": { + "range": ["normal", "charge"] + } + }, + "pm10": { + "type": "Integer", + "value": { + "max": 1000, + "min": 0, + "scale": 0, + "step": 1, + "unit": "ug/m3" + } + }, + "pm25": { + "type": "Integer", + "value": { + "max": 1000, + "min": 0, + "scale": 0, + "step": 1, + "unit": "ug/m3" + } + }, + "humidity_current": { + "type": "Integer", + "value": { + "max": 100, + "min": 0, + "scale": 0, + "step": 1, + "unit": "" + } + }, + "air_quality": { + "type": "Enum", + "value": { + "range": ["great", "mild", "good", "medium", "severe"] + } + }, + "pm25_state": { + "type": "Enum", + "value": { + "range": ["alarm", "normal"] + } } }, "status": { "co2_state": "normal", - "co2_value": 541, - "alarm_volume": "low", + "co2_value": 419, + "alarm_volume": "mute", "alarm_time": 1, "alarm_switch": false, "battery_percentage": 100, - "alarm_bright": 98, - "temp_current": 26, - "humidity_value": 53, - "pm25_value": 17, - "voc_value": 18, - "ch2o_value": 2 + "alarm_bright": 0, + "temp_current": 24, + "humidity_value": 54, + "pm25_value": 7, + "voc_value": 71, + "ch2o_value": 6, + "alarm_ringtone": "ringtone_1", + "battery_state": "normal", + "maxco2_set": 1500, + "temp_unit_convert": "c", + "pm10": 8, + "pm25": 5, + "humidity_current": 54, + "air_quality": "great", + "pm25_set": 40, + "pm25_state": "normal", + "check_time": false, + "screen_sleep": true, + "screen_sleep_time": 180 }, "set_up": true, "support_local": true diff --git a/tests/components/tuya/snapshots/test_select.ambr b/tests/components/tuya/snapshots/test_select.ambr index deab14ecc95..fa568136a59 100644 --- a/tests/components/tuya/snapshots/test_select.ambr +++ b/tests/components/tuya/snapshots/test_select.ambr @@ -293,7 +293,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'low', + 'state': 'mute', }) # --- # name: test_platform_setup_and_discovery[select.aubess_cooker_indicator_light_mode-entry] diff --git a/tests/components/tuya/snapshots/test_sensor.ambr b/tests/components/tuya/snapshots/test_sensor.ambr index 172531124fd..423f06f9005 100644 --- a/tests/components/tuya/snapshots/test_sensor.ambr +++ b/tests/components/tuya/snapshots/test_sensor.ambr @@ -507,6 +507,54 @@ 'state': '100.0', }) # --- +# name: test_platform_setup_and_discovery[sensor.aqi_battery_state-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': , + 'entity_id': 'sensor.aqi_battery_state', + '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': 'Battery state', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'battery_state', + 'unique_id': 'tuya.iks13mcaiyie3rryjb2ocbattery_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_platform_setup_and_discovery[sensor.aqi_battery_state-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'AQI Battery state', + }), + 'context': , + 'entity_id': 'sensor.aqi_battery_state', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'normal', + }) +# --- # name: test_platform_setup_and_discovery[sensor.aqi_carbon_dioxide-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -560,7 +608,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '541.0', + 'state': '419.0', }) # --- # name: test_platform_setup_and_discovery[sensor.aqi_formaldehyde-entry] @@ -612,7 +660,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '0.002', + 'state': '0.006', }) # --- # name: test_platform_setup_and_discovery[sensor.aqi_humidity-entry] @@ -665,7 +713,60 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '53.0', + 'state': '54.0', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.aqi_pm10-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.aqi_pm10', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'PM10', + 'platform': 'tuya', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'pm10', + 'unique_id': 'tuya.iks13mcaiyie3rryjb2ocpm10', + 'unit_of_measurement': 'μg/m³', + }) +# --- +# name: test_platform_setup_and_discovery[sensor.aqi_pm10-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'pm10', + 'friendly_name': 'AQI PM10', + 'state_class': , + 'unit_of_measurement': 'μg/m³', + }), + 'context': , + 'entity_id': 'sensor.aqi_pm10', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '8.0', }) # --- # name: test_platform_setup_and_discovery[sensor.aqi_pm2_5-entry] @@ -721,7 +822,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '17.0', + 'state': '7.0', }) # --- # name: test_platform_setup_and_discovery[sensor.aqi_temperature-entry] @@ -777,7 +878,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '26.0', + 'state': '24.0', }) # --- # name: test_platform_setup_and_discovery[sensor.aqi_volatile_organic_compounds-entry] @@ -830,7 +931,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '0.018', + 'state': '0.071', }) # --- # name: test_platform_setup_and_discovery[sensor.aubess_cooker_current-entry]