Skip to content

Commit

Permalink
Merge pull request #175 from craibo/camera-issues-part2
Browse files Browse the repository at this point in the history
camera-issues-fix
  • Loading branch information
craibo authored Jul 22, 2024
2 parents f9ebab3 + c7ae5f0 commit a8b618c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions custom_components/ha_strava/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ha_strava/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit a8b618c

Please sign in to comment.