Homebridge plugin

Hi guys,

I recently write a Yeelight plugin for homebridge, so iOS users can use Home App or Siri to control Yeelight WiFi devices directly, you can try it and provide any feedback or bug report here.

BTW, I’m new to Javascript and NodeJS, so some code may look clumsy, but it works :slight_smile: You are very welcome to polish it or re-write it once you got the idea how it works.


  1. Follow instruction here to install HomeBridge: https://github.com/nfarina/homebridge
  2. Turn on developer mode of your device.
  3. Download Yeelight plugin https://github.com/vvpossible/homebridge_plugin. “config.json” is to tell HomeBridge how to present your devices to iOS while the folder “yeelight” contains all the code.
  4. The quickest way is to put them under $HOME/.homebridge (only tested on my Linux machine, windows or mac use has to study it yourself :grinning:). You may also found other methods to deploy it or you can even publish the plugin to NPM.
  5. Start Homebridge by command “homebridge -P ~/.homebridge/yeelight/”.
  6. Open the Home App and enjoy.

yeelight/index.js --> main plugin file for HomeBridge, implement required plugin interface and interact with Yeelight device adapter
yeelight/node_modules/yee.js --> Yeelight device adapter, handle device discover, device management, socket connection and command sending/receiving.
yeelight/node_modules/test.js --> some test script for yee.js

Deploy it on your openwrt router or on a long-run machine in your home, then you can enjoy it anytime.


Made some update of this plugin. Already published to NPM and user now can just type:

npm install -g homebrige-yeelight

to run.

I got loading error when kick off the plugin.
Line 179 of yee.js


SyntaxError: missing ) after argument list

Any suggestion? or code update?

Following home bridge installation I can set home bridge as daemon in raspi3
Do I have launch yeelight plugin every time manuali ?

I already publish the latest plugin to NPM, could you try to use “npm install -g homebridge-yeelight” and see if you still got the error? I tested locally and didn’t see any issue …

Already published the plugin to NPM, you can install the plugin and then it should be automatically activated when your homebridge started. If not, you may want to configure ~/.homebridge/config.json and add Yeelight platform there to explicitly ask homebridge to load Yeelight plugin.

You can find yee.js and replace all the “() =>” with “function()”. And then it should be good. I think this new syntax is not supported by your js interpreter yet.

First, i can use home.app or siri to control yeelight bulb. Thanks.
But here’s the bug i found.
e.g. when i turn on the bulb in mijia.app or yeelight.app, then go back to Home.app, the icon of yeelight bulb in home.app is still turned off.(In fact, the yeelight bulb is turned on.)
So the icon of yeelight bulb in home.app can not show me the correct state。

Thanks for your feedback! Regarding the state sync, the 3rd party API of Yeelight do keep that in mind during design, however, I quickly studied hombridge and didn’t find any API that can be used to report the state change to Home App. I believe homekit protocol must have included that, so will do a deeper investigation later.

Thanks for your reply. I’m looking forward to your update for the state sync.
There’s another plugin named homebridge-aqara which is also Cooperating with Xiaomi, and it works good with the state sync.

I wish it can help you with the state sync.

Thanks for your information!
I have fixed the issue, please try it by updating your plugin. “npm install -g homebridge-yeelight”.

Well done.
Thanks very much!

find this code:

this.sock.on(“data”, (data) => {
var msg = data.toString();
var that = this;

and delete " var that = this;"

it’s worked for me.(ps: I replaced " (data)=>" by “function(data)”)

我想问一下,HomeBridge 可以安装在 OpenWrt 的路由器上吗?

Openwrt 路由器应该是可以的,但是可能需要手动编译一些东西。可以先google一下,试着安装nodejs和npm,如果能安装上,那应该就可以跑起来。

Tks. Weiwei.
I manage to modify few lines of the code to make it works. weird.




I have modified the plugin and removed all arrow functions which seems to have some compatibility issue among different Node environment.

1 Like