diff --git a/custom_components/ha_strava/camera.py b/custom_components/ha_strava/camera.py index dd0b0b2..13cd661 100644 --- a/custom_components/ha_strava/camera.py +++ b/custom_components/ha_strava/camera.py @@ -135,7 +135,7 @@ def rotate_img(self): # pylint: disable=missing-function-docstring if len(self._urls) == 0: return self._url_index = (self._url_index + 1) % len(self._urls) - self.async_write_ha_state() + self.schedule_update_ha_state() def img_update_handler(self, event): """handle new urls of Strava images""" @@ -189,13 +189,13 @@ async def _load_pickle_urls(self): try: async with aiofiles.open(self._url_dump_filepath, "rb") as file: content = await file.read() - self._urls = pickle.load(content) + self._urls = pickle.loads(content) except FileNotFoundError: _LOGGER.error("File not found") except pickle.UnpicklingError as pe: - _LOGGER.error(f"Invalid data in file: {pe}") + _LOGGER.error(f"Invalid data in file: {pe}", exc_info=pe) except Exception as e: # pylint: disable=broad-exception-caught - _LOGGER.error(f"Error reading from file: {e}") + _LOGGER.error(f"Error reading from file: {e}", exc_info=e) async def _store_pickle_urls(self): """store image urls persistently on hard drive""" @@ -205,9 +205,9 @@ async def _store_pickle_urls(self): except FileNotFoundError: _LOGGER.error("File not found") except pickle.PickleError as pe: - _LOGGER.error(f"Invalid data in file: {pe}") + _LOGGER.error(f"Invalid data in file: {pe}", exc_info=pe) except Exception as e: # pylint: disable=broad-exception-caught - _LOGGER.error(f"Error storing images to file: {e}") + _LOGGER.error(f"Error storing images to file: {e}", exc_info=e) def _return_default_img(self): img_response = requests.get( # pylint: disable=unused-argument @@ -293,7 +293,7 @@ def entity_registry_enabled_default(self) -> bool: return self._default_enabled async def async_added_to_hass(self): - self.hass.bus.async_listen(CONF_IMG_UPDATE_EVENT, await self.img_update_handler) + self.hass.bus.async_listen(CONF_IMG_UPDATE_EVENT, self.img_update_handler) async def async_will_remove_from_hass(self): await super().async_will_remove_from_hass() diff --git a/custom_components/ha_strava/manifest.json b/custom_components/ha_strava/manifest.json index c810804..2e137b8 100644 --- a/custom_components/ha_strava/manifest.json +++ b/custom_components/ha_strava/manifest.json @@ -8,5 +8,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/craibo/ha_strava/issues", "requirements": ["aiofiles>=23.2.1", "aiohttp>=3.9.5", "voluptuous>=0.11.7"], - "version": "3.2.38" + "version": "3.2.39" }