albertogeniola / meross-homeassistant

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

Meross mss310 HA integration using Local Broker breaking repeatedly #441

Open sharkwsk opened 1 year ago

sharkwsk commented 1 year ago

Describe the bug I have 2 mss310 smart plugs integrated to HA using Meross Local Broker. I am able to pair the devices using custom pairer app. If I switch off the power and restart the plugs the integration becomes unstable and eventually becomes completely broken

IP addresses to the plugs are setup in the WiFi modem so they get assigned same IP all the time for specific MAC using MAC binding (its not static IP assignment)

Your environment Home Assistant 2023.4.4 Supervisor 2023.04.0 Frontend 20230411.1 - latest

Logs taken when the issue happened

I see following prints in my HA logs

2023-04-18 10:57:49.338 WARNING (MainThread) [meross_iot.model.http.device] Provided bind_time is not int neither datetime. It will be ignored.
2023-04-18 10:57:49.340 WARNING (MainThread) [meross_iot.model.http.device] Provided bind_time is not int neither datetime. It will be ignored.
2023-04-18 10:57:49.342 INFO (MainThread) [custom_components.meross_cloud] The HTTP API has found new devices that were unknown to us. Triggering discovery.
2023-04-18 10:57:49.343 INFO (MainThread) [meross_iot.manager] 

------- Triggering Manager Discovery (using cached http device list), filter_device: [None] -------
2023-04-18 10:57:49.343 INFO (MainThread) [meross_iot.manager] Fetch and update done
2023-04-18 10:57:49.344 INFO (MainThread) [meross_iot.manager] 
------- Manager Discovery ended -------

2023-04-18 10:57:49.344 INFO (MainThread) [custom_components.meross_cloud.sensor] Refreshing instant metrics for device MerosLight1 (mss310) power W - Main channel
2023-04-18 10:57:49.348 INFO (MainThread) [custom_components.meross_cloud.sensor] Refreshing instant metrics for device MerosLight1 (mss310) current A - Main channel
2023-04-18 10:57:49.352 ERROR (MainThread) [homeassistant.components.switch] Platform meross_cloud does not generate unique IDs. ID switch:#BASE:2202140564066190868448e1e9897314:0 already exists - ignoring switch.meroslight1_mss310_main_channel
2023-04-18 10:57:51.960 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.meroslight2_mss310_current_a_main_channel is taking over 10 seconds
2023-04-18 10:57:51.963 ERROR (MainThread) [meross_iot.manager] Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1-ef814d1d374be2b185c4bbf9ec698605/subscribe","messageId":"ef51b45c4b27d1346cdf8361826101ab","method":"GET","namespace":"Appliance.Control.Electricity","payloadVersion":1,"sign":"5c8bf980515f528e548051e72b6f9a8b","timestamp":1681779462,"triggerSrc":"Android","uuid":"2202144936124790868448e1e9897e23"},"payload":{"channel":0}}' sent to device uuid 2202144936124790868448e1e9897e23. Timeout was: 10.000000 seconds. Mqtt Host: 192.168.1.124:2001.
2023-04-18 10:57:51.967 ERROR (MainThread) [custom_components.meross_cloud.sensor] Error occurred.
-------------------------------------
Component version: 0.4.5.7
Device info: 
        Name: MerosLight2
        UUID: 2202144936124790868448e1e9897e23
        Type: mss310
        HW Version: 6.0.0
        FW Version: 6.3.21
