Update pyTibber to 0.27.0 (#86940)
* Update pyTibber to 0.27.0 * Handle new exceptionspull/89059/head
parent
243725efe3
commit
e2e8d74aa6
|
@ -53,17 +53,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
try:
|
||||
await tibber_connection.update_info()
|
||||
if not tibber_connection.name:
|
||||
raise ConfigEntryNotReady("Could not fetch Tibber data.")
|
||||
|
||||
except asyncio.TimeoutError as err:
|
||||
raise ConfigEntryNotReady from err
|
||||
except aiohttp.ClientError as err:
|
||||
_LOGGER.error("Error connecting to Tibber: %s ", err)
|
||||
return False
|
||||
except (
|
||||
asyncio.TimeoutError,
|
||||
aiohttp.ClientError,
|
||||
tibber.RetryableHttpException,
|
||||
) as err:
|
||||
raise ConfigEntryNotReady("Unable to connect") from err
|
||||
except tibber.InvalidLogin as exp:
|
||||
_LOGGER.error("Failed to login. %s", exp)
|
||||
return False
|
||||
except tibber.FatalHttpException:
|
||||
return False
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
|
|
|
@ -44,10 +44,14 @@ class TibberConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
await tibber_connection.update_info()
|
||||
except asyncio.TimeoutError:
|
||||
errors[CONF_ACCESS_TOKEN] = "timeout"
|
||||
except aiohttp.ClientError:
|
||||
errors[CONF_ACCESS_TOKEN] = "cannot_connect"
|
||||
except tibber.InvalidLogin:
|
||||
errors[CONF_ACCESS_TOKEN] = "invalid_access_token"
|
||||
except (
|
||||
aiohttp.ClientError,
|
||||
tibber.RetryableHttpException,
|
||||
tibber.FatalHttpException,
|
||||
):
|
||||
errors[CONF_ACCESS_TOKEN] = "cannot_connect"
|
||||
|
||||
if errors:
|
||||
return self.async_show_form(
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
"iot_class": "cloud_polling",
|
||||
"loggers": ["tibber"],
|
||||
"quality_scale": "silver",
|
||||
"requirements": ["pyTibber==0.26.13"]
|
||||
"requirements": ["pyTibber==0.27.0"]
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ from homeassistant.helpers.entity_registry import async_get as async_get_entity_
|
|||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
UpdateFailed,
|
||||
)
|
||||
from homeassistant.util import Throttle, dt as dt_util
|
||||
|
||||
|
@ -559,6 +560,8 @@ class TibberRtDataCoordinator(DataUpdateCoordinator):
|
|||
class TibberDataCoordinator(DataUpdateCoordinator[None]):
|
||||
"""Handle Tibber data and insert statistics."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(self, hass: HomeAssistant, tibber_connection: tibber.Tibber) -> None:
|
||||
"""Initialize the data handler."""
|
||||
super().__init__(
|
||||
|
@ -571,9 +574,17 @@ class TibberDataCoordinator(DataUpdateCoordinator[None]):
|
|||
|
||||
async def _async_update_data(self) -> None:
|
||||
"""Update data via API."""
|
||||
await self._tibber_connection.fetch_consumption_data_active_homes()
|
||||
await self._tibber_connection.fetch_production_data_active_homes()
|
||||
await self._insert_statistics()
|
||||
try:
|
||||
await self._tibber_connection.fetch_consumption_data_active_homes()
|
||||
await self._tibber_connection.fetch_production_data_active_homes()
|
||||
await self._insert_statistics()
|
||||
except tibber.RetryableHttpException as err:
|
||||
raise UpdateFailed(f"Error communicating with API ({err.status})") from err
|
||||
except tibber.FatalHttpException:
|
||||
# Fatal error. Reload config entry to show correct error.
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.async_reload(self.config_entry.entry_id)
|
||||
)
|
||||
|
||||
async def _insert_statistics(self) -> None:
|
||||
"""Insert Tibber statistics."""
|
||||
|
|
|
@ -1473,7 +1473,7 @@ pyRFXtrx==0.30.1
|
|||
pySwitchmate==0.5.1
|
||||
|
||||
# homeassistant.components.tibber
|
||||
pyTibber==0.26.13
|
||||
pyTibber==0.27.0
|
||||
|
||||
# homeassistant.components.dlink
|
||||
pyW215==0.7.0
|
||||
|
|
|
@ -1076,7 +1076,7 @@ pyMetno==0.9.0
|
|||
pyRFXtrx==0.30.1
|
||||
|
||||
# homeassistant.components.tibber
|
||||
pyTibber==0.26.13
|
||||
pyTibber==0.27.0
|
||||
|
||||
# homeassistant.components.dlink
|
||||
pyW215==0.7.0
|
||||
|
|
Loading…
Reference in New Issue