Do not provide icon if device class is set in ESPHome config (#46650)
parent
960b5b7d86
commit
c45ce86e53
|
@ -52,7 +52,7 @@ class EsphomeSensor(EsphomeEntity):
|
|||
@property
|
||||
def icon(self) -> str:
|
||||
"""Return the icon."""
|
||||
if self._static_info.icon == "":
|
||||
if not self._static_info.icon or self._static_info.device_class:
|
||||
return None
|
||||
return self._static_info.icon
|
||||
|
||||
|
@ -73,14 +73,14 @@ class EsphomeSensor(EsphomeEntity):
|
|||
@property
|
||||
def unit_of_measurement(self) -> str:
|
||||
"""Return the unit the value is expressed in."""
|
||||
if self._static_info.unit_of_measurement == "":
|
||||
if not self._static_info.unit_of_measurement:
|
||||
return None
|
||||
return self._static_info.unit_of_measurement
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
if self._static_info.device_class == "":
|
||||
if not self._static_info.device_class:
|
||||
return None
|
||||
return self._static_info.device_class
|
||||
|
||||
|
|
Loading…
Reference in New Issue