Compare commits
14 Commits
6-integer-
...
v1.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e1ede071e | ||
|
|
8fb322283c | ||
|
|
35ed25cf3f | ||
|
|
d20b48e6b1 | ||
|
|
d1438f9a0b | ||
|
|
c1b7b16251 | ||
|
|
e6c2644ea5 | ||
|
|
fc5f6e7c93 | ||
|
|
fa052cdfc9 | ||
|
|
f6f799e85f | ||
|
|
a44308a4e1 | ||
|
|
dd5bb2916b | ||
|
|
67bb1e49ef | ||
|
|
aaea39657e |
@@ -16,7 +16,7 @@ from .crawler import CovidCrawler
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
__version__ = "0.1.0"
|
||||
__version__ = "1.3.1"
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
|
||||
@@ -59,10 +59,12 @@ class VaccinationData:
|
||||
total_vaccinations: int = 0
|
||||
num_vaccinated_once: int = 0
|
||||
num_vaccinated_full: int = 0
|
||||
num_vaccinated_booster: int = 0
|
||||
|
||||
ratio_vaccinated_once: float = 0.0
|
||||
ratio_vaccinated_full: float = 0.0
|
||||
ratio_vaccinated_total: float = 0.0
|
||||
ratio_vaccinated_booster: float = 0.0
|
||||
|
||||
|
||||
class CovidCrawlerBase(ABC):
|
||||
@@ -107,7 +109,7 @@ class CovidCrawler(CovidCrawlerBase):
|
||||
)
|
||||
soup = await self._fetch(url)
|
||||
|
||||
match = soup.find(id="c1067628")
|
||||
match = soup.find(id="c1075340")
|
||||
text = match.text.strip()
|
||||
_log.debug(f"Infection data text: {text}")
|
||||
|
||||
@@ -165,9 +167,9 @@ class CovidCrawler(CovidCrawlerBase):
|
||||
result = soup.find(id=container_id)
|
||||
text = re.sub(r"\s+", " ", result.text)
|
||||
regexes = [
|
||||
r"(?P<total_vaccinations>\d+[.]\d+) Impfdosen",
|
||||
r"Weitere (?P<num_vaccinated_once>\d+[.]\d+) Personen haben die Erstimpfung erhalten",
|
||||
r"(?P<num_vaccinated_full>\d+[.]\d+) Personen sind bereits vollständig geimpft",
|
||||
r"(?P<total_vaccinations>\d+([.]\d+)?) Personen in Augsburg",
|
||||
r"(?P<num_vaccinated_full>\d+([.]\d+)?) Personen in Augsburg",
|
||||
r"(?P<num_vaccinated_booster>\d+([.]\d+)?) Personen, also",
|
||||
]
|
||||
values = {}
|
||||
for r in regexes:
|
||||
@@ -185,18 +187,24 @@ class CovidCrawler(CovidCrawlerBase):
|
||||
if not matches:
|
||||
raise ValueError(f"Could not extract date from scraped web page, {text=}")
|
||||
|
||||
values["num_vaccinated_once"] = (
|
||||
values["total_vaccinations"] - values["num_vaccinated_full"]
|
||||
)
|
||||
|
||||
values["date"] = parse_date(**matches.groupdict()).strftime("%Y-%m-%d")
|
||||
result = VaccinationData(**values)
|
||||
|
||||
# Total population in Augsburg as of 2020
|
||||
# https://www.augsburg.de/fileadmin/user_upload/buergerservice_rathaus/rathaus/statisiken_und_geodaten/statistiken/Monitoring/Demografiemonitoring_der_Stadt_Augsburg_2021.pdf
|
||||
population = 299021
|
||||
# Total population in Augsburg as listed on the crawled page
|
||||
population = 298014
|
||||
|
||||
result.ratio_vaccinated_full = result.num_vaccinated_full / population * 100
|
||||
result.ratio_vaccinated_once = result.num_vaccinated_once / population * 100
|
||||
result.ratio_vaccinated_total = (
|
||||
result.ratio_vaccinated_once + result.ratio_vaccinated_full
|
||||
)
|
||||
result.ratio_vaccinated_booster = (
|
||||
result.num_vaccinated_booster / population * 100
|
||||
)
|
||||
_log.debug(f"Result data: {result}")
|
||||
|
||||
return result
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
{
|
||||
"domain": "covid19_augsburg",
|
||||
"name": "COVID-19 Augsburg",
|
||||
"version": "1.1.3",
|
||||
"version": "1.3.1",
|
||||
"config_flow": true,
|
||||
"documentation": "https://github.com/AdrianoKF/home-assistant-covid19-augsburg",
|
||||
"issue_tracker": "https://github.com/AdrianoKF/home-assistant-covid19-augsburg/issues",
|
||||
"requirements": ["beautifulsoup4==4.8.2"],
|
||||
"requirements": [
|
||||
"beautifulsoup4==4.8.2"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@AdrianoKF"]
|
||||
}
|
||||
"codeowners": [
|
||||
"@AdrianoKF"
|
||||
]
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class CoronaAugsburgSensor(Entity):
|
||||
return self.coordinator.data["incidence"].incidence
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
def extra_state_attributes(self):
|
||||
data = self.coordinator.data["incidence"]
|
||||
return asdict(data)
|
||||
|
||||
@@ -98,7 +98,7 @@ class CoronaAugsburgVaccinationSensor(Entity):
|
||||
return self.coordinator.data["vaccination"].total_vaccinations
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
def extra_state_attributes(self):
|
||||
data = self.coordinator.data["vaccination"]
|
||||
return asdict(data)
|
||||
|
||||
|
||||
1021
poetry.lock
generated
1021
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "home_assistant_covid19_augsburg"
|
||||
version = "0.1.0"
|
||||
version = "1.3.1"
|
||||
description = ""
|
||||
authors = ["Adrian Rumpold <a.rumpold@gmail.com>"]
|
||||
packages = [
|
||||
|
||||
Reference in New Issue
Block a user