diff --git a/cookbook/connectors/homeassistant.py b/cookbook/connectors/homeassistant.py index e2bdcc22d..3268c4cb1 100644 --- a/cookbook/connectors/homeassistant.py +++ b/cookbook/connectors/homeassistant.py @@ -3,7 +3,7 @@ from logging import Logger from typing import Dict, Tuple from urllib.parse import urljoin -from aiohttp import ClientError, request +from aiohttp import request, ClientResponseError from cookbook.connectors.connector import Connector from cookbook.models import ShoppingListEntry, ConnectorConfig, Space @@ -48,8 +48,8 @@ class HomeAssistant(Connector): try: await self.homeassistant_api_call("POST", "services/todo/add_item", data) - except ClientError as err: - self._logger.warning(f"received an exception from the api: {err=}, {type(err)=}") + except ClientResponseError as err: + self._logger.warning(f"received an exception from the api: {err.request_info.url=}, {err.request_info.method=}, {err.status=}, {err.message=}, {type(err)=}") async def on_shopping_list_entry_updated(self, space: Space, shopping_list_entry: ShoppingListEntry) -> None: if not self._config.on_shopping_list_entry_updated_enabled: @@ -76,9 +76,9 @@ class HomeAssistant(Connector): try: await self.homeassistant_api_call("POST", "services/todo/remove_item", data) - except ClientError as err: + except ClientResponseError as err: # This error will always trigger if the item is not present/found - self._logger.debug(f"received an exception from the api: {err=}, {type(err)=}") + self._logger.debug(f"received an exception from the api: {err.request_info.url=}, {err.request_info.method=}, {err.status=}, {err.message=}, {type(err)=}") async def close(self) -> None: pass