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

Commit

Permalink
Handle request read timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
oischinger committed Aug 22, 2023
1 parent 7ec655e commit 4bf63b4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/vicare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
raise ConfigEntryNotReady from err
except PyViCareInternalServerError as err:
raise ConfigEntryNotReady from err
except requests.exceptions.ConnectionError as err:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as err:
raise ConfigEntryNotReady from err

def vicare_login(hass, entry_data, scan_interval = DEFAULT_SCAN_INTERVAL):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vicare/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def update(self):
try:
with suppress(PyViCareNotSupportedFeatureError):
self._state = self.entity_description.value_getter(self._api)
except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vicare/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def press(self) -> None:
try:
with suppress(PyViCareNotSupportedFeatureError):
self.entity_description.value_setter(self._api)
except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
Expand Down
4 changes: 2 additions & 2 deletions custom_components/vicare/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def update(self) -> None:
self._current_action or compressor.getActive()
)

except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
Expand Down Expand Up @@ -480,7 +480,7 @@ def update(self) -> None:
self._attributes = {}
self._attributes["room_temperature"] = _room_temperature

except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vicare/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def async_step_user(
except PyViCareInternalServerError as err:
errors["base"] = "server_error"
description_placeholders = {"error": str(err)}
except requests.exceptions.ConnectionError as err:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as err:
errors["base"] = "cannot_connect"
description_placeholders = {"error": str(err)}
except PyViCareRateLimitError as err:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vicare/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def update(self):
self._attr_native_unit_of_measurement = (
VICARE_UNIT_TO_UNIT_OF_MEASUREMENT.get(vicare_unit)
)
except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
Expand Down
6 changes: 3 additions & 3 deletions custom_components/vicare/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def update(self):
with suppress(PyViCareNotSupportedFeatureError):
_LOGGER.debug("Fetching DHW One Time Charging Status")
self._state = self.entity_description.value_getter(self._api)
except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
Expand All @@ -161,7 +161,7 @@ async def async_turn_on(self, **kwargs: Any) -> None:
self._ignore_update_until = datetime.datetime.utcnow() + TIMEDELTA_UPDATE
self._state = True

except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
Expand All @@ -179,7 +179,7 @@ async def async_turn_off(self, **kwargs: Any) -> None:
self._ignore_update_until = datetime.datetime.utcnow() + TIMEDELTA_UPDATE
self._state = False

except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
_LOGGER.error("Unable to decode data from ViCare server")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vicare/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def update(self) -> None:
with suppress(PyViCareNotSupportedFeatureError):
self._current_mode = self._circuit.getActiveMode()

except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
_LOGGER.error("Unable to retrieve data from ViCare server")
except PyViCareRateLimitError as limit_exception:
_LOGGER.error("Vicare API rate limit exceeded: %s", limit_exception)
Expand Down

1 comment on commit 4bf63b4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.