Whytey / moebot-hass-integration

A HomeAssistant integration for MoeBot (and compatible) TUYA mowers.
8 stars 0 forks source link

Critical issue after 0.2.0: blocking call to sleep inside the event loop. #10

Closed clau-bucur closed 12 months ago

clau-bucur commented 1 year ago

I just updated to 0.2.0 and my HA won't start-up anymore. Looking at the log I see this:

2023-06-27 22:52:32.268 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for moebot doing blocking calls at custom_components/moebot/__init__.py, line 23: moebot.listen()
Whytey commented 1 year ago

Hi @clau-bucur ,

Yes sorry - all testing went well and then as I pushed it to a release and ran it on my machine I got the same thing. I tried to work it out but had to go to bed and now work.

For me I was able to force hass to load by doing the following:

  1. from the homeassistant directory, nano .storage/core.config_entries
  2. locate the moebot entry and update the following line: "source": "ignore",
  3. restart hass - but the moebot integration is disabled.

At least at that point you should be able to roll bacl the change. I plan to have this fixed tonight. :|

clau-bucur commented 1 year ago

Not a problem 😆 I was also able to revert to 0.1.1 and it's all good for now.

Whytey commented 12 months ago

@clau-bucur 0.2.1 seems to have introduced a different issue now. Another one that doesn't seem to show in my dev environment. You may see different results with your Tuya protocol version 3.4 machine.

clau-bucur commented 12 months ago

Testing now!

Whytey commented 12 months ago

OK, cool. I think my issue is that my home-assistant server doesn't pull down the latest version of the pymoebot library - I am stuck on version 0.0.1 :-1:

clau-bucur commented 12 months ago

Doesn't seem to update the mower state reliably. Out of 10 state changes the integration only correctly switched to 3 of them, but I can't seem to see a pattern. Let me know how can I test more.

Whytey commented 12 months ago

Thanks.

Maybe up the logger and see if that reveals anything weird:

logs:
  # Otherstuff
  custom_component.moebot: debug
  pymoebot: debug
clau-bucur commented 12 months ago

Ok, ran another test.

  1. Started mowing from the vacuum device
  2. Paused mowing from the vacuum device [it did not receive the pause state]
  3. Tried to stop but it failed because of bad state
  4. Stopped from the Tuya app
  5. Parked from Tuya app
  6. Stopped park from Tuya app
  7. Parked from vacuum device
  8. Stopped park [it did not receive the standby state] ....
2023-07-07 16:04:02.141 DEBUG (SyncWorker_3) [pymoebot] Attempting to start mowing: 'STANDBY'
2023-07-07 16:04:02.141 DEBUG (SyncWorker_3) [pymoebot] StartMowing
2023-07-07 16:04:02.271 DEBUG (SyncWorker_3) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735041, 'data': {'dps': {'101': 'MOWING'}}, 'dps': {'101': 'MOWING'}}
2023-07-07 16:04:25.247 DEBUG (SyncWorker_6) [pymoebot] Attempting to pause mowing: 'MOWING'
   <<< did not update state, localtuya integration updated state >>>

