albertogeniola / meross-homeassistant

Custom component that leverages the Meross IoT library to integrate with Homeassistant
MIT License
731 stars 83 forks source link

Repeat Error Causing HA Crashing #509

Open Coolmanchambers opened 3 months ago

Coolmanchambers commented 3 months ago

Describe the bug Issues with the integration, throwing an excessive amount of errors, eventually causing RAM usage to cap, and CPU usage to Spike.

First error was a async_forward_entry_setup (same one that was reported here earlier) for multiple meross devices. When i updated Device communication options from "Attempt local HTTP communication first and fall-back to MQTT broker" to "Attempt local HTTP communication first only for GET commands, fall-back to MQTT broker", the async error seems to reduce. Before this, this error was happening for multiple devices at a rate of 200+ per 30 mins.

The error "waiting a response for message" below is persisting at the rate of 70-90 times per 30 minutes.

This started shortly after the update to HA core that took place this week.

Your environment HomeAssistant version: Core 2024.8.1 Supervisor 2024.08.0 Operating System 12.4 Frontend 20240809.0 Hassio Version (if applicable): -- PLEASE SPECIFY -- Hardware environment: NUC 13th gen

Logs taken when the issue happened

Logger: meross_iot.manager
Source: runner.py:190
First occurred: 6:34:25 PM (54 occurrences)
Last logged: 6:47:09 PM

Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1561054-0ba86291c93897af2f684daf70f1c01c/subscribe","messageId":"33daeb05dc8d1305eda93e6ed931ae10","method":"GET","namespace":"Appliance.System.Ability","payloadVersion":1,"sign":"ab1f731d0ac4f43ea442a47eb84a49b2","timestamp":1723427089,"triggerSrc":"Android","uuid":"2109135775875751856848e1e976a56e"},"payload":{}}' sent to device uuid 2109135775875751856848e1e976a56e. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-us-4.meross.com:443.
Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1561054-0ba86291c93897af2f684daf70f1c01c/subscribe","messageId":"7591799608150651ac2d1eb688a4950f","method":"GET","namespace":"Appliance.System.Ability","payloadVersion":1,"sign":"4c4cafb9566a3ab526cdf01f15629b95","timestamp":1723427099,"triggerSrc":"Android","uuid":"2103171038975451855048e1e9637722"},"payload":{}}' sent to device uuid 2103171038975451855048e1e9637722. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-us-4.meross.com:443.
Device Decorations Plug 1 (2103171038975451855048e1e9637722) is online, but timeout occurred when fetching its abilities.
Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1561054-0ba86291c93897af2f684daf70f1c01c/subscribe","messageId":"f4b82f87d43567154bfd7a46495f675b","method":"GET","namespace":"Appliance.System.Ability","payloadVersion":1,"sign":"b59484c78e868bb24cd69294cb09c877","timestamp":1723427209,"triggerSrc":"Android","uuid":"2109135775875751856848e1e976a56e"},"payload":{}}' sent to device uuid 2109135775875751856848e1e976a56e. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-us-4.meross.com:443.
Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1561054-0ba86291c93897af2f684daf70f1c01c/subscribe","messageId":"3a8a299c9c4b5e844d6e9377708ef7f2","method":"GET","namespace":"Appliance.System.Ability","payloadVersion":1,"sign":"bae8c3c2bfaeccd8e8f3b4d0319c2b47","timestamp":1723427219,"triggerSrc":"Android","uuid":"2103171038975451855048e1e9637722"},"payload":{}}' sent to device uuid 2103171038975451855048e1e9637722. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-us-4.meross.com:443.
calexandre commented 1 month ago

I'm also seeing an identical error:

2024-10-06 22:41:40.547 ERROR (MainThread) [meross_iot.manager] Timeout occurred while waiting a response for message b'{"header":{"from":"/app/340967-60f30072b05f90e5c88bcff2ef6a7fa9/subscribe","messageId":"cb9635f3918fc76c6ba78fcf183a8aaf","method":"GET","namespace":"Appliance.System.Runtime","payloadVersion":1,"sign":"576da488286301bc6be314596f6d723f","timestamp":1728250891,"triggerSrc":"Android","uuid":"1811061516525925181734298f17a292"},"payload":{}}' sent to device uuid 1811061516525925181734298f17a292. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-eu-4.meross.com:443.
2024-10-06 22:41:40.547 ERROR (MainThread) [custom_components.meross_cloud] Error occurred.
-------------------------------------
Component version: 0.4.7.3
Device info:
        Name: Water Heater
        UUID: 1811061516525925181734298f17a292
        Type: mss310
        HW Version: 2.0.0
        FW Version: 2.1.11
Error Message: "An exception occurred"
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/meross_iot/manager.py", line 925, in _async_send_and_wait_ack
    return await asyncio.wait_for(future, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
    async with timeouts.timeout(timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/__init__.py", line 241, in async_update
    await self._device.async_update()
  File "/usr/local/lib/python3.12/site-packages/meross_iot/controller/mixins/system.py", line 20, in async_update
    await super().async_update(timeout=timeout, *args, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/meross_iot/controller/mixins/runtime.py", line 50, in async_update
    await self.async_update_runtime_info()
  File "/usr/local/lib/python3.12/site-packages/meross_iot/controller/mixins/runtime.py", line 29, in async_update_runtime_info
    result = await self._execute_command(method="GET",
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/controller/device.py", line 308, in _execute_command
    return await self._manager.async_execute_cmd(destination_device_uuid=self.uuid,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/manager.py", line 852, in async_execute_cmd
    return await self.async_execute_cmd_client(client=client,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/manager.py", line 906, in async_execute_cmd_client
    response = await self._async_send_and_wait_ack(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/manager.py", line 932, in _async_send_and_wait_ack
    raise CommandTimeoutError(message=str(message), target_device_uuid=target_device_uuid, timeout=timeout)
meross_iot.model.exception.CommandTimeoutError