SmartThings Community

Mi Connector (Xiaomi and Yeelight)

smartapp_misc
dth_sensors
requires_server
smartapp_appliances
(Wilk2312pl) #412

Hi can you help me? model: Xiaomi Air Purifier 2S

2019-03-05	19:00:01	info	Device Info >> zhimi.airpurifier.mc1 [{"life":1853,"cfg_time":0,"token":"mytoken","mac":"mymac","fw_ver":"1.4.3_21105","hw_ver":"MW300","uid":6158226008,"model":"zhimi.airpurifier.mc1","wifi_fw_ver":"SD878x-14.76.36.p84-702.1.0-WM","ap":{"rssi":-39,"ssid":"UPC97B2672","bssid":"DC:53:7C:9A:30:0D"},"netif":{"localIp":"192.168.0.171","mask":"255.255.255.0","gw":"192.168.0.1","gw_mac":"DC:

Regards,
Maciej.

(Jarno Marinelli) #413

Hey @fison67 i currently have a problem adding my Xiaomi Philips Bedside Lamp (philips.light.moonlight). I tried to make a fork from your github and adding it as a Xiaomi Light, but the problem (for what I can tell) is in the mi connector, which doesn’t recognize the device. I am currently running a docker container with the latest test.

Any ideas or cann you add support for it ? Thanks for the great work.
Will donate for sure if you are able to add support for this device

(Chals) #414

What’s your docker image version?
Install a ‘test2’ version.

(Chals) #415

Need some time to add it.
And I don’t have a moonlight.
I need your test after working.

What is type of docker image? mi-connector or mi-connector-arm?

(Jarno Marinelli) #416

Yeah of corse. I was hoping that it would be as simple as letting it show up a different device (color changing bulb).

I am running the latest mi-connector-test (not the arm version)

If you need anything or I can help you in any way (without needing you to buy it): remote session, advanced debug log from the connector,… let me know. I would be glad to help you out.

(Chals) #417

Update a docker image version[test3] & DTH & Smartapp.

Function: Turn on/off, color. brigtness.

(Jarno Marinelli) #418

Hi and thanks for your super fast reply.
Unfortunatly now no device gets registered (not even my air purifier that worked before).
I did the DB config, reinstalled everything, but every time from the mi connector I try to trigger the registration (I am in manuel mode), i see in the docker procol following error:

Log from moonlight
2019-03-06 08:40:02 [info]: Register Device to ST >> id(87084244) type(philips.light.moonlight) stdout
20:40:02 2019-03-06 08:40:02 [error]: (node:18) UnhandledPromiseRejectionWarning: ReferenceError: err is not defined stdout
20:40:02 at /usr/src/app/routes/registerST.js:52:97 stdout
20:40:02 at deviceMap.(anonymous function).target.state.then.state (/usr/src/app/miio/miio.js:1441:9) stdout
20:40:02 at <anonymous> stdout
20:40:02 at process._tickCallback (internal/process/next_tick.js:182:7)
Log from Air Purifier 2s
2019-03-06 08:44:41 [info]: Register Device to ST >> id(78920401) type(zhimi.airpurifier.ma2) stdout
20:44:41 2019-03-06 08:44:41 [error]: (node:18) UnhandledPromiseRejectionWarning: ReferenceError: err is not defined stdout
20:44:41 at /usr/src/app/routes/registerST.js:52:97 stdout
20:44:41 at deviceMap.(anonymous function).target.state.then.state (/usr/src/app/miio/miio.js:1441:9) stdout
20:44:41 at <anonymous> stdout
20:44:41 at process._tickCallback (internal/process/next_tick.js:182:7) stdout
20:44:41 2019-03-06 08:44:41 [error]: (node:18) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)

Let me know when there is a new version of what component to fix the issue.

(Chals) #419

Did you try to add a device to ST on web yourself?
There are some bug in log. But it’s occurred when it’s not able to register a device to ST.
This will be fixed later.

Let’s do this again.

  1. Install a test3 docker image.
  2. Update a Smartapp & DTH on ST IDE.
  3. Restart a docker container.
  4. Go to the dashboard on web.
    After 1min from reboot check there is a moonlight in Xiaomi Devices tab.
    If it is, it’s registered to mi connector.
  5. You don’t need to add a device to ST yourself.
  6. Let me know your log again.
(Jarno Marinelli) #420

So I redid everything as you documented in your installation guide (before I missed to create the config path for the docker container).
As you can see from the picture below, after adding the token they show up in the dashboard, but nothing happens on the site of SmartThings (no device, nothing)

Here the entire connector.log
2019-03-07 07:59:57 [Mi-Connector] info: WebSocket init
2019-03-07 07:59:59 [Mi-Connector] info: Initiallize Ping Processor
2019-03-07 07:59:59 [Mi-Connector] info: Mi Connector Version >> 0.0.4.5
2019-03-07 07:59:59 [Mi-Connector] info: {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:},“db”:{“host”:“localhost”,“port”:3306,“password”:“password”}}
2019-03-07 07:59:59 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:},“db”:{“host”:“localhost”,“port”:3306,“password”:“password”},“graph”:{“height”:40},“log”:{“enable”:true},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:"",“enable”:false}}
2019-03-07 07:59:59 [Mi-Connector] info: DB Config >> {“host”:“localhost”,“port”:3306,“user”:“root”,“password”:“password”,“database”:“mi_connector”}
2019-03-07 07:59:59 [Mi-Connector] info: ----------------------------------
2019-03-07 07:59:59 [Mi-Connector] info: Initialize >> Auto Detect Device!
2019-03-07 07:59:59 [Mi-Connector] info: ----------------------------------
2019-03-07 07:59:59 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:},“db”:{“host”:“localhost”,“port”:3306,“password”:“password”},“graph”:{“height”:40},“log”:{“enable”:true},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 07:59:59 [Mi-Connector] error: DB is disconnected >> Error: connect ECONNREFUSED 127.0.0.1:3306
2019-03-07 07:59:59 [Mi-Connector] warn: Finded >> But Mi-Connector can’t get token from this device!!! id(78920401)
2019-03-07 07:59:59 [Mi-Connector] warn: Finded >> But Mi-Connector can’t get token from this device!!! id(87093336)
2019-03-07 07:59:59 [Mi-Connector] warn: Finded >> But Mi-Connector can’t get token from this device!!! id(87084244)
2019-03-07 08:00:52 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:},“db”:{“host”:“192.168.1.30”,“port”:“3306”,“password”:“password1234”},“graph”:{“height”:40},“log”:{“enable”:true},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 08:00:52 [Mi-Connector] info: DB Config >> {“host”:“192.168.1.30”,“port”:“3306”,“user”:“root”,“password”:“password1234”,“database”:“mi_connector”}
2019-03-07 08:00:52 [Mi-Connector] error: DB is disconnected
2019-03-07 08:01:01 [Mi-Connector] info: Sensor Live Logging >> Disabled
2019-03-07 08:01:01 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:},“db”:{“host”:“192.168.1.30”,“port”:“3306”,“password”:“password1234”},“graph”:{“height”:40},“log”:{“enable”:false},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 08:01:50 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:},“db”:{“host”:“192.168.1.30”,“port”:“33006”,“password”:“password1234”},“graph”:{“height”:40},“log”:{“enable”:false},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 08:01:50 [Mi-Connector] info: DB Config >> {“host”:“192.168.1.30”,“port”:“33006”,“user”:“root”,“password”:“password1234”,“database”:“mi_connector”}
2019-03-07 08:01:51 [Mi-Connector] info: Try to connect DB…
2019-03-07 08:01:51 [Mi-Connector] info: DB is connected
2019-03-07 08:01:51 [Mi-Connector] info: DB is connected
2019-03-07 08:06:23 [Mi-Connector] warn: Find Device Manually but nothing token!!! >> 78920401
2019-03-07 08:06:23 [Mi-Connector] warn: Find Device Manually but nothing token!!! >> 87093336
2019-03-07 08:06:23 [Mi-Connector] warn: Find Device Manually but nothing token!!! >> 87084244
2019-03-07 08:07:40 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:[{“ip”:“192.168.1.56”,“token”:“de90dd41097447a4d3eaa2b7ff198211”}]},“db”:{“host”:“192.168.1.30”,“port”:“33006”,“password”:“password1234”},“graph”:{“height”:40},“log”:{“enable”:false},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 08:07:40 [Mi-Connector] info: Initialize Wi-Fi Device >> Ip(192.168.1.56), Token(de90dd41097447a4d3eaa2b7ff198211), Type(unknown)
2019-03-07 08:07:40 [Mi-Connector] info: Initialize Wi-Fi Device >> Ip(192.168.1.56), Token(de90dd41097447a4d3eaa2b7ff198211), Type(zhimi.airpurifier.ma2)
2019-03-07 08:07:50 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:[{“ip”:“192.168.1.56”,“token”:“de90dd41097447a4d3eaa2b7ff198211”},{“ip”:“192.168.1.124”,“token”:“6aa1917e369ce3f35e5a8c56e9ee9237”}]},“db”:{“host”:“192.168.1.30”,“port”:“33006”,“password”:“password1234”},“graph”:{“height”:40},“log”:{“enable”:false},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 08:07:50 [Mi-Connector] info: Initialize Wi-Fi Device >> Ip(192.168.1.124), Token(6aa1917e369ce3f35e5a8c56e9ee9237), Type(unknown)
2019-03-07 08:07:50 [Mi-Connector] info: Initialize Wi-Fi Device >> Ip(192.168.1.124), Token(6aa1917e369ce3f35e5a8c56e9ee9237), Type(philips.light.moonlight)
2019-03-07 08:07:59 [Mi-Connector] info: Save Config >> {“st”:{“app_url”:"",“app_id”:"",“access_token”:""},“connector”:{“port”:30000,“websocketPort”:30001,“address”:""},“xiaomi”:{“find_limit_time”:“30000”,“motion_reset_time”:“4900”,“find_mode”:“auto”},“devices”:{“list”:[{“ip”:“192.168.1.56”,“token”:“de90dd41097447a4d3eaa2b7ff198211”},{“ip”:“192.168.1.124”,“token”:“6aa1917e369ce3f35e5a8c56e9ee9237”},{“ip”:“192.168.1.134”,“token”:“f9a112b5681d5eb8be48987f982bbe09”}]},“db”:{“host”:“192.168.1.30”,“port”:“33006”,“password”:“password1234”},“graph”:{“height”:40},“log”:{“enable”:false},“ble”:{“enable”:false,“flora”:{“pollingTime”:60},“temperature”:{“pollingTime”:60}},“ir”:{},“ping”:{“list”:},“user”:{“name”:“admin”,“password”:“12345”},“token”:{“value”:“41c213232288ef514352ba4783b12ac3afede016b72e824608a5b857fabfd94a56fd961f1222008a096e626c1d46cf6b”,“enable”:false}}
2019-03-07 08:07:59 [Mi-Connector] info: Initialize Wi-Fi Device >> Ip(192.168.1.134), Token(f9a112b5681d5eb8be48987f982bbe09), Type(unknown)
2019-03-07 08:07:59 [Mi-Connector] info: Initialize Wi-Fi Device >> Ip(192.168.1.134), Token(f9a112b5681d5eb8be48987f982bbe09), Type(philips.light.moonlight)
2019-03-07 08:09:57 [Mi-Connector] info: Register Device to ST >> id(78920401) type(zhimi.airpurifier.ma2)
2019-03-07 08:09:57 [Mi-Connector] error: (node:20) UnhandledPromiseRejectionWarning: ReferenceError: err is not defined
at /usr/src/app/routes/registerST.js:52:97
at deviceMap.(anonymous function).target.state.then.state (/usr/src/app/miio/miio.js:1441:9)
at
at process._tickCallback (internal/process/next_tick.js:182:7)
2019-03-07 08:09:57 [Mi-Connector] error: (node:20) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2019-03-07 08:09:57 [Mi-Connector] error: (node:20) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here at the end you can see the error. Even going into http://mi-connector:30000/registerDevices it stays spinning and nothing happens.

