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?
//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
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]}