merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
391 stars 61 forks source link

Question about timeouts, retries. #559

Closed CooperCGN closed 5 months ago

CooperCGN commented 9 months ago

Hello, so every night at the exact same time I get these two errors thrown from my two Roborocks.

[28/12/2023, 03:39:35] [homebridge-miot] [Roborock Oben] Poll failed 4 times in a row! Stopping polling and trying to reconnect! Reason: Error: Call to device timed out

and

[28/12/2023, 03:56:50] [homebridge-miot] [Roborock Unten] Poll failed 4 times in a row! Stopping polling and trying to reconnect! Reason: Error: Call to device timed out

Exactly one minute after that the plugin reconnects and works as expected. Doing some research I found out that the robots seem to do some internal stuff like checking for new firmware or so as others have experienced the same in other home automations.

My question now is: is there a way for me to manully alter the code to increase the retries or timeout thing. The problem is that the dock sensor is shortly going to "not docked" and I have some automations that get triggered by it.

merdok commented 9 months ago

Yeah that happens sometimes, the device might be busy and does not respond to requests. I honestly see two easy possibilities here. You could try to increase the pollingInterval, but please note that this will delay status updates or you could disable your automations during the night.

Other than that if you wish to modify code you can go ahead and in the MiotDevice.js there is a constant defined at the top of the file which you change from 4 to any other number. But maybe it would even make sense to expose that as a config property for exactly such use cases?

Anyway, you can try it out and let me know. If changing the value of retries manually will help, then I might expose it...

CooperCGN commented 9 months ago

I will try modifying the retry constant and see how this works out and will report back in a few days. How much time is in between retries?

merdok commented 9 months ago

The pollingInterval property value defines the time between retries. Per default it should be 15 seconds.

CooperCGN commented 9 months ago

Just wanted to report back, I changed the retries to 15 (may be lower, need to test that) and the errors are gone. Perfect!

Guten Rutsch!

merdok commented 9 months ago

That sounds good! thanks for letting me know! i might make it configurable then.