Add device_class attribute to ESPHome sensor entities (#46595)

This commit is contained in:
marecabo 2021-02-16 07:19:31 +01:00 committed by GitHub
parent 3c26235e78
commit 1e172dedf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -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"]

View File

@ -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."""

View File

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

View File

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