mirror of
https://github.com/home-assistant/core.git
synced 2025-09-04 12:21:36 +02:00
Fix issue with Tuya suggested unit (#150414)
This commit is contained in:
@@ -1496,6 +1496,7 @@ class TuyaSensorEntity(TuyaEntity, SensorEntity):
|
||||
self.unique_id,
|
||||
)
|
||||
self._attr_device_class = None
|
||||
self._attr_suggested_unit_of_measurement = None
|
||||
return
|
||||
|
||||
uoms = DEVICE_CLASS_UNITS[self.device_class]
|
||||
@@ -1506,6 +1507,7 @@ class TuyaSensorEntity(TuyaEntity, SensorEntity):
|
||||
# Unknown unit of measurement, device class should not be used.
|
||||
if uom is None:
|
||||
self._attr_device_class = None
|
||||
self._attr_suggested_unit_of_measurement = None
|
||||
return
|
||||
|
||||
# Found unit of measurement, use the standardized Unit
|
||||
|
@@ -114,6 +114,7 @@ DEVICE_MOCKS = {
|
||||
"kj_CAjWAxBUZt7QZHfz": [
|
||||
# https://github.com/home-assistant/core/issues/146023
|
||||
Platform.FAN,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
],
|
||||
"kj_yrzylxax1qspdgpp": [
|
||||
|
@@ -1649,6 +1649,58 @@
|
||||
'state': '220.4',
|
||||
})
|
||||
# ---
|
||||
# name: test_platform_setup_and_discovery[kj_CAjWAxBUZt7QZHfz][sensor.hl400_pm2_5-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.hl400_pm2_5',
|
||||
'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': 'PM2.5',
|
||||
'platform': 'tuya',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'pm25',
|
||||
'unique_id': 'tuya.152027113c6105cce49cpm25',
|
||||
'unit_of_measurement': '',
|
||||
})
|
||||
# ---
|
||||
# name: test_platform_setup_and_discovery[kj_CAjWAxBUZt7QZHfz][sensor.hl400_pm2_5-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'HL400 PM2.5',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': '',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.hl400_pm2_5',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '45.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_platform_setup_and_discovery[mcs_7jIGJAymiH8OsFFb][sensor.door_garage_battery-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
Reference in New Issue
Block a user