Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
Update for new source format
Browse files Browse the repository at this point in the history
You know the drill by now...
  • Loading branch information
foosel committed Apr 29, 2020
1 parent dede994 commit 5349aa8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 3 additions & 4 deletions custom_components/coronavirus_hessen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ async def async_get_data():

for row in rows[2:]:
line = row.select("td")
if len(line) != 7:
if len(line) != 6:
continue

try:
county = line[0].get_text(" ", strip=True)
cases = parse_num(line[1].get_text(" ", strip=True))
hospitalized = parse_num(line[2].get_text(" ", strip=True))
deaths = parse_num(line[3].get_text(" ", strip=True))
deaths = parse_num(line[2].get_text(" ", strip=True))
except:
_LOGGER.exception("Error processing line {}, skipping".format(line))
continue
Expand All @@ -94,7 +93,7 @@ async def async_get_data():
if county == "Gesamtergebnis":
county = OPTION_TOTAL

result[county] = dict(cases=cases, hospitalized=hospitalized, deaths=deaths)
result[county] = dict(cases=cases, deaths=deaths)

_LOGGER.debug("Corona Hessen: {!r}".format(result))
return result
Expand Down
2 changes: 0 additions & 2 deletions custom_components/coronavirus_hessen/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
_LOGGER = logging.getLogger(__name__)

ATTR_DEATHS = "deaths"
ATTR_HOSPITALIZED = "hospitalized"

async def async_setup_entry(hass, config_entry, async_add_entities):
"""Defer sensor setup to the shared sensor module."""
Expand Down Expand Up @@ -60,7 +59,6 @@ def state(self):
@property
def device_state_attributes(self):
return {ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_HOSPITALIZED: self.coordinator.data[self.county]["hospitalized"],
ATTR_DEATHS: self.coordinator.data[self.county]["deaths"]}

async def async_added_to_hass(self):
Expand Down

0 comments on commit 5349aa8

Please sign in to comment.