Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
为hass添加小米的智能插座基础版
@willwhui

This comment has been minimized.

Copy link
Owner Author

@willwhui willwhui commented Oct 29, 2017

小米智能插座基础版

小米设备的接入有这篇文章可以看,是@cxlwill 写的
https://sspai.com/post/40113

目前有一个简单粗暴的标准,即如果一个设备需要小米多功能网关才可以使用,一般来说它采用的是 Zigbee 协议,那么只要网关接入了 HA 就可以完美适配。而如果一个设备是独立接入网络的,比如米家 Wi-Fi 插座、扫地机器人、Yeelight 灯具等,我们则需要单独在 HASS 里接入它们。

参见文中的

WiFi 插座及智能插线板

另外,我也想知道官方文档,找了一下发现从hass前端界面的 Available Components 链接的界面中搜索 "mi":
https://home-assistant.io/components/#search/mi

但是注意,其中写着“Xiaomi Switch”的下面这个链接,是小米zigbee开关,不是wifi插座
https://home-assistant.io/components/switch.xiaomi_aqara/

点击“Xiaomi Smart WiFi Socket and Smart Power Strip
就是小米wifi插座了

switch:
  - platform: xiaomi_miio
    name: “Xiaomi Mi Smart WiFi Socket”
    host: 192.168.130.59 <------- 填写插座的ip
    token: YOUR_TOKEN <------- 填写token

获取插座token比较麻烦

参见https://gist.github.com/willwhui/7829f4a76d8bf8a3410fe50a9000352c

@willwhui

This comment has been minimized.

Copy link
Owner Author

@willwhui willwhui commented Nov 1, 2017

没有python-mirobo,开关加载不成功

配置好yaml之后,启动hass,结果前台显示:

Invalid Config
...

后台日志搜索关键字,找到错误:

Not initializing switch.xiaomi_miio because could not install dependency python-mirobo==0.2.0

原来必须得安装python-mirobo==0.2.0,这是对小米智能插座等设备作支持的模块。
记得在虚拟环境下安装:

$ sudo su homeassistant
$ source /srv/homeassistant/bin/activate
$ pip3 install python-mirobo

因为网络环境的问题出现几次远程连接中断,重复上面的pip3安装命令就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.