『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 5357|回复: 5

[基础教程] 整理了一份orange安装homeassistant和homebridge的无坑教程

[复制链接]

7

主题

89

帖子

395

积分

中级会员

Rank: 3Rank: 3

积分
395
金钱
306
HASS币
0
发表于 2018-2-3 16:17:40 | 显示全部楼层 |阅读模式
本帖最后由 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上使用




回复

使用道具 举报

14

主题

656

帖子

3846

积分

论坛元老

Rank: 8Rank: 8

积分
3846
金钱
3185
HASS币
10
发表于 2018-2-9 21:01:14 | 显示全部楼层
写的非常好啊 别的平台也是可以借鉴的
回复

使用道具 举报

7

主题

89

帖子

395

积分

中级会员

Rank: 3Rank: 3

积分
395
金钱
306
HASS币
0
 楼主| 发表于 2018-2-9 22:12:06 | 显示全部楼层
余歌唱晚 发表于 2018-2-9 21:01
写的非常好啊 别的平台也是可以借鉴的

感谢回复
回复

使用道具 举报

2

主题

97

帖子

1161

积分

论坛积极会员

积分
1161
金钱
1064
HASS币
0
发表于 2018-3-21 15:38:29 | 显示全部楼层
本帖最后由 yiwlg 于 2018-3-22 16:40 编辑

Ubuntu 16.04 安装65版本,需要先更新python3.6  


我刚刚在Ubuntu 16.04上将python升级到了3.6,并且我可以确认它可行,但我使用虚拟环境,并且我强烈建议您使用该版本,以便保留Ubuntu 16.04,因为在替换python 3.5时可能会中断系统。 2乘以3.6。
sudo add-apt-repository ppa:jonathonf/python-3.6sudo apt-get updatesudo apt-get install python3.6sudo apt-get install python3.6-venvsudo apt-get install python3.6-dev
但venv应该使用所需的python版本(显式)创建:
python3.6 -m venv homeassistant
回复

使用道具 举报

7

主题

89

帖子

395

积分

中级会员

Rank: 3Rank: 3

积分
395
金钱
306
HASS币
0
 楼主| 发表于 2018-3-22 16:03:17 | 显示全部楼层
yiwlg 发表于 2018-3-21 15:38
有坑啊,python3.5.2  不支持.....

原来是没坑的,最近homeassistant升级了  最低要3.5.3,自带的是3.5.2
回复

使用道具 举报

0

主题

4

帖子

40

积分

新手上路

Rank: 1

积分
40
金钱
36
HASS币
0
发表于 2018-7-18 10:56:16 | 显示全部楼层
安装到 sudo npm install --unsafe-perm bignum 这一步出错怎么办 ??错误如下::
root@orangepipc:/usr/lib/node_modules/homebridge# sudo npm install --unsafe-perm bignum
sudo: unable to resolve host orangepipc

> [email protected] install /usr/lib/node_modules/homebridge/node_modules/bignum
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=8.11.3 runtime=node arch=arm platform=linux)
make: Entering directory '/usr/lib/node_modules/homebridge/node_modules/bignum/build'
  CXX(target) Release/obj.target/bignum/bignum.o
  SOLINK_MODULE(target) Release/obj.target/bignum.node
  COPY Release/bignum.node
make: Leaving directory '/usr/lib/node_modules/homebridge/node_modules/bignum/build'
npm notice created a lockfile as package-lock.json. You should commit this file.
+ [email protected]
added 64 packages from 45 contributors and audited 125 packages in 35.01s
found 0 vulnerabilities
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-6 01:03 , Processed in 0.674056 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表