3 Commits

Author SHA1 Message Date
Adrian Rumpold
62904f4c09 fix(parser): Update infection data parser for new web page layout
Closes #4
2021-09-17 08:30:48 +02:00
Adrian Rumpold
35d5232d8e feat: Use syringe MDI icon for vaccination entity 2021-08-11 10:57:03 +02:00
Adrian Rumpold
1c3b0ae0b5 Merge pull request #3 from AdrianoKF/feature/vaccination-data
Crawling and parsing of vaccination data, see #2
2021-08-11 10:35:21 +02:00
4 changed files with 9 additions and 12 deletions

View File

@@ -41,7 +41,7 @@ entities:
format: precision1 format: precision1
unit: '%' unit: '%'
show_state: false show_state: false
icon: mdi:biohazard icon: mdi:needle
name: COVID-19 Vaccinations name: COVID-19 Vaccinations
secondary_info: secondary_info:
attribute: date attribute: date

View File

@@ -107,8 +107,8 @@ class CovidCrawler(CovidCrawlerBase):
) )
soup = await self._fetch(url) soup = await self._fetch(url)
match = soup.find(class_="frame--type-textpic") match = soup.find(id="c1067628")
text = match.p.text text = match.text.strip()
_log.debug(f"Infection data text: {text}") _log.debug(f"Infection data text: {text}")
matches = re.search(r"(\d+,\d+)\sNeuinfektion", text) matches = re.search(r"(\d+,\d+)\sNeuinfektion", text)
@@ -120,18 +120,15 @@ class CovidCrawler(CovidCrawlerBase):
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 match = soup.find(id="c1052517")
matches = re.search(r"\((\d+)\. (\w+).*\)", text) text = match.text.strip()
matches = re.search(r"Stand: (\d+)\. (\w+) (\d{4})", text)
if not matches: if not matches:
raise ValueError(f"Could not extract date from scraped web page, {text=}") raise ValueError(f"Could not extract date from scraped web page, {text=}")
date = parse_date(matches.group(1), matches.group(2)) date = parse_date(matches.group(1), matches.group(2), matches.group(3))
_log.debug(f"Parsed date: {date}") _log.debug(f"Parsed date: {date}")
match = match.find_next_sibling(class_="frame--type-textpic")
text = match.text
_log.debug(f"Infection counts text: {text}")
regexes = [ regexes = [
r"Insgesamt: (?P<total_cases>[0-9.]+)", r"Insgesamt: (?P<total_cases>[0-9.]+)",
r"genesen: (?P<num_recovered>[0-9.]+)", r"genesen: (?P<num_recovered>[0-9.]+)",

View File

@@ -1,7 +1,7 @@
{ {
"domain": "covid19_augsburg", "domain": "covid19_augsburg",
"name": "COVID-19 Augsburg", "name": "COVID-19 Augsburg",
"version": "1.1.0", "version": "1.1.1",
"config_flow": true, "config_flow": true,
"documentation": "https://github.com/AdrianoKF/home-assistant-covid19-augsburg", "documentation": "https://github.com/AdrianoKF/home-assistant-covid19-augsburg",
"issue_tracker": "https://github.com/AdrianoKF/home-assistant-covid19-augsburg/issues", "issue_tracker": "https://github.com/AdrianoKF/home-assistant-covid19-augsburg/issues",

View File

@@ -87,7 +87,7 @@ class CoronaAugsburgVaccinationSensor(Entity):
@property @property
def icon(self): def icon(self):
return "mdi:biohazard" return "mdi:needle"
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):