Error Message: "An exception occurred"
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 903, in _async_send_and_wait_ack
    return await asyncio.wait_for(future, timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/sensor.py", line 186, in async_update
    await self._device.async_get_instant_metrics(channel=self._channel_id)
  File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/mixins/electricity.py", line 41, in async_get_instant_metrics
    result = await self._execute_command(method="GET",
  File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/device.py", line 302, in _execute_command
    return await self._manager.async_execute_cmd(destination_device_uuid=self.uuid,
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 847, in async_execute_cmd
    return await self.async_execute_cmd_client(client=client,
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 884, in async_execute_cmd_client
    response = await self._async_send_and_wait_ack(
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 910, in _async_send_and_wait_ack
    raise CommandTimeoutError(message=str(message), target_device_uuid=target_device_uuid, timeout=timeout)
meross_iot.model.exception.CommandTimeoutError
2023-04-18 10:57:59.349 ERROR (MainThread) [meross_iot.manager] Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1-ef814d1d374be2b185c4bbf9ec698605/subscribe","messageId":"090acc968e0e46f9402c2e071df27065","method":"GET","namespace":"Appliance.Control.Electricity","payloadVersion":1,"sign":"7ed8f343a20c3541c99a6c2b253e51c6","timestamp":1681779469,"triggerSrc":"Android","uuid":"2202140564066190868448e1e9897314"},"payload":{"channel":0}}' sent to device uuid 2202140564066190868448e1e9897314. Timeout was: 10.000000 seconds. Mqtt Host: 192.168.1.124:2001.
2023-04-18 10:57:59.351 ERROR (MainThread) [custom_components.meross_cloud.sensor] Error occurred.
-------------------------------------
Component version: 0.4.5.7
Device info: 
        Name: MerosLight1
        UUID: 2202140564066190868448e1e9897314
        Type: mss310
        HW Version: 6.0.0
        FW Version: 6.3.21
Error Message: "An exception occurred"
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 903, in _async_send_and_wait_ack
    return await asyncio.wait_for(future, timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/sensor.py", line 147, in async_update
    await self._device.async_get_instant_metrics(channel=self._channel_id)
  File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/mixins/electricity.py", line 41, in async_get_instant_metrics
    result = await self._execute_command(method="GET",
  File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/device.py", line 302, in _execute_command
    return await self._manager.async_execute_cmd(destination_device_uuid=self.uuid,
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 847, in async_execute_cmd
    return await self.async_execute_cmd_client(client=client,
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 884, in async_execute_cmd_client
    response = await self._async_send_and_wait_ack(
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 910, in _async_send_and_wait_ack
    raise CommandTimeoutError(message=str(message), target_device_uuid=target_device_uuid, timeout=timeout)
meross_iot.model.exception.CommandTimeoutError
2023-04-18 10:57:59.361 ERROR (MainThread) [homeassistant.components.sensor] Platform meross_cloud does not generate unique IDs. ID sensor:#BASE:2202140564066190868448e1e9897314:0:power:W already exists - ignoring sensor.meroslight1_mss310_power_w_main_channel
2023-04-18 10:57:59.364 INFO (MainThread) [custom_components.meross_cloud.sensor] Refreshing instant metrics for device MerosLight1 (mss310) voltage V - Main channel
2023-04-18 10:57:59.366 ERROR (MainThread) [meross_iot.manager] Timeout occurred while waiting a response for message b'{"header":{"from":"/app/1-ef814d1d374be2b185c4bbf9ec698605/subscribe","messageId":"9e012e9746af81012d3c187d0684c56b","method":"GET","namespace":"Appliance.Control.Electricity","payloadVersion":1,"sign":"03bbc6de3ac33e87d860ed758512043f","timestamp":1681779469,"triggerSrc":"Android","uuid":"2202140564066190868448e1e9897314"},"payload":{"channel":0}}' sent to device uuid 2202140564066190868448e1e9897314. Timeout was: 10.000000 seconds. Mqtt Host: 192.168.1.124:2001.
2023-04-18 10:57:59.368 ERROR (MainThread) [custom_components.meross_cloud.sensor] Error occurred.
-------------------------------------
Component version: 0.4.5.7
Device info: 
        Name: MerosLight1
        UUID: 2202140564066190868448e1e9897314
        Type: mss310
        HW Version: 6.0.0
        FW Version: 6.3.21
Error Message: "An exception occurred"
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 903, in _async_send_and_wait_ack
    return await asyncio.wait_for(future, timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/sensor.py", line 186, in async_update
    await self._device.async_get_instant_metrics(channel=self._channel_id)
  File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/mixins/electricity.py", line 41, in async_get_instant_metrics
    result = await self._execute_command(method="GET",
  File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/device.py", line 302, in _execute_command
    return await self._manager.async_execute_cmd(destination_device_uuid=self.uuid,
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 847, in async_execute_cmd
    return await self.async_execute_cmd_client(client=client,
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 884, in async_execute_cmd_client
    response = await self._async_send_and_wait_ack(
  File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 910, in _async_send_and_wait_ack
    raise CommandTimeoutError(message=str(message), target_device_uuid=target_device_uuid, timeout=timeout)
meross_iot.model.exception.CommandTimeoutError
2023-04-18 10:57:59.376 ERROR (MainThread) [homeassistant.components.sensor] Platform meross_cloud does not generate unique IDs. ID sensor:#BASE:2202140564066190868448e1e9897314:0:current:A already exists - ignoring sensor.meroslight1_mss310_current_a_main_channel
2023-04-18 10:58:01.945 INFO (MainThread) [custom_components.meross_cloud.sensor] Refreshing instant metrics for device MerosLight2 (mss310) power W - Main channel
2023-04-18 10:58:01.947 INFO (MainThread) [custom_components.meross_cloud.sensor] Refreshing instant metrics for device MerosLight2 (mss310) voltage V - Main channel
^C
bash-5.1# 
mathgim commented 9 months ago

It seems I might have the same issue :

Logger: meross_iot.manager
Source: runner.py:188
First occurred: 17:38:22 (4 occurrences)
Last logged: 17:38:32

Timeout occurred while waiting a response for message b'{"header":{"from":"/app/360752-88db5e5ddac05a948f2ce06efefbb934/subscribe","messageId":"705284be12bd75fcdfc3568bba222f3d","method":"GET","namespace":"Appliance.System.Ability","payloadVersion":1,"sign":"efceb97268dbb56b7e4204b13f920fc9","timestamp":1701362292,"triggerSrc":"Android","uuid":"1912273149180125188248e1e9154163"},"payload":{}}' sent to device uuid 1912273149180125188248e1e9154163. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-eu-2.meross.com:443.
Device Lampe (1912273149180125188248e1e9154163) is online, but timeout occurred when fetching its abilities.
Timeout occurred while waiting a response for message b'{"header":{"from":"/app/360752-88db5e5ddac05a948f2ce06efefbb934/subscribe","messageId":"a612484d5573963064749faffd12d63d","method":"GET","namespace":"Appliance.System.Ability","payloadVersion":1,"sign":"acd27c68a2d80cbb71d6ff9b0e5af03b","timestamp":1701362302,"triggerSrc":"Android","uuid":"1912274424746025188248e1e915357a"},"payload":{}}' sent to device uuid 1912274424746025188248e1e915357a. Timeout was: 10.000000 seconds. Mqtt Host: mqtt-eu-2.meross.com:443.
Device Prise arrosage (1912274424746025188248e1e915357a) is online, but timeout occurred when fetching its abilities.