[IOT프로젝트] 3. HomeBridge on AoL

category AndroidOverLinux 2019.09.08 20:27

안녕하세요?


애플 HomeKit 와 커스텀 연동을 할 수 있는 홈브릿지를 AoL에 올려보겠습니다.




1. 의존 패키지 설치하기


# nodejs 설치

root@AOL-Debian:/homecurl -sL https://deb.nodesource.com/setup_9.x | sudo bash -


## Installing the NodeSource Node.js 9.x repo...



## Populating apt-get cache...


+ apt-get update

Ign:1 http://ftp.kr.debian.org/debian stretch InRelease

Get:2 http://ftp.kr.debian.org/debian stretch-backports InRelease [91.8 kB]

Get:3 http://ftp.kr.debian.org/debian unstable InRelease [139 kB]                   

Get:4 http://ftp.kr.debian.org/debian stretch Release [118 kB]     

Get:5 http://ftp.kr.debian.org/debian stretch Release.gpg [2,410 B]                               

Get:6 http://ppa.launchpad.net/mhier/libboost-latest/ubuntu eoan InRelease [15.9 kB]              

Get:7 http://ftp.kr.debian.org/debian unstable/non-free Sources.diff/Index [27.8 kB]

Get:8 http://ftp.kr.debian.org/debian unstable/main Sources.diff/Index [27.9 kB]



root@AOL-Debian:/homeapt install nodejs


# 의존패키지 설치

root@AOL-Debian:/home/homebridge# apt install libavahi-compat-libdnssd-dev

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following packages were automatically installed and are no longer required:

  dtv-scan-tables dvb-apps makedev

Use 'apt autoremove' to remove them.

The following additional packages will be installed:

  libavahi-compat-libdnssd1

The following NEW packages will be installed:

  libavahi-compat-libdnssd-dev libavahi-compat-libdnssd1

0 upgraded, 2 newly installed, 0 to remove and 100 not upgraded.

Need to get 104 kB of archives.

After this operation, 243 kB of additional disk space will be used.

Do you want to continue? [Y/n]





2. homebridge 설치하기


# 홈브릿지 폴더 생성

root@AOL-Debian:/home# mkdir homebridge

root@AOL-Debian:/home# cd homebridge/


# 지정 폴더에 홈브릿지 설치

root@AOL-Debian:/home/homebridge# npm install --unsafe-perm --prefix /home/homebridge/ homebridge

npm WARN saveError ENOENT: no such file or directory, open '/home/homebridge/package.json'

npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN enoent ENOENT: no such file or directory, open '/home/homebridge/package.json'

npm WARN homebridge No description

npm WARN homebridge No repository field.

npm WARN homebridge No README data

npm WARN homebridge No license field.


+ homebridge@0.4.50

added 46 packages in 7.583s


# 홈브릿지 설정폴더 생성

root@AOL-Debian:/home/homebridge# mkdir config


# 예제 설정파일 복사 및 값 수정

root@AOL-Debian:/home/homebridge# cp node_modules/homebridge/config-sample.json config/

root@AOL-Debian:/home/homebridge# cd config/

root@AOL-Debian:/home/homebridge/config# mv config-sample.json config.json


root@AOL-Debian:/home/homebridge/config# cat config.json 
{
  "bridge": {
    "name": "Homebridge",
    "username": "CC:22:3D:E3:CE:30",
    "port": 51826,
    "pin": "031-45-154"
  },

  "accessories": [
  ],

  "platforms": [
  ]
}


# 실행 테스트

root@AOL-Debian:/home/homebridge# /home/homebridge/node_modules/homebridge/bin/homebridge -U /home/homebridge/config

[2019-9-8 20:07:09] Loaded config.json with 0 accessories and 0 platforms.

[2019-9-8 20:07:10] ---

[2019-9-8 20:07:10] No plugins found. See the README for information on installing plugins.

[2019-9-8 20:07:10] Loading 0 platforms...

[2019-9-8 20:07:10] Loading 0 accessories...

Setup Payload:

Scan this code with your HomeKit app on your iOS device to pair with Homebridge:

                                                      

Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:

                       

    ┌────────────┐     

    │ 031-45-154 │     

    └────────────┘     

                       

[2019-9-8 20:07:10] Homebridge is running on port 51826.





3. web ui 플러그인 설치하기


# 홈브릿지 UI 플러그인 설치

