文章目录[隐藏]
首先是USB摄像头接入HA的方法:
1.查看摄像头位置
使用命令
1
|
ls -l /dev/video*
|
2.直接在HA配置
1
2
3
4
|
camera:
– platform: ffmpeg
name: ctsxt
input: /dev/video0
|
3.重启HA
简单爆了有木有!!
接入HA这里就讲完了。下面我们讲一讲接入HomeKit方法。
首先安装Home Bridge
1
2
3
4
5
6
|
sudo apt-get install nodejs
sudo apt-get install 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
|
看能不能正常启动
1
|
homebridge
|
然后安装sudo npm install homebridge-homeassistant -g这一步接摄像头不是必须,这是HA接HB的插件。
安装摄像头插件
<br data-filtered="filtered" /><span class="nb">sudo </span>npm install <span class="nt">-g</span> homebridge-camera-ffmpeg
编辑config.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
{
“bridge”: {
“name”: “Homebridge”,
“username”: “B8:27:EB:5F:8A:95″,#主机,树莓派的网卡信息
“port”: 35115,
“pin”: “123-45-678”
},
“platforms”: [{
“platform”: “Camera-ffmpeg”,
“cameras”: [{
“name”: “BasementCam”,
“videoConfig”: {
“source”: “-f v4l2 -r 30 -s 1280×720 -i /dev/video0”,
“maxStreams”: 2,
“maxWidth”: 1280,
“maxHeight”: 720,
“maxFPS”: 30,
“vcodec”: “h264_omx”
}
}]
}]
}
|
再次启动homebridge
我们来看看有没有报错
设置Home Bridge自启动
1
2
3
4
5
6
7
8
9
|
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
|
1
2
|
cd /etc/default
sudo nano homebridge
|
填写内容
1
2
3
4
5
6
7
|
# 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=*
|
1
2
|
cd /etc/systemd/system
sudo nano homebridge.service
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[Unit]
Description=Node.jsHomeKitServer
After=syslog.target network-online.target
[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
ExecStart= /usr/local/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
|
1
2
3
4
5
|
cd /
sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge
sudo systemctl status homebridge
|
重启树莓派
在手机上添加设备
折腾结束。
浏览量: 36