2023-07-07 16:04:33.976 DEBUG (SyncWorker_3) [pymoebot] Attempting to cancel mowing: 'MOWING'
2023-07-07 16:04:33.976 ERROR (SyncWorker_3) [pymoebot] Unable to cancel due to current state: 'MOWING'
2023-07-07 16:04:35.482 ERROR (SyncWorker_6) [pymoebot] Error from device: None
2023-07-07 16:05:02.381 DEBUG (SyncWorker_10) [pymoebot] Attempting to cancel mowing: 'MOWING'
2023-07-07 16:05:02.381 ERROR (SyncWorker_10) [pymoebot] Unable to cancel due to current state: 'MOWING'
2023-07-07 16:05:27.078 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735126, 'data': {'dps': {'101': 'STANDBY'}}, 'dps': {'101': 'STANDBY'}}
NoneType: None
2023-07-07 16:05:27.078 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735126, 'data': {'dps': {'101': 'STANDBY'}}, 'dps': {'101': 'STANDBY'}}
2023-07-07 16:05:27.352 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735127, 'data': {'dps': {'112': 'ZKg3cQAAAFUBZKgu9wAAAP4BZKgnggAAADwBZKgnXAAAADwBZKgabQAADOABZKbimQAALMIBZKVbPgAARlQBZKRT5QAARlEBZKK4PgAARlQBZKGJqgAARlAB'}}, 'dps': {'112': 'ZKg3cQAAAFUBZKgu9wAAAP4BZKgnggAAADwBZKgnXAAAADwBZKgabQAADOABZKbimQAALMIBZKVbPgAARlQBZKRT5QAARlEBZKK4PgAARlQBZKGJqgAARlAB'}}
NoneType: None
2023-07-07 16:05:27.352 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735127, 'data': {'dps': {'112': 'ZKg3cQAAAFUBZKgu9wAAAP4BZKgnggAAADwBZKgnXAAAADwBZKgabQAADOABZKbimQAALMIBZKVbPgAARlQBZKRT5QAARlEBZKK4PgAARlQBZKGJqgAARlAB'}}, 'dps': {'112': 'ZKg3cQAAAFUBZKgu9wAAAP4BZKgnggAAADwBZKgnXAAAADwBZKgabQAADOABZKbimQAALMIBZKVbPgAARlQBZKRT5QAARlEBZKK4PgAARlQBZKGJqgAARlAB'}}
2023-07-07 16:05:41.655 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735141, 'data': {'dps': {'101': 'PARK'}}, 'dps': {'101': 'PARK'}}
NoneType: None
2023-07-07 16:05:41.655 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735141, 'data': {'dps': {'101': 'PARK'}}, 'dps': {'101': 'PARK'}}
2023-07-07 16:06:17.774 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735177, 'data': {'dps': {'101': 'STANDBY'}}, 'dps': {'101': 'STANDBY'}}
NoneType: None
2023-07-07 16:06:17.774 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735177, 'data': {'dps': {'101': 'STANDBY'}}, 'dps': {'101': 'STANDBY'}}
2023-07-07 16:06:25.195 DEBUG (SyncWorker_0) [pymoebot] Attempting to dock mower: 'STANDBY'
2023-07-07 16:06:25.315 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735184, 'data': {'dps': {'101': 'PARK'}}, 'dps': {'101': 'PARK'}}
NoneType: None
2023-07-07 16:06:25.315 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735184, 'data': {'dps': {'101': 'PARK'}}, 'dps': {'101': 'PARK'}}
2023-07-07 16:06:30.334 ERROR (SyncWorker_0) [pymoebot] Error from device: None
2023-07-07 16:06:39.092 DEBUG (SyncWorker_11) [pymoebot] Attempting to cancel mowing: 'PARK'
   <<< did not update state, localtuya integration updated state >>>

2023-07-07 16:06:59.533 DEBUG (SyncWorker_6) [pymoebot] Attempting to dock mower: 'PARK'
2023-07-07 16:06:59.533 ERROR (SyncWorker_6) [pymoebot] Unable to dock due to current state: 'PARK'
2023-07-07 16:07:07.215 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735226, 'data': {'dps': {'101': 'PARK'}}, 'dps': {'101': 'PARK'}}
NoneType: None
2023-07-07 16:07:07.215 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735226, 'data': {'dps': {'101': 'PARK'}}, 'dps': {'101': 'PARK'}}
2023-07-07 16:07:30.366 ERROR (SyncWorker_11) [pymoebot] Error from device: {'Error': 'Network Error: Device Unreachable', 'Err': '905', 'Payload': None}
2023-07-07 16:08:22.867 DEBUG (Thread-5 (__loop)) [pymoebot] Received Payload: {'protocol': 4, 't': 1688735302, 'data': {'dps': {'101': 'CHARGING'}}, 'dps': {'101': 'CHARGING'}}
NoneType: None
2023-07-07 16:08:22.867 DEBUG (Thread-5 (__loop)) [pymoebot] Parsing data from device: {'protocol': 4, 't': 1688735302, 'data': {'dps': {'101': 'CHARGING'}}, 'dps': {'101': 'CHARGING'}}
Whytey commented 12 months ago

OK - I think the original issue here is actually fixed by 0.2.1. I agree there appears to be some instability in recording the results of issued commands but I will try and rectify that elsewhere. Closing.

Whytey commented 10 months ago

Hi @clau-bucur - the previous uncertainty around receiving responses from pymoebot has been mostly addressed for a couple of weeks now. I was just keen to hear if you had any feedback on reliability?

In my testing, it would appear I maybe miss responses for 1 or 2 in every 10 commands.

clau-bucur commented 10 months ago

Hey. It's pretty stable for me too. Been using it for the past weeks with no issue on the component side.

From time to time the robot loses sync with the app or the component (it appears online but it's actually offline or locked) but it shows the same in the Tuya app, tinytuya, or this component.

Very happy with this! Thank you.