Compare commits
11 Commits
v1.0.3-rc2
...
v1.1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81c19b552d | ||
|
|
0d609ade9a | ||
|
|
2b453f4b5e | ||
|
|
62904f4c09 | ||
|
|
35d5232d8e | ||
|
|
1c3b0ae0b5 | ||
|
|
d2e8f77725 | ||
|
|
92e99e03ef | ||
|
|
903a512f99 | ||
|
|
f385ee3a5a | ||
|
|
573f91e2f9 |
24
README.md
24
README.md
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
## Adding to your dashboard
|
## Adding to your dashboard
|
||||||
|
|
||||||
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:
|
You can add an overview of the current infection and vaccination numbers to your dashboard
|
||||||
|
using the [multiple-entity-row](https://github.com/benct/lovelace-multiple-entity-row) card:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
type: entities
|
type: entities
|
||||||
@@ -24,4 +25,25 @@ entities:
|
|||||||
secondary_info:
|
secondary_info:
|
||||||
attribute: incidence
|
attribute: incidence
|
||||||
unit: cases/100k
|
unit: cases/100k
|
||||||
|
- type: custom:multiple-entity-row
|
||||||
|
entity: sensor.covid_19_vaccinations_augsburg
|
||||||
|
entities:
|
||||||
|
- attribute: ratio_vaccinated_once
|
||||||
|
name: Once
|
||||||
|
format: precision1
|
||||||
|
unit: '%'
|
||||||
|
- attribute: ratio_vaccinated_full
|
||||||
|
name: Fully
|
||||||
|
format: precision1
|
||||||
|
unit: '%'
|
||||||
|
- attribute: ratio_vaccinated_total
|
||||||
|
name: Total
|
||||||
|
format: precision1
|
||||||
|
unit: '%'
|
||||||
|
show_state: false
|
||||||
|
icon: mdi:needle
|
||||||
|
name: COVID-19 Vaccinations
|
||||||
|
secondary_info:
|
||||||
|
attribute: date
|
||||||
|
format: date
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class VaccinationData:
|
|||||||
|
|
||||||
ratio_vaccinated_once: float = 0.0
|
ratio_vaccinated_once: float = 0.0
|
||||||
ratio_vaccinated_full: float = 0.0
|
ratio_vaccinated_full: float = 0.0
|
||||||
|
ratio_vaccinated_total: float = 0.0
|
||||||
|
|
||||||
|
|
||||||
class CovidCrawlerBase(ABC):
|
class CovidCrawlerBase(ABC):
|
||||||
@@ -106,11 +107,11 @@ 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)
|
||||||
if not matches:
|
if not matches:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Could not extract incidence from scraped web page, {text=}"
|
f"Could not extract incidence from scraped web page, {text=}"
|
||||||
@@ -119,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.]+)",
|
||||||
@@ -194,8 +192,11 @@ class CovidCrawler(CovidCrawlerBase):
|
|||||||
# https://www.augsburg.de/fileadmin/user_upload/buergerservice_rathaus/rathaus/statisiken_und_geodaten/statistiken/Monitoring/Demografiemonitoring_der_Stadt_Augsburg_2021.pdf
|
# https://www.augsburg.de/fileadmin/user_upload/buergerservice_rathaus/rathaus/statisiken_und_geodaten/statistiken/Monitoring/Demografiemonitoring_der_Stadt_Augsburg_2021.pdf
|
||||||
population = 299021
|
population = 299021
|
||||||
|
|
||||||
result.ratio_vaccinated_full = result.num_vaccinated_full / population
|
result.ratio_vaccinated_full = result.num_vaccinated_full / population * 100
|
||||||
result.ratio_vaccinated_once = result.num_vaccinated_once / population
|
result.ratio_vaccinated_once = result.num_vaccinated_once / population * 100
|
||||||
|
result.ratio_vaccinated_total = (
|
||||||
|
result.ratio_vaccinated_once + result.ratio_vaccinated_full
|
||||||
|
)
|
||||||
_log.debug(f"Result data: {result}")
|
_log.debug(f"Result data: {result}")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"domain": "covid19_augsburg",
|
"domain": "covid19_augsburg",
|
||||||
"name": "COVID-19 Augsburg",
|
"name": "COVID-19 Augsburg",
|
||||||
"version": "0.1.0",
|
"version": "1.1.3",
|
||||||
"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",
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "git add re"
|
name = "home_assistant_covid19_augsburg"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Adrian Rumpold <a.rumpold@gmail.com>"]
|
authors = ["Adrian Rumpold <a.rumpold@gmail.com>"]
|
||||||
|
|||||||
Reference in New Issue
Block a user