From c0a3c7a4b74bdf64bd242e1344594989bbf0d43a Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Mon, 11 Oct 2021 04:37:44 +0200 Subject: [PATCH] Update pyfronius to 0.7.0 (#57279) * update to pyfronius 0.7.0 * exception handling * exception handling --- homeassistant/components/fronius/manifest.json | 2 +- homeassistant/components/fronius/sensor.py | 12 +++--------- requirements_all.txt | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/fronius/manifest.json b/homeassistant/components/fronius/manifest.json index 4c21e83e191..e40b5303eca 100644 --- a/homeassistant/components/fronius/manifest.json +++ b/homeassistant/components/fronius/manifest.json @@ -2,7 +2,7 @@ "domain": "fronius", "name": "Fronius", "documentation": "https://www.home-assistant.io/integrations/fronius", - "requirements": ["pyfronius==0.6.0"], + "requirements": ["pyfronius==0.7.0"], "codeowners": ["@nielstron"], "iot_class": "local_polling" } diff --git a/homeassistant/components/fronius/sensor.py b/homeassistant/components/fronius/sensor.py index 076eee9acc8..0ad172c2ab0 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -6,7 +6,7 @@ from datetime import timedelta import logging from typing import Any -from pyfronius import Fronius +from pyfronius import Fronius, FroniusError import voluptuous as vol from homeassistant.components.sensor import ( @@ -205,19 +205,13 @@ class FroniusAdapter: """Retrieve and update latest state.""" try: values = await self._update() - except ConnectionError: + except FroniusError as err: # fronius devices are often powered by self-produced solar energy # and henced turned off at night. # Therefore we will not print multiple errors when connection fails if self._available: self._available = False - _LOGGER.error("Failed to update: connection error") - return - except ValueError: - _LOGGER.error( - "Failed to update: invalid response returned." - "Maybe the configured device is not supported" - ) + _LOGGER.error("Failed to update: %s", err) return self._available = True # reset connection failure diff --git a/requirements_all.txt b/requirements_all.txt index ec5374661c6..744403d7968 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1495,7 +1495,7 @@ pyfreedompro==1.1.0 pyfritzhome==0.6.2 # homeassistant.components.fronius -pyfronius==0.6.0 +pyfronius==0.7.0 # homeassistant.components.ifttt pyfttt==0.3