本教程适用于斐讯N1的armbian和树莓派,注意修改$HOME为运行homebridge的用户家目录。

安装各种依赖:

sudo apt-get -y install nodejs
sudo apt-get -y install npm
sudo npm install -g npm
sudo npm install -g n
sudo n stable
sudo apt-get -y install libavahi-compat-libdnssd-dev
sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
sudo npm install -g homebridge-ip-camera
下面文件保存为config.json 到$HOME/.homebridge/config.json ,注意修改$HOME为运行homebridge的用户家目录。

{
	"bridge": {
		"name": "Homebridge",
		"username": "B8:27:EB:5F:8A:95",
		"pin": "031-45-154"
	},
	"platforms": [{
		"platform": "Camera-IP",
		"cameras": [{
			"name": "Camera-1",
			"videoConfig": {
				"source": "-re -i http://127.0.0.1:8081",
				"maxStreams": 8,
				"maxWidth": 1280,
				"maxHeight": 720,
				"maxFPS": 30,
				"vcodec": "h264_omx"
			}
		}]
	}]
}
设置Home Bridge自启动,注意修改$HOME为运行homebridge的用户家目录。

保存下面内容到/etc/systemd/system/homebridge.service

[Unit]
Description=Node.js HomeKit Server 
After=syslog.target network-online.target
 
[Service]
Type=simple
User=pi
ExecStartPre=/bin/bash #HOME/.homebridge/mac.sh
ExecStart= /usr/local/bin/homebridge
Restart=on-failure
RestartSec=10
KillMode=process
 
[Install]
WantedBy=multi-user.target
设置开机加载

sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge
sudo systemctl status homebridge
下面脚本保存为mac.sh到 $HOME/.homebridge/ 下面,注意修改$HOME为运行homebridge的用户家目录。

#/bin/bash
MAC=$(sudo cat /sys/class/net/eth0/address)
M1=$(echo ${MAC^^})
config=$(jq '.bridge.username' $HOME/.homebridge/config.json)
M2=$(echo ${config//\"/})

if [ $M1 != $M2 ];
then
    command="/usr/bin/jq '.bridge.username = \"$M1\"' $HOME/.homebridge/config.json > ~/.homebridge/config1.json"
    echo $command > /tmp/temp.sh
    sudo chmod +x /tmp/temp.sh
    sudo /bin/bash /tmp/temp.sh
    sudo mv $HOME/.homebridge/config1.json $HOME/.homebridge/config.json
    sudo rm -rf /tmp/temp.sh
    sudo systemctl restart homebridge
fi

跟着教程操作还没有搞定的话,下载我装好的固件吧,刷进去就能用了。

树莓派:    https://t.me/itcommander/56
斐讯N1:    https://t.me/itcommander/55

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据