(Chals) #421

You didn’t set a st url, app id, token on setting page.

({“st”:{“app_url”:"",“app_id”:"",“access_token”:""}…)

Open smartapp Mi connector.
Type a address and press save button.
ex) 192.168.0.11:30000

Then it will be written by automatically.

As your log monnlight is init on mi connector.
It’s just not registered to st.

(Matt B) #422

@fison67 would you be able to provide some pointers? I’m trying to get a Flora talking to the docker on my Synology NAS. I see earlier that you’re running a similar setup. I’ve got the USB device passed through to the docker, but not sure precisely where to go from here.

I scan with hcitool -i hci0 scan and hcitool -i hci0 lescan but the Flora doesn’t show up. It does find the Nest Protect in the same room as the server, the Flora is even closer, probably no more than 60cm from the Bluetooth adapter.

Also, when it comes to token time, I’m wondering how to obtain this. The instructions I followed for the vacuum worked, but that’s from the Mi Home App, which doesn’t appear to have any support for the Flora, I had to install an app called “Flower Care” to get it paired with my phone.

(Chals) #423

You don’t have to do something.

It’s just connected automatically with docker container restart.

Or remount USB & docker container restart.

Version of your Bluetooth dongle is higher than 4.0?

(Matt B) #424

I had to do a little more than that to get it passed through but it is passed through now. The dongle is BT 4.0 exactly according to the product description.

