Do not provide icon if device class is set in ESPHome config (#46650)

This commit is contained in:
marecabo 2021-02-16 20:36:32 +01:00 committed by GitHub
parent 960b5b7d86
commit c45ce86e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,7 @@ class EsphomeSensor(EsphomeEntity):
@property @property
def icon(self) -> str: def icon(self) -> str:
"""Return the icon.""" """Return the icon."""
if self._static_info.icon == "": if not self._static_info.icon or self._static_info.device_class:
return None return None
return self._static_info.icon return self._static_info.icon
@ -73,14 +73,14 @@ class EsphomeSensor(EsphomeEntity):
@property @property
def unit_of_measurement(self) -> str: def unit_of_measurement(self) -> str:
"""Return the unit the value is expressed in.""" """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 None
return self._static_info.unit_of_measurement return self._static_info.unit_of_measurement
@property @property
def device_class(self) -> str: def device_class(self) -> str:
"""Return the class of this device, from component DEVICE_CLASSES.""" """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 None
return self._static_info.device_class return self._static_info.device_class