Add snapshot tests for tuya co2bj and gyd categories (#148872)

This commit is contained in:
epenet 2025-07-16 10:38:43 +02:00 committed by GitHub
parent 6833bf1900
commit 033d8b3dfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 1066 additions and 0 deletions

View File

@ -23,6 +23,14 @@ DEVICE_MOCKS = {
Platform.COVER,
Platform.LIGHT,
],
"co2bj_air_detector": [
# https://github.com/home-assistant/core/issues/133173
Platform.BINARY_SENSOR,
Platform.NUMBER,
Platform.SELECT,
Platform.SENSOR,
Platform.SIREN,
],
"cs_arete_two_12l_dehumidifier_air_purifier": [
Platform.BINARY_SENSOR,
Platform.FAN,
@ -75,6 +83,10 @@ DEVICE_MOCKS = {
# https://github.com/home-assistant/core/issues/143499
Platform.SENSOR,
],
"gyd_night_light": [
# https://github.com/home-assistant/core/issues/133173
Platform.LIGHT,
],
"kg_smart_valve": [
# https://github.com/home-assistant/core/issues/148347
Platform.SWITCH,

View File

@ -0,0 +1,174 @@
{
"endpoint": "https://apigw.tuyaus.com",
"terminal_id": "1732306182276g6jQLp",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"id": "eb14fd1dd93ca2ea34vpin",
"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",
"function": {
"alarm_volume": {
"type": "Enum",
"value": {
"range": ["low", "middle", "high", "mute"]
}
},
"alarm_time": {
"type": "Integer",
"value": {
"unit": "s",
"min": 1,
"max": 60,
"scale": 0,
"step": 1
}
},
"alarm_switch": {
"type": "Boolean",
"value": {}
},
"alarm_bright": {
"type": "Integer",
"value": {
"unit": "%",
"min": 0,
"max": 100,
"scale": 0,
"step": 1
}
}
},
"status_range": {
"co2_state": {
"type": "Enum",
"value": {
"range": ["alarm", "normal"]
}
},
"co2_value": {
"type": "Integer",
"value": {
"unit": "ppm",
"min": 0,
"max": 5000,
"scale": 0,
"step": 1
}
},
"alarm_volume": {
"type": "Enum",
"value": {
"range": ["low", "middle", "high", "mute"]
}
},
"alarm_time": {
"type": "Integer",
"value": {
"unit": "s",
"min": 1,
"max": 60,
"scale": 0,
"step": 1
}
},
"alarm_switch": {
"type": "Boolean",
"value": {}
},
"battery_percentage": {
"type": "Integer",
"value": {
"unit": "%",
"min": 0,
"max": 100,
"scale": 0,
"step": 1
}
},
"alarm_bright": {
"type": "Integer",
"value": {
"unit": "%",
"min": 0,
"max": 100,
"scale": 0,
"step": 1
}
},
"temp_current": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": -9,
"max": 199,
"scale": 0,
"step": 1
}
},
"humidity_value": {
"type": "Integer",
"value": {
"unit": "%",
"min": 0,
"max": 100,
"scale": 0,
"step": 1
}
},
"pm25_value": {
"type": "Integer",
"value": {
"unit": "ug/m3",
"min": 0,
"max": 1000,
"scale": 0,
"step": 1
}
},
"voc_value": {
"type": "Integer",
"value": {
"unit": "mg/m3",
"min": 0,
"max": 9999,
"scale": 3,
"step": 1
}
},
"ch2o_value": {
"type": "Integer",
"value": {
"unit": "mg/m3",
"min": 0,
"max": 9999,
"scale": 3,
"step": 1
}
}
},
"status": {
"co2_state": "normal",
"co2_value": 541,
"alarm_volume": "low",
"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
},
"set_up": true,
"support_local": true
}

View File

@ -0,0 +1,266 @@
{
"endpoint": "https://apigw.tuyaus.com",
"terminal_id": "1732306182276g6jQLp",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"id": "eb3e988f33c233290cfs3l",
"name": "Colorful PIR Night Light",
"category": "gyd",
"product_id": "lgekqfxdabipm3tn",
"product_name": "Colorful PIR Night Light",
"online": true,
"sub": false,
"time_zone": "+07:00",
"active_time": "2024-07-18T12:02:37+00:00",
"create_time": "2024-07-18T12:02:37+00:00",
"update_time": "2024-07-18T12:02:37+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": {}
},
"scene_data": {
"type": "Json",
"value": {}
},
"countdown": {
"type": "Integer",
"value": {
"unit": "s",
"min": 0,
"max": 86400,
"scale": 0,
"step": 1
}
},
"control_data": {
"type": "String",
"value": {
"maxlen": 255
}
},
"device_mode": {
"type": "Enum",
"value": {
"range": ["auto", "manual"]
}
},
"cds": {
"type": "Enum",
"value": {
"range": ["2000lux", "300lux", "50lux", "10lux", "5lux"]
}
},
"pir_sensitivity": {
"type": "Enum",
"value": {
"range": ["low", "middle", "high"]
}
},
"pir_delay": {
"type": "Integer",
"value": {
"unit": "s",
"min": 5,
"max": 3600,
"scale": 0,
"step": 1
}
},
"switch_pir": {
"type": "Boolean",
"value": {}
},
"standby_time": {
"type": "Integer",
"value": {
"unit": "min",
"min": 1,
"max": 480,
"scale": 0,
"step": 1
}
},
"standby_bright": {
"type": "Integer",
"value": {
"min": 0,
"max": 1000,
"scale": 0,
"step": 1
}
}
},
"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": {}
},
"scene_data": {
"type": "Json",
"value": {}
},
"countdown": {
"type": "Integer",
"value": {
"unit": "s",
"min": 0,
"max": 86400,
"scale": 0,
"step": 1
}
},
"device_mode": {
"type": "Enum",
"value": {
"range": ["auto", "manual"]
}
},
"pir_state": {
"type": "Enum",
"value": {
"range": ["pir", "none"]
}
},
"cds": {
"type": "Enum",
"value": {
"range": ["2000lux", "300lux", "50lux", "10lux", "5lux"]
}
},
"pir_sensitivity": {
"type": "Enum",
"value": {
"range": ["low", "middle", "high"]
}
},
"pir_delay": {
"type": "Integer",
"value": {
"unit": "s",
"min": 5,
"max": 3600,
"scale": 0,
"step": 1
}
},
"switch_pir": {
"type": "Boolean",
"value": {}
},
"standby_time": {
"type": "Integer",
"value": {
"unit": "min",
"min": 1,
"max": 480,
"scale": 0,
"step": 1
}
},
"standby_bright": {
"type": "Integer",
"value": {
"min": 0,
"max": 1000,
"scale": 0,
"step": 1
}
}
},
"status": {
"switch_led": false,
"work_mode": "white",
"bright_value": 1000,
"temp_value": 1,
"colour_data": {
"h": 0,
"s": 1000,
"v": 1000
},
"scene_data": {
"scene_num": 1,
"scene_units": [
{
"bright": 200,
"h": 0,
"s": 0,
"temperature": 0,
"unit_change_mode": "static",
"unit_gradient_duration": 13,
"unit_switch_duration": 14,
"v": 0
}
]
},
"countdown": 0,
"device_mode": "auto",
"pir_state": "none",
"cds": "5lux",
"pir_sensitivity": "middle",
"pir_delay": 30,
"switch_pir": true,
"standby_time": 1,
"standby_bright": 146
},
"set_up": true,
"support_local": true
}

