Xiaomi Robot Vacuum Binding

@mhilbush that definitely needs to be look after.
I guess it has to do that the cleanup of the receiver thread is not working well, most likely when communication errors or processing errors occur.
I’m not very skilled in such debugging, so any more info you can find where it is waiting for / stuck would be very helpful

I took a quick look at the code last night, but I didn’t see anything obvious. I’ll look more closely this morning.

Last night I uninstalled and reinstalled the binding (by removing from addons, then putting back in addons), and the blocked threads all went away. This morning, it looks like there are 68 of them.

So, I just uninstalled again and the blocked threads went to 0.

I’ll let you know what I find out.

It would seem interrupting a UDP socket receive is problematic.



I’ve successfully used the timeout method before (using setSoTimeout). If it can work in your situation, I actually think closing the socket is more desirable, as the effect is more immediate.

Either way, using one of these approaches should fix the issue.

Edit: Also looks like setSoTimeout is used in a number of other bindings that are receiving on a datagram socket.

While I was looking at the code, I noticed this unnecessary line.

Hi,
I have tried to extract my Yeelight tokens from my android device.
However, the database contains all my devices, the token column is empty.
I have also tried using MiToolkit, and it has the same result. I have the list of my devices, IP, etc but no token :

lumi.gateway.v3 - Gateway - - 192.168.1.24
lumi.sensor_motion.v2 - Occupancy Sensor - -
lumi.sensor_switch.v2 - Light Switch - -
yeelink.light.color1 - Living room light - - 192.168.1.6
yeelink.light.color1 - Hallway light - - 192.168.1.48
yeelink.light.color1 - Main kitchen light - - 192.168.1.13

Did anyone have the same issue lately?

I had it working.
Apparently, the problem is with the last version of MiHome, which could be a problem in the future if they have decided not to store tokens in the database anymore.
I had to install MiHome 1.0.19 version from API Mirror to make it work.

If anyone knows how to retrieve the tokens with the last version of MiHome, I am still interesting as this solution is not very convenient.

@DaAndy. Your method of token retrieval finally worked for me. The latest mihome app does not allow for token retrieval and flole is not able to do mihome imports as before. After trying almost every option in the forum the only thing that worked was sideloading the old mihome app. Thanks again. I wish I had read your post earlier before trying all the other suggestions.
Ellis

recap:
In the end I had to side load an older version of the xiaomi home app:
(https://www.apkmirror.com/apk/xiaomi-inc/mihome/mihome-5-0-19-release/mihome-5-0-19-android-apk-download/
And then extract using the commands/instr below:

  1. hook up debugable phone and use: adb.exe backup n- -noapk com.xiaomi.smarthome -f backup.ab
  2. java -jar .\android-backup-tookit\android-backup-extractor\android-backup-extractor-20180203-bin\abe.jar unpack .\backup.ab backup.tar
  3. Use 7zip to extract tar
  4. Use sqllite browser to mine mio2.db file
  5. Use this sql cmd to retrieve token: select token from devicerecord

@marcel_verpaalen I’m using openhab 2.1.0 w/ a mi robot v1 Firmware version 3.3.9_003088 and miio binding 2.3.0.201802111049. I can get updates from the vacuum but I can’t send any commands. Log displayed below. The vacuum seems to be online per paperui interface. Any ideas on where I should troubleshoot next?

21:55:28.910 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for ‘miio:vacuum:04EB012C’. 9 elements in queue.
21:55:58.910 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for ‘miio:vacuum:04EB012C’. 9 elements in queue.
21:56:28.911 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for ‘miio:vacuum:04EB012C’. 9 elements in queue.
21:56:58.911 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for ‘miio:vacuum:04EB012C’. 9 elements in queue.
21:57:28.127 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘actionControl’ received command pause
21:57:28.130 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {“id”:23,“method”:“app_pause”,“params”:[]} -> 10.10.10.250 (Device: 04EB012C token: 5175xxxxxxxxxxB323361 Queue: 10)
21:57:28.130 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 04EB012C (10.10.10.250)
21:57:28.130 [INFO ] [marthome.event.ItemStateChangedEvent] - actionControl changed from dock to pause
21:57:28.133 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 04EB012C (10.10.10.250) success
21:57:28.135 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {“id”:24,“method”:“get_status”,“params”:[]} -> 10.10.10.250 (Device: 04EB012C token: 5175505xxxxxxxxxx3361 Queue: 11)
21:57:28.135 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 04EB012C (10.10.10.250)
21:57:28.138 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 04EB012C (10.10.10.250) success
21:57:28.911 [DEBUG] [nding.miio.handler.MiIoVacuumHandler] - Skipping periodic update for ‘miio:vacuum:04EB012C’. 11 elements in queue.

Thanks for any help you can give,
Ellis

Update: I had the correct token, but I was using the openhab 2.1 distro. After upgrading to openhab 2.2 things just worked. Not sure why but I hope this helps someone else.

@elias_gabrielsson this typically indicates a token issue.
Are you sure you are seeing true status updates and not some older status, skipping the periodic update means you are not getting anything.
There is not really any difference between sending a command vs getting an update from the device.
Your device appears online as ping is working (IP is defined well), I expect it shows configuration error in paperUI as well (due to the issue with token)

@ellisbjohns tagging right man for previous post. :slight_smile:

1 Like

@marcel_verpaalen I just installed your binding to control philips eyecare 2 and it works great, but I noticed that when I turn on or off the lamp manually switch state in the openhab is not updated. Is it possible to fix it somehow ?

P.S. Thank you for your wonderful work

Thanks allot for the binding!
I managed to turn my yeelight ceiling on & off, dimm it and control it with Alexa so far.
Unfortunately I am still a bloody beginner and am struggling with setting up everything else.
If someone could help me out with an example of his/her item and sitemap file I would be very thankful.
Thanks again :slight_smile:.

Hey @frest,

what kind of device are you having?

I see the same results obn yeelight color bulb…
Need bit of checking what is causing that behaviour

1 Like

3 Yeelight color bulb.

@marcel_verpaalen Is there anything else you need in addition to what I provided above to resolve the thread cleanup issue?

yes… spare time :slight_smile: I’ve not been able to spend much time on the
development last few weeks as I am busy with some other private projects

I totally get that. :slight_smile: Just wanted to make sure you had what you needed.

Hi Marcel,
Great work on the development of the binding, I might going to use it in the future. In my research for my potentionel new vacuum cleaner I came across https://github.com/dgiese/dustcloud and thought it might be interesting for you. It’s a method to root the Xiaomi. Cheers

2 Likes

Hello @marcel_verpaalen,

after an update the addon is uninstalled, because i’m using the addons.cfg.
Is there any chance that you put the binding in the openHAB2 Addons repository?

Regards Christian