Fix missing unit of measurement in tuya numbers (#148924)

This commit is contained in:
epenet 2025-07-17 08:55:47 +02:00 committed by GitHub
parent e32e06d7a0
commit ae03fc2295
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -381,6 +381,8 @@ class TuyaNumberEntity(TuyaEntity, NumberEntity):
self._attr_native_max_value = self._number.max_scaled self._attr_native_max_value = self._number.max_scaled
self._attr_native_min_value = self._number.min_scaled self._attr_native_min_value = self._number.min_scaled
self._attr_native_step = self._number.step_scaled self._attr_native_step = self._number.step_scaled
if description.native_unit_of_measurement is None:
self._attr_native_unit_of_measurement = int_type.unit
# Logic to ensure the set device class and API received Unit Of Measurement # Logic to ensure the set device class and API received Unit Of Measurement
# match Home Assistants requirements. # match Home Assistants requirements.

View File

@ -95,7 +95,7 @@
'supported_features': 0, 'supported_features': 0,
'translation_key': 'feed', 'translation_key': 'feed',
'unique_id': 'tuya.bfd0273e59494eb34esvrxmanual_feed', 'unique_id': 'tuya.bfd0273e59494eb34esvrxmanual_feed',
'unit_of_measurement': None, 'unit_of_measurement': '',
}) })
# --- # ---
# name: test_platform_setup_and_discovery[cwwsq_cleverio_pf100][number.cleverio_pf100_feed-state] # name: test_platform_setup_and_discovery[cwwsq_cleverio_pf100][number.cleverio_pf100_feed-state]
@ -106,6 +106,7 @@
'min': 1.0, 'min': 1.0,
'mode': <NumberMode.AUTO: 'auto'>, 'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0, 'step': 1.0,
'unit_of_measurement': '',
}), }),
'context': <ANY>, 'context': <ANY>,
'entity_id': 'number.cleverio_pf100_feed', 'entity_id': 'number.cleverio_pf100_feed',
@ -152,7 +153,7 @@
'supported_features': 0, 'supported_features': 0,
'translation_key': 'temp_correction', 'translation_key': 'temp_correction',
'unique_id': 'tuya.bfb45cb8a9452fba66lexgtemp_correction', 'unique_id': 'tuya.bfb45cb8a9452fba66lexgtemp_correction',
'unit_of_measurement': None, 'unit_of_measurement': '℃',
}) })
# --- # ---
# name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][number.wifi_smart_gas_boiler_thermostat_temperature_correction-state] # name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][number.wifi_smart_gas_boiler_thermostat_temperature_correction-state]
@ -163,6 +164,7 @@
'min': -9.9, 'min': -9.9,
'mode': <NumberMode.AUTO: 'auto'>, 'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.1, 'step': 0.1,
'unit_of_measurement': '℃',
}), }),
'context': <ANY>, 'context': <ANY>,
'entity_id': 'number.wifi_smart_gas_boiler_thermostat_temperature_correction', 'entity_id': 'number.wifi_smart_gas_boiler_thermostat_temperature_correction',