Skip to content

Commit

Permalink
fix: sync version sensor state after HA connection loss (#43)
Browse files Browse the repository at this point in the history
fix: add "sensor." prefix name to version sensor
chore: update mypy and pylint
  • Loading branch information
rmoesbergen authored Nov 17, 2023
1 parent 78af9b8 commit 8b222b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions presence-detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from typing import Any, List, Callable, Optional, Tuple
from urllib import request

VERSION = "2.1.0"
VERSION = "2.1.1"


class Logger:
Expand Down Expand Up @@ -215,7 +215,7 @@ def _update_version_entity(self):
if self._settings.ap_name
else "openwrt_router"
)
entity_id = f"{ap_name}.presence_detector_version"
entity_id = f"sensor.{ap_name}_presence_detector_version"

response, ok = self._post(
f"{self._settings.hass_url}/api/states/{entity_id}",
Expand Down Expand Up @@ -263,6 +263,8 @@ def run(self) -> None:
# We're back online -> process backlog
ha_is_offline = False
self._do_full_sync()
# Update the version entity in HA
self._update_version_entity()
else:
self._logger.log("Home Assistant seems to be offline, sleeping...")
# HA is offline -> Add the item back to the queue
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r requirements.txt
pylint==2.17.0
mypy==1.1.1
pylint==3.0.2
mypy==1.7.0

0 comments on commit 8b222b3

Please sign in to comment.