之前搭建了個 HomeKit 伺服器,還沒有接入米家的插線板,現在試試能不能讓米家設備接入蘋果的 HomeKit,用手機的 Home 軟體就能控制米家插線板。
安裝homebridge-mi-outlet
插件#
sudo npm -g install homebridge-mi-outlet
安裝miio
插件#
sudo npm -g install miio
用miio
插件發現小米智能插線板#
miio discover
可以看到Model info:zhimi.powerstrip.v2
就是米家智能插線板,將下放的 Address 和 Token 記下來:
Address:192.168.xxx.xxx
Token:21a98556732d471e2764cxxxxxxb1ee1
修改 HomeBridge 的config.json
檔案#
在bridge
節點後面添加所需的platforms
:
{
"platforms": [{
"platform": "MiOutletPlatform",
"deviceCfgs": [{
"type": "MiPlugBase",
"ip": "xxx.xxx.xxx.xxx",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"outletName": "米家智能插座基礎版",
"outletDisable": false,
"temperatureName": "米家智能插座基礎版溫度",
"temperatureDisable": false,
"switchLEDName": "米家智能插座基礎版指示燈開關",
"switchLEDDisable": false
}, {
"type": "MiPlugBaseWithUSB",
"ip": "xxx.xxx.xxx.xxx",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"outletName": "米家智能插座USB版",
"outletDisable": false,
"temperatureName": "米家智能插座USB版溫度",
"temperatureDisable": false,
"switchUSBName": "米家智能插座USB版指示燈開關",
"switchUSBDisable": false
}, {
"type": "MiIntelligencePinboard",
"ip": "xxx.xxx.xxx.xxx",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"outletName": "米家智能插線板",
"outletDisable": false,
"temperatureName": "米家智能插線板溫度",
"temperatureDisable": false,
"switchLEDName": "米家智能插線板指示燈開關",
"switchLEDDisable": false
}, {
"type": "MiQingPinboard",
"ip": "xxx.xxx.xxx.xxx",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"outletName": "青米智能插線板五孔位版",
"outletDisable": false,
"temperatureName": "青米智能插線板五孔位版溫度",
"temperatureDisable": false
}, {
"type": "MiQingPinboardWithUSB",
"ip": "xxx.xxx.xxx.xxx",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"outletName": "青米智能插線板USB版",
"outletDisable": false,
"temperatureName": "青米智能插線板USB版溫度",
"temperatureDisable": false
}]
}]
}
其中type
代表的硬體:
- 米家智能插座基礎版:
MiPlugBase
- 米家智能插座 USB 版:
MiPlugBaseWithUSB
- 米家智能插線板:
MiIntelligencePinboard
- 青米智能插線板五孔位版:
MiQingPinboard
- 青米智能插線板 USB 版:
MiQingPinboardWithUSB