vincentwolsink / home_assistant_micronova_agua_iot

Home Assistant integration controlling heating devices connected via the Agua IOT platform of Micronova
Apache License 2.0
27 stars 15 forks source link

Failed config, reload needed #50

Closed silkyclouds closed 11 months ago

silkyclouds commented 1 year ago

Hi,

Me again ;)

image

This is happening quire a lot since whatever update.

As you might imagine, this is pretty problematic, as I'm using the schedule card to start the stove in the morning and reach XX celcius. So, if the stove is unavailable, no heating, and house is damn cold ;)

I have to reload the integration manually to get things to work properly again.

am I the only one ? Or is there a woarkaround existing ?

Thanks !

vincentwolsink commented 1 year ago

There should be an error in your logs. Please provide it here 🙂

marc-cizeron commented 12 months ago

Hi, I'having issue very similar with the beta 6. Here the log I get when I try to reload the integration :

Cette erreur provient d'une intégration personnalisée

Logger: custom_components.aguaiot
Source: helpers/update_coordinator.py:290
Integration: Micronova Agua IOT (documentation, issues)
First occurred: 09:48:27 (1 occurrences)
Last logged: 09:48:27

Unexpected error fetching aguaiot data: name 'self' is not defined
Traceback (most recent call last):
  File "/config/custom_components/aguaiot/__init__.py", line 94, in async_update_data
    await agua.fetch_device_information()
  File "/config/custom_components/aguaiot/aguaiot.py", line 287, in fetch_device_information
    await dev.update()
  File "/config/custom_components/aguaiot/aguaiot.py", line 358, in update
    await self.__update_device_information()
  File "/config/custom_components/aguaiot/aguaiot.py", line 413, in __update_device_information
    raise AguaIOTError("Error while fetching device information")
custom_components.aguaiot.aguaiot.AguaIOTError: Error while fetching device information

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/aguaiot/__init__.py", line 108, in async_update_data
    self._device.name,
    ^^^^
NameError: name 'self' is not defined

Hop, this helps !

Thanks

silkyclouds commented 12 months ago

Thanks for being faster than me at checking the logs Marc ! :)

FYI, this is what shows up in the logs I can see within HA :

This error originated from a custom integration.

Logger: custom_components.aguaiot Source: custom_components/aguaiot/init.py:85 Integration: Micronova Agua IOT (documentation, issues) First occurred: 9:28:14 AM (1 occurrences) Last logged: 9:28:14 AM

Connection to Agua IOT not possible

I would be fine to figure out a simple workaround, reloading my integration using a command line, running in a cron, whatever...

silkyclouds commented 12 months ago

I confirm I have the exact same issue, happens each time I restart home assistant (and every once and then) :

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/aguaiot/__init__.py", line 108, in async_update_data
    self._device.name,
    ^^^^
NameError: name 'self' is not defined
2023-10-08 09:53:16.813 ERROR (MainThread) [custom_components.aguaiot] Unexpected error fetching aguaiot data: name 'self' is not defined
Traceback (most recent call last):
  File "/config/custom_components/aguaiot/__init__.py", line 94, in async_update_data
    await agua.fetch_device_information()
  File "/config/custom_components/aguaiot/aguaiot.py", line 287, in fetch_device_information
    await dev.update()
  File "/config/custom_components/aguaiot/aguaiot.py", line 358, in update
    await self.__update_device_information()
  File "/config/custom_components/aguaiot/aguaiot.py", line 413, in __update_device_information
    raise AguaIOTError("Error while fetching device information")
custom_components.aguaiot.aguaiot.AguaIOTError: Error while fetching device information

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/aguaiot/__init__.py", line 108, in async_update_data
    self._device.name,
    ^^^^