root@AOL-Debian:/home/homebridge# npm install --unsafe-perm homebridge-config-ui-x --prefix /home/homebridge/


> node-pty-prebuilt-multiarch@0.9.0-beta2 install /home/homebridge/node_modules/node-pty-prebuilt-multiarch

> prebuild-install || node scripts/install.js



> @nestjs/core@6.5.3 postinstall /home/homebridge/node_modules/homebridge-config-ui-x/node_modules/@nestjs/core

> opencollective || exit 0


                          Thanks for installing nest 🙏

                 Please consider donating to our open collective

                        to help us maintain this package.

                                         

                           Number of contributors: 110

                              Number of backers: 215

                            Annual budget: US$ 68,326

                            Current balance: US$ 5,156

                                         

       👉  Become a partner: https://opencollective.com/nest/donate

                                         


> node-pty-prebuilt-multiarch@0.9.0-beta2 postinstall /home/homebridge/node_modules/node-pty-prebuilt-multiarch

> node scripts/post-install.js


npm WARN saveError ENOENT: no such file or directory, open '/home/homebridge/package.json'

npm WARN enoent ENOENT: no such file or directory, open '/home/homebridge/package.json'

npm WARN homebridge No description

npm WARN homebridge No repository field.

npm WARN homebridge No README data

npm WARN homebridge No license field.


+ homebridge-config-ui-x@4.6.1

added 281 packages in 65.49s


# 홈브릿지 UI 플러그인 선언하기

root@AOL-Debian:/home/homebridge# nano config/config.json 


{

  "bridge": {

    "name": "Homebridge",

    "username": "CC:22:3D:E3:CE:30",

    "port": 51826,

    "pin": "031-45-154"

  },


  "accessories": [

  ],


  "platforms": [

    {

      "platform": "config",

      "name": "Config",

      "port": 50000,

      "sudo": false

    }

  ]

}


# 기본 인증 파일을 지워 새로 생성하게 하기 (admin / admin 계정 생성)

root@AOL-Debian:/home/homebridge/config# rm auth.json


root@AOL-Debian:/home/homebridge/config# /home/homebridge/node_modules/homebridge/bin/homebridge -U /home/homebridge/config

[2019-9-8 20:17:19] Loaded config.json with 0 accessories and 1 platforms.

[2019-9-8 20:17:19] ---

[2019-9-8 20:17:19] Loaded plugin: homebridge-config-ui-x

[2019-9-8 20:17:19] Registering platform 'homebridge-config-ui-x.config'

[2019-9-8 20:17:19] ---

[2019-9-8 20:17:19] Loading 1 platforms...

[2019-9-8 20:17:19] [Config] Initializing config platform...

[2019-9-8 20:17:19] [Config] Spawning homebridge-config-ui-x with PID 13290

[2019-9-8 20:17:19] Loading 0 accessories...

...............................
[2019-9-8 20:17:20] Homebridge is running on port 51826.
[2019-9-8 20:17:27] [Config] Homebridge Config UI X v4.6.1 is listening on :: port 50000
[2019-9-8 20:17:28] [Config] Added new user: admin







4. 자동실행 설정하기


root@AOL-Debian:~# wget https://github.com/djjproject/android_over_linux/raw/master/init.d/homebridge -O /etc/init.d/homebridge

--2019-09-08 20:21:46--  https://github.com/djjproject/android_over_linux/raw/master/init.d/homebridge

Resolving github.com (github.com)... 15.164.81.167

Connecting to github.com (github.com)|15.164.81.167|:443... connected.

HTTP request sent, awaiting response... 302 Found

Location: https://raw.githubusercontent.com/djjproject/android_over_linux/master/init.d/homebridge [following]

--2019-09-08 20:21:47--  https://raw.githubusercontent.com/djjproject/android_over_linux/master/init.d/homebridge

Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...

Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 1113 (1.1K) [text/plain]

Saving to: ‘/etc/init.d/homebridge’


/etc/init.d/homebridge    100%[====================================>]   1.09K  --.-KB/s    in 0s      


2019-09-08 20:21:48 (5.78 MB/s) - ‘/etc/init.d/homebridge’ saved [1113/1113]


root@AOL-Debian:~# chmod a+x /etc/init.d/homebridge 

root@AOL-Debian:~# update-rc.d homebridge defaults

root@AOL-Debian:~# service homebridge start

Starting homebridge: homebridge.


감사합니다.





댓글을 달아 주세요