python3.6.5(或更新版本)
pip3
libffi-devel
zlib1g
zlib1g-devel
python3-pip
libavahi-compat-libdnssd-dev
git
$ sudo pip3 install -U pip
$ sudo pip3 install virtualenv
$ sudo useradd -rm homeassistant
$ sudo mkdir /srv/homeassistant
$ sudo chown homeassistant:homeassistant /srv/homeassistant
$ sudo su -s /bin/bash homeassistant
$ virtualenv -p python3 /srv/homeassistant
$ source ./homeassistant/bin/activate
$ pip3 install netdisco
$ pip3 install -U homeassistant
[注意]
如果安装中出现“the ssl module in Python is not available”错误,则需要安装libssl-dev和openssl依赖包,并重新编译安装python3(3.5.3以上)。配置编译时添加–with-ssl参数。
$ sudo apt-get install -y curl
$ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
如果安装速度慢可以改成国内源
$ sudo nano /etc/apt/sources.list.d/nodesource.list
添加
deb https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_7.x xenial main
deb-src https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_7.x xenial main )
$ sudo apt-get update
$ sudo apt-get install -y nodejs
$ sudo npm install -g --unsafe-perm homebridge
$ sudo npm install -g homebridge-homeassistant
[注意]
如果是用手机Linux Deploy搭建的系统,需要以下额外步骤:
将 /etc/avahi/avahi-daemon.conf 文件中publish部分所有参数都注释掉
将/etc/init.d/avahi-daemon 文件中d_start() 部分 $DAEMON 后面添加 --no-drop-root 参数
$ sudo /etc/init.d/dbus start
$ sudo /etc/init.d/avahi-daemon start
$ sudo useradd -rm homebridge
$ sudo mkdir /var/opt/homebridge
$ sudo cp -R ~/.homebridge/* /var/opt/homebridge
$ sudo chown -R homebridge:homebridge /var/opt/homebridge
sudo apt-get install -y mosquitto mosquitto-clients
(测试运行:
订阅主题:mosquitto_sub -h localhost -t hello/world -u username -P password
发布主题:mosquitto_pub -h localhost -t hello/world -m “HELLO” -u username -P password
)
allow_anonymous 允许匿名
password_file 密码文件
acl_file 访问控制列表
$ sudo chown mosquitto:mosquitto mosquitto.conf
$ sudo touch pwfile
$ sudo mosquitto_passwd -b pwfile "username" "password"
$ sudo chown mosquitto:mosquitto pwfile
$ sudo chmod u+rw pwfile
$ sudo /etc/init.d/mosquitto start
$ vi /home/homeassistant/.homeassistant/configuration.yaml
添加
mqtt:
broker: xxx.xxx.xxx.xxx
port: 1883
username:
password:
broker为本机IP地址
$ vi /var/opt/homebridge/config.json
添加
{
"bridge": {
"name": "Homebridge",
"username": "xx:xx:xx:xx:xx:xx",
"port": 51826,
"pin": "123-45-678"
},
"platforms": [
{
"platform": "HomeAssistant",
"name": "HomeAssistant",
"host": "http://xxx.xxx.xxx.xxx:8123",
"password": "",
"supported_types": ["automation", "binary_sensor", "climate", "cover", "device_tracker", "fan", "group", "input_boolean", "light", "lock", "media_player", "remote", "scene", "sensor", "switch"],
"default_visibility": "visible"
}
]
}
username为设备mac地址