NameError: name 'self' is not defined
2023-10-08 09:54:31.491 ERROR (MainThread) [custom_components.aguaiot] Unexpected error fetching aguaiot data: name 'self' is not defined
Traceback (most recent call last):
  File "/config/custom_components/aguaiot/__init__.py", line 94, in async_update_data
    await agua.fetch_device_information()
  File "/config/custom_components/aguaiot/aguaiot.py", line 287, in fetch_device_information
    await dev.update()
  File "/config/custom_components/aguaiot/aguaiot.py", line 358, in update
    await self.__update_device_information()
  File "/config/custom_components/aguaiot/aguaiot.py", line 413, in __update_device_information
    raise AguaIOTError("Error while fetching device information")
custom_components.aguaiot.aguaiot.AguaIOTError: Error while fetching device information
vincentwolsink commented 12 months ago

I am just back from vacation. Will try to put some improvements in this week.

marc-cizeron commented 12 months ago

Thanks for being faster than me at checking the logs Marc ! :)

FYI, this is what shows up in the logs I can see within HA :

This error originated from a custom integration.

Logger: custom_components.aguaiot Source: custom_components/aguaiot/init.py:85 Integration: Micronova Agua IOT (documentation, issues) First occurred: 9:28:14 AM (1 occurrences) Last logged: 9:28:14 AM

Connection to Agua IOT not possible

I would be fine to figure out a simple workaround, reloading my integration using a command line, running in a cron, whatever...

I have time to time the same issue. I often have the Connection to Agua IOT not possible Did you connect the stove via a Freebox ?

silkyclouds commented 12 months ago

Thanks for being faster than me at checking the logs Marc ! :) FYI, this is what shows up in the logs I can see within HA : This error originated from a custom integration. Logger: custom_components.aguaiot Source: custom_components/aguaiot/init.py:85 Integration: Micronova Agua IOT (documentation, issues) First occurred: 9:28:14 AM (1 occurrences) Last logged: 9:28:14 AM Connection to Agua IOT not possible I would be fine to figure out a simple workaround, reloading my integration using a command line, running in a cron, whatever...

I have time to time the same issue. I often have the Connection to Agua IOT not possible Did you connect the stove via a Freebox ?

Nope, not at all. I'm in BEFR, using a cable provider. ;)

silkyclouds commented 12 months ago

I suspect the issue might originate from this section of the code. It might be worth examining the way self is defined and used here.

async def async_update_data(self):
    """Get the latest data."""
    try:
        await self._device.fetch_device_information()
    except UnauthorizedError:
        _LOGGER.error(
            "Wrong credentials for device %s (%s)",
            self._device.name,
            self._device.id_device,
        )
        return False
    except ConnectionError:
        _LOGGER.error("Connection to Agua IOT not possible")
        return False
    except AguaIOTError as err:
        _LOGGER.error(
            "Failed to update %s (%s), error: %s",
            self._device.name,
            self._device.id_device,
            err,
        )
        return False
vincentwolsink commented 12 months ago

This fixes the error during exception handling. But it does not fix the root cause yet. #51

vincentwolsink commented 12 months ago

The timeout to the AguaIOT api was on the low side. I increased it, let's see if that helps.

silkyclouds commented 12 months ago

might be, as this is happening right after a restart. as I told you, reloading the integration manually fixes the issue. I'll keep you posted. thanks ! :)

silkyclouds commented 11 months ago

unfortunately the timeout increase is not fixing it on my end :

image

this happens at each HA restart.

vincentwolsink commented 11 months ago

Can you please share the relevant entries in your error log?

silkyclouds commented 11 months ago

Can you please share the relevant entries in your error log?

Sure, can you eventuall let me know if I can see your integration's logs only somewhere ? I'm flooded in the general HA logs.

any clue what I am seeking for ?

FYI, this mornng, even reloading the integration doesn't bring the stove back :(

-> the crappy official app works, so it is really realted to the integration.

If it helps hre is how loggin is cofigured inside my yml file :


logger:
  default: error
  logs:
    custom_components.webrtc: error

but this only do report a one liner each time I reload the integration :

2023-10-16 10:34:28.568 ERROR (MainThread) [custom_components.aguaiot] Connection to Agua IOT not possible
2023-10-16 10:38:24.820 ERROR (MainThread) [custom_components.aguaiot] Connection to Agua IOT not possible
2023-10-16 10:38:41.696 ERROR (MainThread) [custom_components.aguaiot] Connection to Agua IOT not possible
2023-10-16 10:42:03.818 ERROR (MainThread) [custom_components.aguaiot] Connection to Agua IOT not possible

