forked from home-assistant/core
Do not provide icon if device class is set in ESPHome config (#46650)
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user