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
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