diff --git a/custom_components/aguaiot/__init__.py b/custom_components/aguaiot/__init__.py index af961e9..dbb15b5 100644 --- a/custom_components/aguaiot/__init__.py +++ b/custom_components/aguaiot/__init__.py @@ -91,7 +91,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_update_data(): """Get the latest data.""" try: - await agua.fetch_device_information() + await agua.update() except UnauthorizedError as e: _LOGGER.error("Agua IOT Unauthorized: %s", e) return False diff --git a/custom_components/aguaiot/aguaiot.py b/custom_components/aguaiot/aguaiot.py index a36aafd..5d3ef15 100644 --- a/custom_components/aguaiot/aguaiot.py +++ b/custom_components/aguaiot/aguaiot.py @@ -160,6 +160,11 @@ async def register_app_id(self): raise ConnectionError(str.format("Connection to {0} not possible", url)) if response.status_code != 201: + _LOGGER.error( + "Failed to register app id. Code: %s, Response: %s", + response.status_code, + response.text, + ) raise UnauthorizedError("Failed to register app id") return True @@ -198,6 +203,11 @@ async def login(self): raise ConnectionError(str.format("Connection to {0} not possible", url)) if response.status_code != 200: + _LOGGER.error( + "Failed to login. Code: %s, Response: %s", + response.status_code, + response.text, + ) raise UnauthorizedError("Failed to login, please check credentials") res = response.json() @@ -283,6 +293,11 @@ async def fetch_devices(self): async def fetch_device_information(self): """Fetch device information of heating devices""" + for dev in self.devices: + await dev.update_mapping() + await dev.update() + + async def update(self): for dev in self.devices: await dev.update() @@ -321,6 +336,11 @@ async def handle_webcall(self, method, url, payload): await self.do_refresh_token() return await self.handle_webcall(method, url, payload) elif response.status_code != 200: + _LOGGER.error( + "Webcall failed. Code: %s, Response: %s", + response.status_code, + response.text, + ) return False return response.json() @@ -353,8 +373,10 @@ def __init__( self.__register_map_dict = dict() self.__information_dict = dict() - async def update(self): + async def update_mapping(self): await self.__update_device_registers_mapping() + + async def update(self): await self.__update_device_information() async def __update_device_registers_mapping(self):