Skip to content

Commit

Permalink
Add icons to Coronavirus (home-assistant#32480)
Browse files Browse the repository at this point in the history
* Add icons to Coronavirus

* Update homeassistant/components/coronavirus/sensor.py

Co-authored-by: Paulus Schoutsen <[email protected]>
  • Loading branch information
Quentame and balloob authored Mar 4, 2020
1 parent 9a8017a commit 15a5ceb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion homeassistant/components/coronavirus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
from . import get_coordinator
from .const import ATTRIBUTION, OPTION_WORLDWIDE

SENSORS = {
"confirmed": "mdi:emoticon-neutral-outline",
"current": "mdi:emoticon-frown-outline",
"recovered": "mdi:emoticon-happy-outline",
"deaths": "mdi:emoticon-dead-outline",
}


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Defer sensor setup to the shared sensor module."""
coordinator = await get_coordinator(hass)

async_add_entities(
CoronavirusSensor(coordinator, config_entry.data["country"], info_type)
for info_type in ("confirmed", "recovered", "deaths", "current")
for info_type in SENSORS
)


Expand Down Expand Up @@ -50,6 +57,11 @@ def state(self):

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."""
Expand Down

0 comments on commit 15a5ceb

Please sign in to comment.