mirror of https://github.com/home-assistant/core
Add device_class attribute to ESPHome sensor entities (#46595)
This commit is contained in:
parent
3c26235e78
commit
1e172dedf6
|
@ -3,7 +3,7 @@
|
|||
"name": "ESPHome",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
||||
"requirements": ["aioesphomeapi==2.6.4"],
|
||||
"requirements": ["aioesphomeapi==2.6.5"],
|
||||
"zeroconf": ["_esphomelib._tcp.local."],
|
||||
"codeowners": ["@OttoWinter"],
|
||||
"after_dependencies": ["zeroconf", "tag"]
|
||||
|
|
|
@ -52,6 +52,8 @@ class EsphomeSensor(EsphomeEntity):
|
|||
@property
|
||||
def icon(self) -> str:
|
||||
"""Return the icon."""
|
||||
if self._static_info.icon == "":
|
||||
return None
|
||||
return self._static_info.icon
|
||||
|
||||
@property
|
||||
|
@ -71,8 +73,17 @@ 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 == "":
|
||||
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 == "":
|
||||
return None
|
||||
return self._static_info.device_class
|
||||
|
||||
|
||||
class EsphomeTextSensor(EsphomeEntity):
|
||||
"""A text sensor implementation for ESPHome."""
|
||||
|
|
|
@ -154,7 +154,7 @@ aiodns==2.0.0
|
|||
aioeafm==0.1.2
|
||||
|
||||
# homeassistant.components.esphome
|
||||
aioesphomeapi==2.6.4
|
||||
aioesphomeapi==2.6.5
|
||||
|
||||
# homeassistant.components.flo
|
||||
aioflo==0.4.1
|
||||
|
|
|
@ -91,7 +91,7 @@ aiodns==2.0.0
|
|||
aioeafm==0.1.2
|
||||
|
||||
# homeassistant.components.esphome
|
||||
aioesphomeapi==2.6.4
|
||||
aioesphomeapi==2.6.5
|
||||
|
||||
# homeassistant.components.flo
|
||||
aioflo==0.4.1
|
||||
|
|
Loading…
Reference in New Issue