Handle empty strings for ESPHome UOMs (#96556)
This commit is contained in:
parent
72458b6672
commit
b77de2abaf
4 changed files with 70 additions and 4 deletions
|
@ -63,7 +63,10 @@ class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
|||
self._attr_native_min_value = static_info.min_value
|
||||
self._attr_native_max_value = static_info.max_value
|
||||
self._attr_native_step = static_info.step
|
||||
self._attr_native_unit_of_measurement = static_info.unit_of_measurement
|
||||
# protobuf doesn't support nullable strings so we need to check
|
||||
# if the string is empty
|
||||
if unit_of_measurement := static_info.unit_of_measurement:
|
||||
self._attr_native_unit_of_measurement = unit_of_measurement
|
||||
if mode := static_info.mode:
|
||||
self._attr_mode = NUMBER_MODES.from_esphome(mode)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue