Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from zweckj/f/datacoordinator
Browse files Browse the repository at this point in the history
use sync endpoint most of the time
  • Loading branch information
zweckj authored Jul 10, 2023
2 parents 2b76ad4 + 9d37fbb commit b9fe3fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion custom_components/tedee/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import logging
from datetime import timedelta

Expand Down Expand Up @@ -26,11 +27,22 @@ def __init__(self, hass, tedee_client):
update_interval=SCAN_INTERVAL,
)
self._tedee_client = tedee_client
self._next_get_locks = time.time()


async def _async_update_data(self):
try:
_LOGGER.debug("Update coordinator: Getting locks from API")
await self._tedee_client.get_locks()

# once every hours get all lock details, otherwise use the sync endpoint
if self._next_get_locks - time.time() <= 0:
_LOGGER.debug("Updating through /my/lock endpoint...")
await self._tedee_client.get_locks()
self._next_get_locks = time.time() + 60*60
else:
_LOGGER.debug("Updating through /sync endpoint...")
await self._tedee_client.sync()

except TedeeAuthException as ex:
msg = "Authentication failed. \
Personal Key is either invalid, doesn't have the correct scopes \
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tedee/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": [],
"codeowners": ["@patrickhilker", "@joerg65", "@zweckj"],
"requirements": ["pytedee-async==0.1.4"],
"version": "2023.7.3",
"version": "2023.7.4",
"config_flow": true,
"iot_class": "cloud_polling"
}

0 comments on commit b9fe3fa

Please sign in to comment.