View File

@ -1,4 +1,53 @@
# serializer version: 1
# name: test_platform_setup_and_discovery[co2bj_air_detector][binary_sensor.aqi_safety-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': None,
'entity_id': 'binary_sensor.aqi_safety',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.SAFETY: 'safety'>,
'original_icon': None,
'original_name': 'Safety',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinco2_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][binary_sensor.aqi_safety-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'safety',
'friendly_name': 'AQI Safety',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.aqi_safety',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[cs_arete_two_12l_dehumidifier_air_purifier][binary_sensor.dehumidifier_defrost-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -56,6 +56,79 @@
'state': 'on',
})
# ---
# name: test_platform_setup_and_discovery[gyd_night_light][light.colorful_pir_night_light-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([
<ColorMode.COLOR_TEMP: 'color_temp'>,
<ColorMode.HS: 'hs'>,
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.colorful_pir_night_light',
'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': 0,
'translation_key': None,
'unique_id': 'tuya.eb3e988f33c233290cfs3lswitch_led',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[gyd_night_light][light.colorful_pir_night_light-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'brightness': None,
'color_mode': None,
'color_temp': None,
'color_temp_kelvin': None,
'friendly_name': 'Colorful PIR Night Light',
'hs_color': None,
'max_color_temp_kelvin': 6500,
'max_mireds': 500,
'min_color_temp_kelvin': 2000,
'min_mireds': 153,
'rgb_color': None,
'supported_color_modes': list([
<ColorMode.COLOR_TEMP: 'color_temp'>,
<ColorMode.HS: 'hs'>,
]),
'supported_features': <LightEntityFeature: 0>,
'xy_color': None,
}),
'context': <ANY>,
'entity_id': 'light.colorful_pir_night_light',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_platform_setup_and_discovery[ks_tower_fan][light.tower_fan_ca_407g_smart_backlight-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -1,4 +1,63 @@
# serializer version: 1
# name: test_platform_setup_and_discovery[co2bj_air_detector][number.aqi_alarm_duration-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 60.0,
'min': 1.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'number.aqi_alarm_duration',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <NumberDeviceClass.DURATION: 'duration'>,
'original_icon': None,
'original_name': 'Alarm duration',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'alarm_duration',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinalarm_time',
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][number.aqi_alarm_duration-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'AQI Alarm duration',
'max': 60.0,
'min': 1.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
}),
'context': <ANY>,
'entity_id': 'number.aqi_alarm_duration',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '1.0',
})
# ---
# name: test_platform_setup_and_discovery[cwwsq_cleverio_pf100][number.cleverio_pf100_feed-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -56,6 +56,67 @@
'state': 'forward',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][select.aqi_volume-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'low',
'middle',
'high',
'mute',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'select.aqi_volume',
'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': 'Volume',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'volume',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinalarm_volume',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][select.aqi_volume-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'AQI Volume',
'options': list([
'low',
'middle',
'high',
'mute',
]),
}),
'context': <ANY>,
'entity_id': 'select.aqi_volume',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'low',
})
# ---
# name: test_platform_setup_and_discovery[cs_arete_two_12l_dehumidifier_air_purifier][select.dehumidifier_countdown-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -1,4 +1,271 @@
# serializer version: 1
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.aqi_battery',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.BATTERY: 'battery'>,
'original_icon': None,
'original_name': 'Battery',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinbattery_percentage',
'unit_of_measurement': '%',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_battery-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'AQI Battery',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'sensor.aqi_battery',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '100.0',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_formaldehyde-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.aqi_formaldehyde',
'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': 'Formaldehyde',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'formaldehyde',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinch2o_value',
'unit_of_measurement': 'mg/m3',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_formaldehyde-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'AQI Formaldehyde',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'mg/m3',
}),
'context': <ANY>,
'entity_id': 'sensor.aqi_formaldehyde',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.002',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_humidity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.aqi_humidity',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.HUMIDITY: 'humidity'>,
'original_icon': None,
'original_name': 'Humidity',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'humidity',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinhumidity_value',
'unit_of_measurement': '%',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_humidity-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'humidity',
'friendly_name': 'AQI Humidity',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'sensor.aqi_humidity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '53.0',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.aqi_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Temperature',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'temperature',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpintemp_current',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'AQI Temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.aqi_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '26.0',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_volatile_organic_compounds-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.aqi_volatile_organic_compounds',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: 'volatile_organic_compounds'>,
'original_icon': None,
'original_name': 'Volatile organic compounds',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'voc',
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinvoc_value',
'unit_of_measurement': 'mg/m³',
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][sensor.aqi_volatile_organic_compounds-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'volatile_organic_compounds',
'friendly_name': 'AQI Volatile organic compounds',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'mg/m³',
}),
'context': <ANY>,
'entity_id': 'sensor.aqi_volatile_organic_compounds',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.018',
})
# ---
# name: test_platform_setup_and_discovery[cs_arete_two_12l_dehumidifier_air_purifier][sensor.dehumidifier_humidity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -0,0 +1,50 @@
# serializer version: 1
# name: test_platform_setup_and_discovery[co2bj_air_detector][siren.aqi-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': 'siren',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'siren.aqi',
'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': <SirenEntityFeature: 3>,
'translation_key': None,
'unique_id': 'tuya.eb14fd1dd93ca2ea34vpinalarm_switch',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[co2bj_air_detector][siren.aqi-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'AQI',
'supported_features': <SirenEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'siren.aqi',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

View File

@ -0,0 +1,55 @@
"""Test Tuya siren platform."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from syrupy.assertion import SnapshotAssertion
from tuya_sharing import CustomerDevice
from homeassistant.components.tuya import ManagerCompat
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import DEVICE_MOCKS, initialize_entry
from tests.common import MockConfigEntry, snapshot_platform
@pytest.mark.parametrize(
"mock_device_code", [k for k, v in DEVICE_MOCKS.items() if Platform.SIREN in v]
)
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.SIREN])
async def test_platform_setup_and_discovery(
hass: HomeAssistant,
mock_manager: ManagerCompat,
mock_config_entry: MockConfigEntry,
mock_device: CustomerDevice,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test platform setup and discovery."""
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.parametrize(
"mock_device_code", [k for k, v in DEVICE_MOCKS.items() if Platform.SIREN not in v]
)
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.SIREN])
async def test_platform_setup_no_discovery(
hass: HomeAssistant,
mock_manager: ManagerCompat,
mock_config_entry: MockConfigEntry,
mock_device: CustomerDevice,
entity_registry: er.EntityRegistry,
) -> None:
"""Test platform setup without discovery."""
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
assert not er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)