From c7bb6e164fcf8a09563273997712a68e4eccf077 Mon Sep 17 00:00:00 2001 From: Simon Berger Date: Fri, 8 Jul 2022 23:20:44 +0200 Subject: [PATCH] only warn about failed polling when retries are exhausted --- CHANGELOG.md | 10 +++++++++- custom_components/weatherlink/__init__.py | 15 +++++++-------- custom_components/weatherlink/manifest.json | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ed1326..79d397e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]) @@ -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 @@ -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 diff --git a/custom_components/weatherlink/__init__.py b/custom_components/weatherlink/__init__.py index 6fc236f..7b0004d 100644 --- a/custom_components/weatherlink/__init__.py +++ b/custom_components/weatherlink/__init__.py @@ -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 diff --git a/custom_components/weatherlink/manifest.json b/custom_components/weatherlink/manifest.json index 0139171..8489ca6 100644 --- a/custom_components/weatherlink/manifest.json +++ b/custom_components/weatherlink/manifest.json @@ -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": [