|
本帖最后由 Lee 于 2017-9-6 23:22 编辑
此贴主要记录自己在入坑HA的一些心得,就当是作为一个填坑笔记吧!空闲的时候会慢慢更新我自己尝试且成功的教程,分享是一种美德!
小白篇:
HA安装:
目前我自己测试的安装方法有三种:
一,黑裙+Docker,群晖
适用对象:有不用的旧电脑,或者自己DIY的黑裙,或者想体验HA的随便一台电脑都可以。
详细教程请移步:https://bbs.hassbian.com/thread-849-1-1.html,之前写的详细教程,可以参考安装。
----------------------------------------------------------------------------------------分割线------------------------------------------------------------------------------------------
二,树莓派安装Hassbian
适用对象:喜欢折腾,有一定的代码功底,或者有一定的英语能力,可以看懂错误及排查,优点比较稳定。
安装方法:
1:下载树莓派Hassbian安装镜像:Download the Hassbian image
2:下载镜像写入工具Etcher:For mac,For Windows,这里我用的Mac,所以给出双平台的链接,大家自行下载。
3:把内存卡插入读卡器,把读卡器插入电脑,用Etcher写入下载好的Hassbian的镜像。
4:链接无线网络,新建一个conf文件,命名为[size=14.399999618530273px]wpa_supplicant.conf,放入写好的内存卡Boot目录下,代码如下:
country=SE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR_SSID"
psk="YOUR_PASSWORD"
}
自行更改WIFI名称及密码就可以了,这里推荐使用Atom:Download For Mac,Download For Windows进行代码编辑。后面会经常用到。
5:拔下内存卡,放入树莓派,连上电源开机,大概10分钟左右,会自动配置好HA的环境(时间看网速而定)。
进入http://hassbian.local:8123检查是否安装完成。
6:安装常用插件,这里做个论坛的搬运,原贴:https://bbs.hassbian.com/forum.p ... &highlight=hassbian(感谢这位ID为“遥远”的坛友,这里稍微整合,方便查看。),代码如下:
#更新-升级
sudo apt-get update
sudo apt-get upgrade -y
#设置语言、时间等
sudo raspi-config
#下载安装Nodejs(更新8版本,会有二行红色报错,无视)
curl -sL [url=https://deb.nodesource.com/setup_8.x]https://deb.nodesource.com/setup_8.x[/url] | sudo -E bash -
sudo apt-get install -y nodejs git libavahi-compat-libdnssd-dev
sudo npm install -g --unsafe-perm hap-nodejs node-gyp homebridge homebridge-homeassistant
cd /usr/lib/node_modules/homebridge/
sudo npm install --unsafe-perm bignum
cd /usr/lib/node_modules/hap-nodejs/node_modules/mdns
sudo node-gyp BUILDTYPE=Release rebuild
#这里先运行一次程序
homebridge
#键盘输入Ctrl+C停止,然后建立config.json配置文件
sudo nano /home/pi/.homebridge/config.json
#鼠标右键粘贴如下内容(XX处修改为树莓派的mac)
{
"bridge": {
"name": "Homebridge",
"username": "XX:XX:XX:XX:XX:XX",
"port": 51826,
"pin": "123-45-678"
},
"platforms": [
{
"platform": "HomeAssistant",
"name": "HomeAssistant",
"host": "http://127.0.0.1:8123",
"password": "raspberry",
"supported_types": ["binary_sensor", "climate", "cover", "device_tracker", "fan", "input_boolean", "light", "lock", "media_player", "remote", "scene", "sensor", "switch"]
}
]
}
#将homebridge设置成随系统启动
cd /
sudo useradd --system homebridge
sudo mkdir /var/homebridge
sudo cp ~/.homebridge/config.json /var/homebridge/
sudo cp -r ~/.homebridge/persist /var/homebridge
sudo chmod -R 0777 /var/homebridge
cd /etc/default
sudo nano homebridge
#将下面的内容复制粘贴进去,然后Ctrl+X,然后Y,回车,保存退出
HOMEBRIDGE_OPTS=-U /var/homebridge
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
#分界线
cd /etc/systemd/system
sudo nano homebridge.service
#将下面的内容复制粘贴进去,然后Ctrl+X,然后Y,回车,保存退出
[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target
[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
ExecStart=/usr/lib/node_modules/homebridge/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
#分界线
cd /
sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge
sudo systemctl status homebridge
#安装Samba(强烈建议安装,方便远程文件访问)
sudo <strong><font color="#FF0000">hassbian</font></strong>-config install samba
#安装MQTT(安装后会要求输入用户名和密码)
sudo hassbian-config install mosquitto
#按需求安装HDMI CEC功能
sudo hassbian-config install libcec
#重启树莓派
sudo reboot
后记:我自己没有用这个办法,因为网络问题放弃了这个,有些组件下载需要梯子,否则太慢了,我这边因为目前路由没有翻墙所以放弃这个了。后期有时间重新再补上其他基础设备接入的教程。
----------------------------------------------------------------------------------------分割线------------------------------------------------------------------------------------------
三:树莓派安装Hass.io
安装方法:
1:下载Hass.io安装镜像:Download For Pi 3
2:下载镜像写入工具Etcher:For mac,For Windows,这里我用的Mac,所以给出双平台的链接,大家自行下载。
3:把内存卡插入读卡器,把读卡器插入电脑,用Etcher写入下载好的Hassio的镜像。
4:编辑配置文件,配置WIFI。文件路径:[size=14.399999618530273px]system-connections/resin-sample代码如下:
[connection]
id=resin-wifi
type=wifi
[wifi]
hidden=true
mode=infrastructure
ssid=[color=#000000]WIFI名称[/color]
[ipv4]
method=auto
[ipv6]
addr-gen-mode=stable-privacy
method=auto
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=WIFI[color=#000000]密码[/color]
编辑并保存文件,这里依然用Atom编辑:Download For Mac,Download For Windows。
5:拔下内存卡,放入树莓派,连上电源开机,系统会自动连接网络配置HA环境。这个过程就有点漫长了,20分钟左右,看网速。建议去吃个饭,再看看安装进度。
http://hassio.local:8123,进这个地址查看安装是否完成。
6:常用插件的安装:这个就比较简单了:
进入Hassio页面:
目前是我已经安装好的几个常用插件。安装方法如下:
添加源地址:https://github.com/hassio-addons/repository,点击save。
目前是学习阶段,不建议安装太多插件,否则出现报错会有点懵逼,根据需求来,第一部分我主要接入sonoff,黑豆两个设备。
所以我装了下面几个插件:
homebridge:用于SIRI控制设备
Mqtt:协议服务
SSH:远程控制
Samba:局域网访问HA配置文件
后记:目前是基于Hassio做的一些常用教程,因为这个安装和维护相对都比较简单(其实是懒)。
坑:
Samba配置:
在Samba插件下的Options下,贴入下面的代码:
{
"workgroup": "WORKGROUP",
"name": "hassio",
"guest": true,
"map": {
"config": true,
"addons": true,
"ssl": false,
"share": true,
"backup": true
},
"username": "",
"password": "",
"interface": "wlan0"
}
注意:最后一行的wlan0,如果你的树莓派是用WIFI接入路由的,那么不用改动,如果是用网线接入的,则要把wlan0改成[size=1em]eth0。
HA安装篇结束
----------------------------------------------------------------------------------------分割线------------------------------------------------------------------------------------------
基础设备接入:
sonoff接入HA:
1:准备工作,一个刷好的Sonoff开关。(刷机教程请参考:https://bbs.hassbian.com/forum.p ... 19&highlight=sonoff)
2:配置Mqtt服务,输入一下代码段到Mqtt服务的Options,点击Save。
{
"plain": true,
"ssl": false,
"anonymous": true,
"logins": [
{"username": "testuser", "password": "mypw"}
],
"customize": {
"active": false,
"folder": "mosquitto",
}
}
修改一下用户名和密码,密码一般是raspberry,保存以后重启MQTT服务就完成了。
3:添加代码到HA的配置文件:
mqtt:
broker: 172.20.10.4#你的树莓派在局域网的地址
port: 1883
client_id: home-assistant-1
keepalive: 60
username: hassio
password: raspberry
protocol: 3.1
switch:
- platform: mqtt
name: "LED Test"
state_topic: "stat/S1/POWER"
command_topic: "cmnd/S1/POWER"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
4:配置Sonoff的MQTT服务,由于没有截图,坛友有更详细的教程,就不在此赘述,配置方法请移步:https://bbs.hassbian.com/forum.p ... 05&highlight=sonoff
5:sonoff接入电路,重启HA,惊喜是不是发生了?HA主页,还有IPhone的家庭APP中是不是出现开关了?
Sonoff接入到此结束。
坑:
1:刷机工具直接下载硬盘ZIP版,不要下载EXE运行文件,到时候会导致配置路径不对,很是蛋疼。
2:选择刷机文件的时候,选择Sonoff文件夹下BIN文件。
3:刷机完毕以后,一定要测试是否刷机成功,看能不能正常接入WIFI,进入配置网页。
黑豆接入HK及空调码学习:
1:准备工作,博联黑豆一只。
2:进入Homebridge插件页面,安装homebridge-broadlink-rm插件。
如图:
在options里面输入一下代码:
{
"plugins": [
"homebridge-broadlink-rm"
]
}
点击Save,重启homebridge,这样就完成了博联插件的安装,然而还没有完。
3:修改homebridge配置文件,把一下代码,贴到你的Hassio文件夹下,homebridge/config.json中:
{
"bridge": {
"name": "Homebridge",
"username": "B8:27:EB:43:7C:A4",#地址请自行更改,用Fing在手机上可以看到。
"port": 51826,
"pin": "123-45-678"
},
"description":"Homebridge",
"accessories":[
],
"platforms":[
{
"platform":"BroadlinkRM",
"name":"Broadlink RM",
"hideScanFrequencyButton": false,
"hideLearnButton": false,
"accessories":[
{
"name":"Air Conditioner",
"type":"air-conditioner",
"defaultCoolTemperature": 25,
"defaultheatTemperature": 28,
"data":{
"off":"2600ca008f920f3810140f3810380f140f1410380f140f1410380f140f1410380f38101310380f1410380f38103710380f1410380f38103710140f14101310140f38101310140f37113710380f1410140f140f14101310140f14101310380f3810380f38103710ad8f9210380f140f3810380f14101310380f14101310380f14101310380f3810140f380f1410380f3810380f380f1410380f3810380f140f14101310140f38101310140f3810380f38101310140f140f14101310140f14101310380f3810380f3810380f000d050000000000000000000000000000",
"temperature30":{
"pseudo-mode":"heat",
"data":"26002e018f9210371014103710380f1410140f380f1410140f380f1410140f380f3810140f38103710140f3810380f38103710380f3810140f38101310140f140f1410140f140f3810140f380f1410380f38101310140f140f3810140f38101310140f3810380fad8f9210380f140f3810380f14101310380f14101310380f14101310380f3810140f38103710140f3810380f38103710380f3810140f38101310140f140f1410140f140f3810140f380f1410380f38101310140f140f3810140f38101310140f3810380fad8f9210380f38101310380f14103710140f38101310380f3810140f140f3810380f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f380f3810380f14103710380f000d0500000000000000000000"
},
"temperature29":{
"pseudo-mode":"heat",
"data":"26002e0191901136121211361136121211121136121211121136121211121136123611121137113611121137113512371136113711360f1411371112101311130f1410131113103711121137111211361236121111121113113611121236121111121236123512ab909112351311123512351311121112361211121112361211121112361235121112361235121212351235133512351236123512111335121112111311121112111212123512111333141112351335121112111311123512111335121112111335123513aa919012351333141112351311123513111235121113351235131112111235133512111211131112111211121113111211121113111211121112111311121112111311121112111211131112111211131112111211121113351235133512111235133512000d0500000000000000000000"
},
"temperature28":{
"pseudo-mode":"cool",
"data":"26002e01909111361212113611361212111211361212111211361212111211361236111211371136111212361136113711361136123611121137111211121112121211121112123611121112121211121112111311121112113612361136123611361137113611ab919111361112123611361113111211361113111211361212111211361137111211361236111211361236113612361136113711121136121211121112121211121112113711121112111212121112111212121112113611371136113612361136123611ab919012361136121211361112123611121136121211361137111211121236113611121212111211121113111211121112121211121112111311121112111212121112111211131112111211121212111211121113111211361137113611121236113611000d0500000000000000000000"
},
"temperature27":{
"pseudo-mode":"cool",
"data":"26002e01928f13361111123513351211121113351211121113351211121113351235131112351235131112351236123512351335123513111235121113111211121113111211123513111211123513111211121112111311123512351311123513351235123513aa928f13351211123513351211121113351211121113351211121113351235131112351235131112351235133512351335123513111235121113111211121112111311123512111311123512111311121112111311123512351311123512361235123513aa928f12351335121113351211123513111235121113351235131112111235133512111211131112111211121113111211121113111211121112111311121112111311121112111211131112111211131112111211121113351235133512111235133512000d0500000000000000000000"
},
"temperature26":{
"pseudo-mode":"cool",
"data":"26002e018f920f3810140f380f3810140f14103710140f14103710140f14103710380f1410380f38101310380f3810380f3810380f380f1410380f14101310140f140f14101310380f3810140f38101310140f140f1410140f140f38101310380f3810380f3810ad8f920f3810140f3810380f140f1410380f140f1410380f140f1410380f380f1410380f38101310380f3810380f3810380f38101310380f14101310140f140f1410140f380f3810140f38101310140f140f1410140f140f3810140f380f3810380f3810ad8f920f3810380f1410380f140f3810140f38101310380f38101310140f3810380f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310380f3810380f14103710380f000d0500000000000000000000"
},
"temperature25":{
"pseudo-mode":"cool",
"data":"26002e018f930f38101310380f3810140f140f3810140f140f3810140f140f3810380f14103710380f1410380f38103710380f3810380f14103710140f14101310140f140f1410380f3810140f140f14101310140f140f1410140f380f3810380f3810380f3810ad8f92113610140f380f3810140f140f3810140f14103712120f14103712361112103811361112103811361236113612361136111212361112111212120f14111212120f381136121211121112121211120f141112121211361236113611361236113612ab8f9211361236111212361112113612121136121112361136121211121136123611121112121211121112121211121112111212121112111212121112111211121212111211121212111211121112121211121112121211361136123611121136123611000d0500000000000000000000"
},
"temperature24":{
"pseudo-mode":"cool",
"data":"26002e018f930f38101310380f3810140f140f3810140f140f3810140f140f3810380f14103710380f1410380f3810380f38103710380f1410380f140f1410140f140f14101310140f38101310140f140f1410140f140f3810140f38103710380f3810380f3810ad8f920f3810140f3810380f140f1410380f140f1410380f140f1410380f38101310380f3810140f38103710380f381036113810140f380f1410140f140f14101310140f14103710140f14101310140f140f1410380f140f3810380f3810380f3810380fad8f9210380f3810140f380f1410380f140f3810140f38103710140f1410380f380f1410140f140f14101310140f14101310140f140f14101310140f14101310140f140f1410140f140f14101310140f140f14101310140f3810380f38101310380f3810000d0500000000000000000000"
},
"temperature23":{
"pseudo-mode":"cool",
"data":"26002e019192103611140f3810380f140f1410380f14101310380f14101310380f38101310380f3810140f3810380f380f3810380f3810140f38101310140f140f1410140f140f14103710140f38101412111211121112360f14103710140f3810380f38103811ab919013351211123513351211121211361112111311361112111311361136121211361136121211361137113611371136113611131136111211131112101311131112111212351311123512121211121112111335121112351311123513351234133513aa928f1335123513111136111212361112113610140f3810380f140f1410380f38101310140f140f1410140f140f14101310140f1410131212121112111212121112111211121212111211121212111211121113111211123510380f3810140f38103710000d0500000000000000000000"
},
"temperature22":{
"pseudo-mode":"cool",
"data":"26002e01919013351211123611361211121211361211121211361211121211361236111211361236111210371236113612360f38123611120f3810140f140f1410140f140f14101310380f38103811120f1410140f140f3811130f140f14103712360f38103811ab8f921236111211371136111212120f38111210140f38111212120f3811361212113612361112113612361136123611361136121211361211121211120f1412121112111212361136113612121112111212121136111212121112113612361136123512ab8f9212361136111212361112113612121136121211361136121211121136123611121112121211121112111212121112111212121112111212121112111211121212111211121112121211121112101411120f14111212361136123611121136123611000d0500000000000000000000"
},
"temperature21":{
"pseudo-mode":"cool",
"data":"26002e018f930f38101310380f38101310140f3810140f140f3810140f140f3810380f14103710380f1410380f3810380f38103710380f1410380f140f14101310140f14101310140f3810380f140f14101310140f14103710140f14103710380f3810380f3810ad8f920f3810140f3810380f140f1410380f140f1410380f140f1410380f38101310380f38101310380f3810380f3810380f38101310380f14101310140f140f1410140f140f3810380f14101310140f140f1410380f140f1410380f38103710380f3810ad8f9210380f38101310380f1410380f140f3810140f38103710140f14103710380f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f3810380f38101310380f3810000d0500000000000000000000"
},
"temperature20":{
"pseudo-mode":"cool",
"data":"26002e0191901235131112351236111211121236111211121236111211121236113611121236113612121136113612361136123611361211123611121211121211121112121211121112103811120f1410140f140f14103710380f1410380f38103710380f3810ad919012361211123512360f14101310380f14101310380f14101310380f38101310380f3810140f38103710380f3810380f38101310380f1410140f140f14101310140f140f1410380f14101310140f140f1410380f38101310380f3810380f3810380fad8f9210380f38101310380f1410380f140f3810140f38103710140f1410380f380f1410140f140f14101310140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f3810380f38101310380f3810000d0500000000000000000000"
},
"temperature19":{
"pseudo-mode":"cool",
"data":"26002e01919012351311113612361211121112361211121112361211121112361235121112361235121211361136123611361236113611131136111211131112111211121113111211121137113611121113111211121137113610131113113611361236113611ac8f92113612120f3811370f14101311371112111211371112101311371136111311361136121211361137123512351335123513111235111212121112111212121112111211121236113610140f140f14101310380f3810140f140f3810380f3810380fad928f1236123512121235121112361211123513111235123612111211103812351013101412110f1410140f140f14101310140f140f1412120f140f14101310140f140f1410140f140f14101310140f14101310140f140f3810380f38101310380f3810000d0500000000000000000000"
},
"temperature18":{
"pseudo-mode":"cool",
"data":"26002e018f9210380f140f3810380f14101310380f14101310380f14101310380f3810140f380f3810140f3810380f38103710380f3810140f38101310140f140f1410140f140f14101310140f38101310140f14101310380f3810380f140f3810381235123612aa928f1236121112351236121112121235121112121136121112121136123512121235123512121235123612351236123512351212123510141112121112111212121112111212121112351212111212111211123612351236121112351236123512360fad928f10380f3810140f380f1410380f140f3810140f38103710140f1410380f380f1410140f140f14101310140f14101310140f140f1410140f140f14101310140f140f1410140f140f14101310140f140f1410140f140f3810380f38101310380f3810000d0500000000000000000000"
},
"temperature17":{
"pseudo-mode":"cool",
"data":"26002e018f9210380f1410380f38101310140f38101310140f38101310140f38103710140f3810380f140f3810380f3810380f38103710140f3810140f140f14101310140f14101310140f140f14101313110f141013103812351236123512351335123512360fad8f9210380f14103811361112121211361112121211361211121211361235131111361335121112351335123513351235123612111136131111121112121211121112111212121112111212121112111211121236113611371136113711361136113711ab928f13351235131112351211133512111235131112351335121112111335123512111311121112111212111211121113111211121113111211121112121211121112121211121112111212121112111212121112111212351335123512121136123512000d0500000000000000000000"
}
}
}
]
}
]
}
这里的代码是美的的挂机,同样品牌的空调可以先试一下,看这个码适不适配,如果适配,那么恭喜你,离成功又进了一步,如果不适配,请继续学码。
4:学习空调码,做好上面的工作以后,重启HA。添加好HB后,发现Learn按键, 点击按下Learn 键,此时黑豆指示灯灯处于橙色状态,把要学习的红外/或者射频的遥控器按键按下让黑豆学习。
按照上面的教程,要学习不同温度的码:按下手机上的Learn键,将空调遥控器对应按钮对准黑豆,然后学习结束后,在homebridge下点击Logs下面的刷新按钮,就可以看到黑豆学习的HEX码,复制学习好的码,填到上面的配置文件中,就可以愉快的用SIRI控制空调了。
至此博联黑豆接入HK结束,这个很简单,全程无坑。
-------------------------------------------------------------------黑豆及Sonoff接入教程结束---------------------------------------------------------------------------------------
只要你愿意去学习,一切都会很简单,一个小白的成长笔记。
不懂的朋友可以直接回帖,我会抽空回答。下次继续更新。
|
评分
-
查看全部评分
|