Problems with Xiaomi Mi IO binding

Tags: #<Tag:0x00007fc20aeaf988> #<Tag:0x00007fc20aeaf898> #<Tag:0x00007fc20aeaf758>

Hi There!

I’m advancing very fast getting all my Xiaomi toys to work with Openhab 2. I’m currently working on the Xiaomi Yeelight integrations but I get some problems controlling the lights.

openhab> bart@openhab:~$ openhab-cli info

Version: 2.4.0 (Build)

I have the following lamps:

yeelink.light.color1
yeelink.light.mono1

The Color bulb get’s recognised instantly upon connecting it to the MI Home app, the mono1 unfortunately isn’t… it is only when I add it manually but I don’t have any control over it. I checked the token and that should be correct, is there anything else I can test to check what is going wrong?

.things

Thing miio:basic:rgblight "RGB Light" [ host="192.168.0.26", token="9921e8188ab1a77e90c6cbc78931bc79", deviceId="035a1ca3" ]

Thing miio:basic:whitelight “White Light” [ host=“192.168.0.10”, token=“17fb8a60481da874b39ab030d52b1168”, deviceId=“361d45d” ]

.items

//StudioLight
Switch RGB_power “Power” {channel=“miio:basic:rgblight:power”}
Number RGB_brightness “Brightness” {channel=“miio:basic:rgblight:brightness”}
String RGB_delayoff “Shutdowm Timer” {channel=“miio:basic:rgblight:delayoff”}
Number RGB_colorTemperature “Color Temperature” {channel=“miio:basic:rgblight:colorTemperature”}
String RGB_colorMode “Color Mode” {channel=“miio:basic:rgblight:colorMode”}
Switch RGB_toggle “toggle” {channel=“miio:basic:rgblight:toggle”}
Color RGB_rgbColor “RGB Color” {channel=“miio:basic:rgblight:rgbColor”}
String RGB_name “Name” {channel=“miio:basic:rgblight:name”}

//Ball Of Glass
Switch BOG_power “Power” {channel=“miio:basic:whitelight:power”}
Number BOG_brightness “Brightness” {channel=“miio:basic:whitelight:brightness”}
Number BOG_delayoff “Shutdowm Timer” {channel=“miio:basic:whitelight:delayoff”}
Number BOG_colorTemperature “Color Temperature” {channel=“miio:basic:whitelight:colorTemperature”}
Number BOG_colorMode “Color Mode” {channel=“miio:basic:whitelight:colorMode”}
String BOG_name “Name” {channel=“miio:basic:whitelight:name”}

Log

18:43:59.344 [INFO ] [est.core.internal.thing.ThingResource] - Received HTTP PUT request for update configuration at ‘things/miio:basic:whitelight/config’ for an unmanaged thing ‘miio:basic:whitelight’.
18:44:50.702 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘BOG_power’ received command ON
18:44:50.704 [INFO ] [arthome.event.ItemStatePredictedEvent] - BOG_power predicted to become NULL
18:44:51.990 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘BOG_power’ received command ON
18:44:51.993 [INFO ] [arthome.event.ItemStatePredictedEvent] - BOG_power predicted to become NULL
18:44:53.254 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘BOG_power’ received command ON
18:44:53.256 [INFO ] [arthome.event.ItemStatePredictedEvent] - BOG_power predicted to become NULL

Thanks!

Have you tried a restart of OH?

Hi H102

Yes, several times already… I also tried to reset the bulbs (I have several mono1 and ct2), capturing their new tokens and work from there without any result. The only one that is alwyas showing up in the Paper UI is the color1.

Here is the log for the ct2 after a reset of the bulb + adding it to OH after a complete reboot of the system. I also restarted the service after adding it manually to OH. Still no success in controlling the light.

08:23:38.711 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'XiaomiMiBasicDevice_Power' received command ON 08:23:38.716 [INFO ] [arthome.event.ItemStatePredictedEvent] - XiaomiMiBasicDevice_Power predicted to become ON 08:23:38.720 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiBasicDevice_Power changed from NULL to ON 08:23:39.423 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'XiaomiMiBasicDevice_Power' received command OFF 08:23:39.428 [INFO ] [arthome.event.ItemStatePredictedEvent] - XiaomiMiBasicDevice_Power predicted to become OFF 08:23:39.429 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiBasicDevice_Power changed from ON to OFF 08:23:41.859 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'XiaomiMiBasicDevice_Power' received command ON 08:23:41.862 [INFO ] [arthome.event.ItemStatePredictedEvent] - XiaomiMiBasicDevice_Power predicted to become ON 08:23:41.864 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiBasicDevice_Power changed from OFF to ON 08:23:42.413 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'XiaomiMiBasicDevice_Power' received command OFF 08:23:42.417 [INFO ] [arthome.event.ItemStatePredictedEvent] - XiaomiMiBasicDevice_Power predicted to become OFF 08:23:42.420 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiBasicDevice_Power changed from ON to OFF 08:23:45.481 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'XiaomiMiBasicDevice_Power' received command ON 08:23:45.485 [INFO ] [arthome.event.ItemStatePredictedEvent] - XiaomiMiBasicDevice_Power predicted to become ON 08:23:45.487 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiBasicDevice_Power changed from OFF to ON 08:23:46.062 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'XiaomiMiBasicDevice_Power' received command OFF 08:23:46.065 [INFO ] [arthome.event.ItemStatePredictedEvent] - XiaomiMiBasicDevice_Power predicted to become OFF 08:23:46.066 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiBasicDevice_Power changed from ON to OFF

I found the solution! When using Miio discover installed on my Linux machine while resetting the bulbs it gave a token but that changed again when connecting to the wifi network.
Solution:

Non-Rooted Android Phones

Extract token from log file

This method will only work when you install the Mi Home app version v5.4.54. You can find it here. It looks like Xiaomi made a mistake in this app version where the log file written to internal memory exposes the device tokens of your Xiaomi miio devices.

  • Setup your Android device with the Mi Home app version 5.4.54
  • Log in with you Xiaomi account
  • Use a file explorer to navigate to /sdcard/SmartHome/logs/Plug_Devicemanager/
  • Look for a log file named yyyy-mm-dd.txt and open it with a file editor
  • Search for a string similar to this with you device name and token
{"did":"117383849","token":"90557f1373xxxxxxx8314a74d547b5","longitude":"x","latitude":"y","name":"Mi Robot Vacuum","pid":"0","localip":"192.168.88.68","mac":"40:31:3C:AA:BB:CC","ssid":"Your AP Name","bssid":"E4:8D:8C:EE:FF:GG","parent_id":"","parent_model":"","show_mode":1,"model":"rockrobo.vacuum.v1","adminFlag":1,"shareFlag":0,"permitLevel":16,"isOnline":true,"desc":"Zoned cleanup","extra":{"isSetPincode":0,"fw_version":"3.3.9_003460","needVerifyCode":0,"isPasswordEncrypt":0},"event":{"event.back_to_dock":"{\"timestamp\":1548817566,\"value\":[0]}
  • Copy the token from this string and you are done.

hi…
there is a new xiaomi yeelight ceiling light:
yilai.light.ceiling1
https://www.gearbest.com/smart-ceiling-lights/pp_009313773573.html

its (still) not working with the mi io binding.
maybe you can help.
thank you