Ubuntu智能家居应用之三:HomeBridge的安装
(2017-11-17 20:21:55)分类: 智能家居 |
###更新和安装源###
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y samba screen git
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash
-
sudo apt-get install -y nodejs
sudo apt-get -y install libavahi-compat-libdnssd-dev
sudo npm install -g --unsafe-perm homebridge hap-nodejs
node-gyp
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
cd /
sudo npm install -g homebridge-homeassistant
homebridge
#####这里先运行一次程序######
######键盘输入Ctrl+C停止homebridge运行,将再次出现命令提示符######
cd /home/baso0204/.homebridge
###########键盘输入Ctrl+C停止,然后建立config.json配置文件########
sudo nano config.json
################鼠标右键粘贴如下内容######################
00:0c:29:41:40:44
{
}
###################分界线#####################################
上面的内容,注意格式,粘贴完毕后,按键盘上的Ctrl+X键,输入 Y,保存退出。
另外:请注意这几段段代码
"host": "http://192.168.1.100:8123",
###其中的192.168.1.100是你的Ubuntu的局域网IP地址####
###这个是密码,因为我们没有修改Ubuntu的登录密码####
##############再次输入homebridge
回车,检查运行有没有错误########
####将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,回车,保存退出####
# 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)
HOMEBRIDGE_OPTS=-U /var/homebridge
# 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
sudo reboot
####重启树####
###最后,你想返回去修改PIN码,MAC地址等等参数,可以按以下命令行来做####
sudo systemctl stop homebridge
###停止homebridge运行###
cd /var/homebridge
###进入目录###
sudo nano config.json
###编辑配置文件###
sudo reboot
###重启树莓派####
pip3 install homeassistant==0.XX.X
###安装指定版本的homeassistant###