I even can see the queries going through adguaard, meaning the wifi module is connected and discusses with their servers :

image

silkyclouds commented 11 months ago

You can search for aguaiot in system logs.

{"entry_id":"e6e973fd0d3e882970e986748708841c","domain":"aguaiot","title":"aguaiot","source":"user","state":"setup_error","supports_options":false,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}},{"type":null,"entry":{"entry_id":"f26929347c4a422e5e97051fe582f875","domain":"openai_conversation","title":"OpenAI Conversation","source":"user","state":"loaded","supports_options":true,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}},{"type":null,"entry":{"entry_id":"aafa6e33ad9e20a71bad2be2184d6f18","domain":"androidtv_remote","title":"Shield pro salon","source":"zeroconf","state":"loaded","supports_options":true,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}},{"type":null,"entry":{"entry_id":"2b2d8e819722cd158bdc89c84ed6f82c","domain":"esphome","title":"niveau_mazout","source":"zeroconf","state":"loaded","supports_options":true,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}}]}]
2023-10-16 10:57:11.459 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Received {'type': 'frontend/get_translations', 'language': 'en', 'category': 'title', 'integration': ['aguaiot'], 'id': 93}
2023-10-16 10:57:11.459 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Received {'type': 'manifest/get', 'integration': 'aguaiot', 'id': 94}
2023-10-16 10:57:11.460 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Sending [{"id":93,"type":"result","success":true,"result":{"resources":{"component.aguaiot.title":"Micronova Agua IOT"}}},{"id":94,"type":"result","success":true,"result":{"domain":"aguaiot","name":"Micronova Agua IOT","codeowners":["@vincentwolsink"],"config_flow":true,"dependencies":[],"documentation":"https://github.com/vincentwolsink/home_assistant_micronova_agua_iot/","integration_type":"hub","iot_class":"cloud_polling","issue_tracker":"https://github.com/vincentwolsink/home_assistant_micronova_agua_iot/issues","requirements":["httpx"],"version":"0.2.0","is_built_in":false}}]
2023-10-16 10:57:11.465 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Received {'type': 'diagnostics/get', 'domain': 'aguaiot', 'id': 95}
2023-10-16 10:57:11.466 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Sending {"id":95,"type":"result","success":true,"result":{"domain":"aguaiot","handlers":{"config_entry":true,"device":false}}}
2023-10-16 10:57:14.502 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Sending [{"id":85,"type":"event","event":[{"type":"updated","entry":{"entry_id":"e6e973fd0d3e882970e986748708841c","domain":"aguaiot","title":"aguaiot","source":"user","state":"setup_in_progress","supports_options":false,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}}]},{"id":85,"type":"event","event":[{"type":"updated","entry":{"entry_id":"e6e973fd0d3e882970e986748708841c","domain":"aguaiot","title":"aguaiot","source":"user","state":"setup_in_progress","supports_options":false,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}}]}]
2023-10-16 10:57:19.563 ERROR (MainThread) [custom_components.aguaiot] Connection to Agua IOT not possible
2023-10-16 10:57:19.570 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547297925184] meaning from xxx.xxx.xxx.xxx (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36): Sending {"id":85,"type":"event","event":[{"type":"updated","entry":{"entry_id":"e6e973fd0d3e882970e986748708841c","domain":"aguaiot","title":"aguaiot","source":"user","state":"setup_error","supports_options":false,"supports_remove_device":false,"supports_unload":true,"pref_disable_new_entities":false,"pref_disable_polling":false,"disabled_by":null,"reason":null}}]
silkyclouds commented 11 months ago

it eventually connected back after 10 tries :

image

vincentwolsink commented 11 months ago

If you still have issues, please install v0.2.2 and check again the error logs. There should be more information available now.

silkyclouds commented 11 months ago

Thanks ! :)