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.

Installation:

  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.

7 个赞

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

npm install -g homebrige-yeelight
hombrige

to run.

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

}.bind(this));
^

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”.

Great!!!
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.

提个小小的建议:


上图是我重新配置时的截屏,其中最后一排设备是yeelight,上面的都是aqara的设备,就是之前我跟你提过的那个绿米。一个问题就是你的各个灯泡在home里面都是以yeelight名字显示,所以我必须一个个点击然后观察哪个灯泡亮才能重新做标识,而aqara每个设备标识都不同,我可以记录对应名称以后,下次配置不需要再一个个比对。
不知道weiwei,这个区分设备标识的功能能否实现,谢谢。

已经支持了,添加时会显示6位的灯的设备ID。请更新homebridge-yeelight插件。

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

1 个赞