2 Commits

Author SHA1 Message Date
Adrian Rumpold
28eb982e5e docs: Update readme 2021-07-01 13:16:24 +02:00
Adrian Rumpold
6a03aba4e9 fix: Deal with new date format, better error handling 2021-07-01 13:11:04 +02:00
2 changed files with 29 additions and 5 deletions

View File

@@ -1,5 +1,27 @@
# Home Assistant Augsburg COVID-19 Tracker Integration # Home Assistant Augsburg COVID-19 Tracker Integration
## Requirements ## Adding to your dashboard
Your system needs to have the `de_DE.utf8` locale installed in order to parse the dates from the scraped web response. You can add an overview of the current infection numbers to your dashboard using the [multiple-entity-row](https://github.com/benct/lovelace-multiple-entity-row) card:
```yaml
type: entities
entities:
- type: custom:multiple-entity-row
entity: sensor.coronavirus_augsburg
entities:
- attribute: total_cases
name: Cases
- attribute: num_dead
name: Deaths
- attribute: num_recovered
name: Recovered
- attribute: num_infected
name: Infected
show_state: false
icon: mdi:biohazard
name: COVID-19
secondary_info:
attribute: incidence
unit: cases/100k
```

View File

@@ -67,15 +67,17 @@ class CovidCrawler(CovidCrawlerBase):
matches = re.search(r"(\d+,\d+)\sNeuinfektion", text) matches = re.search(r"(\d+,\d+)\sNeuinfektion", text)
if not matches: if not matches:
raise ValueError("Could not extract incidence from scraped web page") raise ValueError(
f"Could not extract incidence from scraped web page, {text=}"
)
incidence = parse_num(matches.group(1), t=float) incidence = parse_num(matches.group(1), t=float)
_log.debug(f"Parsed incidence: {incidence}") _log.debug(f"Parsed incidence: {incidence}")
text = match.h2.text text = match.h2.text
matches = re.search(r"\((\d+)\. (\w+)\)", text) matches = re.search(r"\((\d+)\. (\w+).*\)", text)
if not matches: if not matches:
raise ValueError("Could not extract date from scraped web page") raise ValueError(f"Could not extract date from scraped web page, {text=}")
months = [ months = [
"Januar", "Januar",