HomeBridge on raspberry pi
Install Homebridge
Method 1: Install HomeBridge ISO directly
github address:https://github.com/homebridge/homebridge-raspbian-image/releases
Method 2: Install manually
In Terminal, execute the following:
1 |
|
Control the power supply of USB port using HomeKit
In Terminal, install ‘uhubctl’
1 |
|
Command to control the power supply:
1 |
|
Then we need to solve the permission problem by configuring ‘udev USB’ permission. (Otherwise, we have to run uhubctl as root
, but by default HomeBridge service will not run as root.)
Run
sudo uhubctl
, see the VID of the port we need to control. (Or find it in uhubctl docs.Add the following udev rule to file
/etc/udev/rules.d/52-usb.rules
. Don’t forget to replace the VID.On raspi 3B+ :
1
SUBSYSTEM=="usb", ATTR{idVendor}=="0424", MODE="0666"
On raspi 4 (one for USB2 and one for USB3) :
1
2SUBSYSTEM=="usb", ATTR{idVendor}=="2109", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", MODE="0666"
To let udev rules function correctly, execute:
1
sudo udevadm trigger --attr-match=subsystem=usb
Test the following command without using
sudo
to check if you can control USB power supply:1
2uhubctl -l 1-1 -p 2 -a on # turn power on
uhubctl -l 1-1 -p 2 -a off # turn power off
Then, install plugin ‘Script2’ in HomeBridge
Enter config and add the following:
1 |
|
Get the token of MJ (米家) devices
https://www.home-assistant.io/integrations/xiaomi_miio#xiaomi-cloud-tokens-extractor-1
github address: https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor/blob/master
HomeKit Camera (No success)
bilibili video demo:
https://b23.tv/vu977y
1 |
|
Github repo address memtioned:
https://github.com/Sunoo/homebridge-camera-ffmpeg
https://sunoo.github.io/homebridge-camera-ffmpeg/configs/Raspberry-Pi-with-Camera-Module.html
Step1. Install HomeBridge system
Start raspi (no need to connect keyboard, mouse, HDMI port), wait a while and connect the wifi named HomeBridge WIFI Setup
after it appears. Enter the wifi keyboard (If raspi fails to detect your wifi, just wait a while and try again).
The default username and password (if you want to ssh connect to your pi) is pi
and raspberry
2 Install HomeBridge Plugin Camera FFMpeg
3 Create a service
1 |
|
Create the file /etc/systemd/system/camera-loopback.service
1 |
|
Activate with sudo systemctl enable camera-loopback
and start with sudo systemctl start camera-loopback
4 Edit config.json
of HomeBridge
Add to the platforms
:
1 |
|