Skip to content

Commit

Permalink
only warn about failed polling when retries are exhausted
Browse files Browse the repository at this point in the history
  • Loading branch information
siku2 committed Jul 8, 2022
1 parent 6653bcb commit c7bb6e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.3] - 2022-07-08

### Changed

- Adjusted log levels to reduce clutter when polling fails ([#19])

### Fixed

- Problems with broadcast reception ([#23])
Expand Down Expand Up @@ -148,7 +154,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.2.2] - 2021-05-11

[Unreleased]: https://github.com/siku2/hass-weatherlink/compare/v0.5.2...HEAD
[Unreleased]: https://github.com/siku2/hass-weatherlink/compare/v0.5.3...HEAD
[0.5.3]: https://github.com/siku2/hass-weatherlink/compare/v0.5.2...v0.5.3
[0.5.2]: https://github.com/siku2/hass-weatherlink/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/siku2/hass-weatherlink/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/siku2/hass-weatherlink/compare/v0.4.1...v0.5.0
Expand All @@ -163,6 +170,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.2.2]: https://github.com/siku2/hass-weatherlink/releases/tag/v0.2.2

[#23]: https://github.com/siku2/hass-weatherlink/issues/23
[#19]: https://github.com/siku2/hass-weatherlink/issues/19
[#17]: https://github.com/siku2/hass-weatherlink/issues/17
[#8]: https://github.com/siku2/hass-weatherlink/issues/8
[#7]: https://github.com/siku2/hass-weatherlink/issues/7
Expand Down
15 changes: 7 additions & 8 deletions custom_components/weatherlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,20 @@ async def __initalize(self, session: WeatherLinkRest, entry: ConfigEntry) -> Non
await self.__update_config(self.hass, entry)

async def __fetch_data(self) -> CurrentConditions:
for i in range(MAX_FAIL_COUNTER):
exc_info = None
for _ in range(MAX_FAIL_COUNTER):
try:
conditions = await self.session.current_conditions()
except Exception as exc:
log_fun = logger.warning if i > 0 else logger.debug
log_fun(
"failed to get current conditions, error %s / %s",
i + 1,
MAX_FAIL_COUNTER,
exc_info=exc,
)
exc_info = exc
await asyncio.sleep(FAIL_TIMEOUT)
else:
break
else:
logger.warning(
f"failed to get current conditions in {MAX_FAIL_COUNTER} attempt(s)",
exc_info=exc_info,
)
conditions = self.data

return conditions
Expand Down
2 changes: 1 addition & 1 deletion custom_components/weatherlink/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "weatherlink",
"name": "WeatherLink",
"version": "0.5.2",
"version": "0.5.3",
"documentation": "https://github.com/siku2/hass-weatherlink/wiki",
"issue_tracker": "https://github.com/siku2/hass-weatherlink/issues",
"codeowners": [
Expand Down

0 comments on commit c7bb6e1

Please sign in to comment.