mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 05:35:11 +02:00
Example coronavirus integration
This commit is contained in:
@@ -38,8 +38,9 @@ class CoronavirusSensor(CoordinatorEntity, SensorEntity):
|
|||||||
else:
|
else:
|
||||||
self.name = f"{coordinator.data[country].country} Coronavirus {info_type}"
|
self.name = f"{coordinator.data[country].country} Coronavirus {info_type}"
|
||||||
self.unique_id = f"{country}-{info_type}"
|
self.unique_id = f"{country}-{info_type}"
|
||||||
self.country = country
|
|
||||||
self.info_type = info_type
|
self._icon = SENSORS[self.info_type]
|
||||||
|
self._unit_of_measurement = "people"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
@@ -63,16 +64,6 @@ class CoronavirusSensor(CoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
return getattr(self.coordinator.data[self.country], self.info_type)
|
return getattr(self.coordinator.data[self.country], self.info_type)
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Return the icon."""
|
|
||||||
return SENSORS[self.info_type]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return unit of measurement."""
|
|
||||||
return "people"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return device attributes."""
|
"""Return device attributes."""
|
||||||
|
Reference in New Issue
Block a user