本帖最后由 jiang123574 于 2018-2-10 11:20 编辑
首先烧录armbian 地址
通电后在路由器里找到IP
用putty等工具进入
用户名root
密码1234
首次进入会叫你改密码
输入原密码1234
然后输入新密码
创建一个新用户
重启
等一会后再次进入
登入后
#配置时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#备份源
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
#更换源 复制下面##########中间部分
sudo nano /etc/apt/sources.list
################复制下面##########中间部分
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted
###################ctrl+x然后按Y保存
#更新系统
sudo apt-get update && sudo apt-get upgrade -y
#更新完成后重启
reboot
#做一些清理工作
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get purge -y
#安装python等
sudo apt-get install python3 python3-dev python3-pip python3-venv
#安装homebridge依赖
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install avahi-daemon avahi-discover libnss-mdns libavahi-compat-libdnssd-dev
sudo apt-get -y install libavahi-compat-libdnssd-devsudo apt-get install libffi-dev libssl-dev #miio必要依赖
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 /
#安装homebridge的homeassistant插件
sudo npm install -g homebridge-homeassistant
#安装homebridge
sudo useradd --system homebridge
#运行一次homebridge
homebridge
#按ctrl+c停止#在root/.homebridge下建立config.json文件,复制下面homebridge设置
################
{
"bridge": {
"name": "orange",
"username": "CC:22:3D:E3:AD:30",
"port": 51826,
"pin": "678-45-123"
},
"platforms": [
{
"platform": "HomeAssistant",
"name": "HomeAssistant",
"host": "http://127.0.0.1:8123",
"password": "zxczxc",
"supported_types": [
"fan",
"garage_door",
"input_boolean",
"light",
"lock",
"media_player",
"rollershutter",
"scene",
"switch"
]
}
]
}
#########################
#复制一些文件,并设置权限
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
#创建一个虚拟环境
python3 -m venv homeassistant
#打开虚拟环境
cd homeassistant
#激活虚拟环境
source bin/activate
#在虚拟环境中安装依赖
pip install --upgrade pip
pip3 install netdisco
pip3 install pycrypto
#安装homeassistant
python3-m pip install homeassistant
#安装和升级miio插件
pip3 install python-miio
pip3 install --upgradepython-miio
#0.62.1中有BUG 给依赖降级
pip3 install construct==2.8.22
#设置开机启动,建立service文件
sudo nano /etc/default/homebridge
#####################
# 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=*
###########################
#ctrl+x,y
sudo nano /etc/systemd/system/homeassistant.service
###################
[Unit]
Description=Home Assistant
After=network.target
[Service]
Type=simple
Environment=PATH="$VIRTUAL_ENV/bin:$PATH"
ExecStart=/root/homeassistant/bin/hass -c "/root/.homeassistant"
[Install]
WantedBy=multi-user.target
#####################
#ctrl+x,y
sudo nano /etc/systemd/system/homebridge.service
#####################
[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
##################
#ctrl+x,y
#更新系统设置
sudo systemctl daemon-reload
#设置HomeAssistant和homebridge开机启动
sudo systemctl enable homeassistant.service
sudo systemctl enable homebridge.service
#启动homeassistant和homebridge
sudo systemctl start homeassistant.service
sudo systemctl start homebridge.service
#重启
reboot
#查看homeassistant和homebridge状态
sudo systemctl status homeassistant.service
sudo systemctl status homebridge.service
复制代码
请注意
本次安装homeassistant的配置文件在root目录下,homebridge在/var/homebridge下
进入虚拟环境方法为
cd homeassistant
source bin/activate
修改配置可自行配置samba或者使用winscp工具
理论上更换源地址后可在各平台的linux上使用