Example coronavirus integration

This commit is contained in:
Franck Nijhof
2021-05-21 13:14:32 +02:00
parent 7ff574b7ea
commit 74127c66ba

View File

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