(luke) #425

Fison67 ,

I went and gave this another go yesterday .

Im using 64bit Centos , and your test3 image . Docker version is from the YUM repository. I have also disabled the SELINUX security.

I changed the command a little bit when installing Mysql

docker run -d --restart=always --name mariadb -e MYSQL_ROOT_PASSWORD=password1234 -e TZ=Asia/Seoul -p 33006:3306 -d jsurf/rpi-mariadb

Seems to have fixed the issue when after a reboot sql would no longer be running , but stating “exiting” . Either the command above did or the version got updated on docker :wink:

Test3 image seems fine, now when i reboot the server it picks the lights up fine again.

So seems great :wink: many thanks for your past help and well done on a great piece of software !

Im using it currently with a Yeelight bulb and Philiips/Xiaomi downlight . I will be installing another 8 downlights soon and wanted Smartthings to turn them on when my philiips hue lights turn on ! so this should do the trick :wink:

(Jarno Marinelli) #426

Hi and thanks for the info.

At the end i insert manually all data that was shown to me inside the config of the smartapp on my device to the mi connector before adding devices and then it worked no problem.

I also wanted to tell you, that someone found an easier way to get device tokens:

This is a modified to work in spanish, that at the same time in the device network settings shows you the token. I needed this, because my vacuum 2 is an eu one, and the other method used the mi home app 5.0.0 beta that doesn’t support EU server.

Newbie question regarding ST and Xiaomi
(Alcopop2006) #427

I’ve had this up and running for a good while and it works great… however just recently my Yeelight bulb went offline. Instead of waiting to see if it just sorted itself out, I reset it and it now isn’t working with the Mi Connector :frowning: The Mi Connector was initially finding and displaying the bulb in red (as it didn’t have an assigned token). I really struggled in obtaining the token for it this time but managed to find a method that worked. Through messing around and my stupidity I’ve assigned a duplicate wrong token to the yeelight and now the Mi Connector won’t let me add the correct IP address with accompanying token. When I search for devices the light isn’t showing to register anymore but it has been displayed at the bottom of the dashboard within the not initialized devices with an ID.

#428

Hello fison67(CHALS) i have an issue, got DB loaded on R Pi 3+, all looks good. Hubitat has device drivers loaded, but mi-connector only finds hub token, no other devices has token and nothing show in hubitat interface at all. Thank You for your work on this !

(Chals) #429

Zigbee devices has no token. It’s normal.

X means that each device is not registered to Smartthings or Hubitat.
Go to the setup page & check st app url, token, id.

If it’s empty, open mi connector smartapp, just press the save button.
It’s filled out it automatically.

#430

Thank You for the reply.
Info is filled correctly, I checked app, has correct URL, token & ID.
This is the 3rd time I try to setup, I used version “…mi-connector.test3”
I notice in raspberry pi, says “docker:0-link is down”, maybe that is issue, but then smartapp should show errors, i think ?

(Chals) #431

Let me know logs of SmartApp after restart a docker container.