본문 바로가기
IoT

[IOT프로젝트] 1. HomeAssistant on AoL

by ㅋㅋ잠자 2019. 9. 7.
반응형

안녕하세요? 


HA 를 AoL에 설치해 보겠습니다.


차후에 Docker 가 가능하다면 쉽게 갈 수 있으나, 아직 Docker 가 지원되지 않아서 Native 로 설치를 진행해야합니다. ㅠㅠ






1. 파이썬3 설치


root@AOL-Debian:~# apt install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev

Reading package lists... Done

Building dependency tree       

Reading state information... Done

libffi-dev is already the newest version (3.2.1-9).

libffi-dev set to manually installed.

libssl-dev is already the newest version (1.1.1c-1).

python3 is already the newest version (3.7.3-1).

python3 set to manually installed.

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

  apt-transport-https g++-6 gnupg-agent libaio1 libcaca0 libcdio-cdda1 libcdio-paranoia1 libcdio13

  libnfs8 libroar2 libsdl1.2debian libspeexdsp1 python3.5 python3.5-minimal

Use 'apt autoremove' to remove them.

The following additional packages will be installed:

  libpython3-dev libpython3.7 libpython3.7-dev python-pip-whl python3-asn1crypto python3-cffi-backend

  python3-crypto python3-cryptography python3-entrypoints python3-keyring python3-keyrings.alt

  python3-pkg-resources python3-secretstorage python3-setuptools python3-wheel python3-xdg

  python3.7-dev python3.7-venv

Suggested packages:

  python-crypto-doc python-cryptography-doc python3-cryptography-vectors gnome-keyring

  libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-secretstorage-doc python-setuptools-doc

The following NEW packages will be installed:

  libpython3-dev libpython3.7 libpython3.7-dev python-pip-whl python3-asn1crypto python3-cffi-backend

  python3-crypto python3-cryptography python3-dev python3-entrypoints python3-keyring

  python3-keyrings.alt python3-pip python3-secretstorage python3-setuptools python3-venv

  python3-wheel python3-xdg python3.7-dev python3.7-venv

The following packages will be upgraded:

  python3-pkg-resources

1 upgraded, 20 newly installed, 0 to remove and 410 not upgraded.

Need to get 52.0 MB of archives.

After this operation, 81.8 MB of additional disk space will be used.

Do you want to continue? [Y/n] 


파이썬 버전이 3.7버전이 설치됨으로 따로 컴파일 하여 올릴 필요가 없습니다.





2. virtualenv 생성 및 HA 설치


root@AOL-Debian:/home# mkdir homeassistant

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

root@AOL-Debian:/home/homeassistant# python3 -m venv .


root@AOL-Debian:/home/homeassistant# source bin/

activate          activate.fish     easy_install-3.7  pip3              python

activate.csh      easy_install      pip               pip3.7            python3


root@AOL-Debian:/home/homeassistant# source bin/activate


(homeassistant) root@AOL-Debian:/home/homeassistant# 


HA 설치


(homeassistant) root@AOL-Debian:/home/homeassistant# python3 -m pip install wheel

Collecting wheel

  Downloading https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl

Installing collected packages: wheel

Successfully installed wheel-0.33.6


(homeassistant) root@AOL-Debian:/home/homeassistant# pip3 install homeassistant

Collecting homeassistant

  Downloading https://files.pythonhosted.org/packages/e2/9b/74b8c868e07d9c937d0dab8c2ce75179ca57df6bdac7db1caad44dd3742e/homeassistant-0.98.5-py3-none-any.whl (5.1MB)

    100% |????????????????????????????????| 5.2MB 32kB/s 

Collecting voluptuous==0.11.7 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/24/3b/fe531688c0d9e057fccc0bc9430c0a3d4b90e0d2f015326e659c2944e328/voluptuous-0.11.7.tar.gz (45kB)

    100% |????????????????????????????????| 51kB 61kB/s 

Collecting bcrypt==3.1.7 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/fa/aa/025a3ab62469b5167bc397837c9ffc486c42a97ef12ceaa6699d8f5a5416/bcrypt-3.1.7.tar.gz (42kB)

    100% |????????????????????????????????| 51kB 85kB/s 

  Installing build dependencies ... done

Collecting certifi>=2019.6.16 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/69/1b/b853c7a9d4f6a6d00749e94eb6f3a041e342a885b87340b79c1ef73e3a78/certifi-2019.6.16-py2.py3-none-any.whl (157kB)

    100% |????????????????????????????????| 163kB 125kB/s 

Collecting importlib-metadata==0.19 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/ad/aa/25fcbded2ab4ed4ff3071d1e000cd4f8f9c65653d2d7157dd105a8e81d42/importlib_metadata-0.19-py2.py3-none-any.whl

Collecting requests==2.22.0 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)

    100% |????????????????????????????????| 61kB 236kB/s 

Collecting astral==1.10.1 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/ff/5d/261f49822b7f77c265197d46cdbaaaaf06f458734e9ac55a140dd75bdf29/astral-1.10.1-py2.py3-none-any.whl

Collecting jinja2>=2.10.1 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)

    100% |????????????????????????????????| 133kB 103kB/s 

Requirement already satisfied: pip>=8.0.3 in ./lib/python3.7/site-packages (from homeassistant) (18.1)

Collecting pytz>=2019.02 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl (508kB)

    100% |????????????????????????????????| 512kB 67kB/s 

Collecting async-timeout==3.0.1 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/e1/1e/5a4441be21b0726c4464f3f23c8b19628372f606755a9d2e46c187e65ec4/async_timeout-3.0.1-py3-none-any.whl

Collecting PyJWT==1.7.1 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/87/8b/6a9f14b5f781697e51259d81657e6048fd31a113229cf346880bb7545565/PyJWT-1.7.1-py2.py3-none-any.whl

Collecting voluptuous-serialize==2.2.0 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/de/00/ad0b68fd0d700ef940997288a0c446319a767e11042a7cc2b72786af1bd5/voluptuous-serialize-2.2.0.tar.gz

Collecting ruamel.yaml==0.15.100 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/9a/ee/55cd64bbff971c181e2d9e1c13aba9a27fd4cd2bee545dbe90c44427c757/ruamel.yaml-0.15.100.tar.gz (318kB)

    100% |????????????????????????????????| 327kB 108kB/s 

Collecting cryptography==2.7 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/c2/95/f43d02315f4ec074219c6e3124a87eba1d2d12196c2767fadfdc07a83884/cryptography-2.7.tar.gz (495kB)

    100% |????????????????????????????????| 501kB 115kB/s 

  Installing build dependencies ... done

Collecting pyyaml==5.1.2 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849582fe/PyYAML-5.1.2.tar.gz (265kB)

    100% |????????????????????????????????| 266kB 113kB/s 

Collecting attrs==19.1.0 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl

Collecting aiohttp==3.5.4 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/0f/58/c8b83f999da3b13e66249ea32f325be923791c0c10aee6cf16002a3effc1/aiohttp-3.5.4.tar.gz (1.1MB)

    100% |????????????????????????????????| 1.1MB 115kB/s 

  Installing build dependencies ... done

Collecting python-slugify==3.0.3 (from homeassistant)

  Downloading https://files.pythonhosted.org/packages/a2/5d/bd30413c00bbed3945558aca07c55944073e1e30abeee1f06515281f9811/python-slugify-3.0.3.tar.gz

Collecting cffi>=1.1 (from bcrypt==3.1.7->homeassistant)

Collecting six>=1.4.1 (from bcrypt==3.1.7->homeassistant)

  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl

Collecting zipp>=0.5 (from importlib-metadata==0.19->homeassistant)

  Downloading https://files.pythonhosted.org/packages/74/3d/1ee25a26411ba0401b43c6376d2316a71addcc72ef8690b101b4ea56d76a/zipp-0.6.0-py2.py3-none-any.whl

Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests==2.22.0->homeassistant)

  Downloading https://files.pythonhosted.org/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl (150kB)

    100% |????????????????????????????????| 153kB 91kB/s 

Collecting chardet<3.1.0,>=3.0.2 (from requests==2.22.0->homeassistant)

  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)

    100% |????????????????????????????????| 143kB 177kB/s 

Collecting idna<2.9,>=2.5 (from requests==2.22.0->homeassistant)

  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)

    100% |????????????????????????????????| 61kB 232kB/s 

Collecting MarkupSafe>=0.23 (from jinja2>=2.10.1->homeassistant)

  Downloading https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz

Collecting asn1crypto>=0.21.0 (from cryptography==2.7->homeassistant)

  Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)

    100% |????????????????????????????????| 102kB 136kB/s 

Collecting multidict<5.0,>=4.0 (from aiohttp==3.5.4->homeassistant)

  Downloading https://files.pythonhosted.org/packages/7f/8f/b3c8c5b062309e854ce5b726fc101195fbaa881d306ffa5c2ba19efa3af2/multidict-4.5.2.tar.gz (105kB)

    100% |????????????????????????????????| 112kB 117kB/s 

Collecting yarl<2.0,>=1.0 (from aiohttp==3.5.4->homeassistant)

  Downloading https://files.pythonhosted.org/packages/fb/84/6d82f6be218c50b547aa29d0315e430cf8a23c52064c92d0a8377d7b7357/yarl-1.3.0.tar.gz (159kB)

    100% |????????????????????????????????| 163kB 118kB/s 

Collecting text-unidecode==1.2 (from python-slugify==3.0.3->homeassistant)

  Downloading https://files.pythonhosted.org/packages/79/42/d717cc2b4520fb09e45b344b1b0b4e81aa672001dd128c180fabc655c341/text_unidecode-1.2-py2.py3-none-any.whl (77kB)

    100% |????????????????????????????????| 81kB 113kB/s 

Collecting pycparser (from cffi>=1.1->bcrypt==3.1.7->homeassistant)

Collecting more-itertools (from zipp>=0.5->importlib-metadata==0.19->homeassistant)

  Downloading https://files.pythonhosted.org/packages/45/dc/3241eef99eb45f1def35cf93af35d1cf9ef4c0991792583b8f33ea41b092/more_itertools-7.2.0-py3-none-any.whl (57kB)

    100% |????????????????????????????????| 61kB 125kB/s 

Building wheels for collected packages: voluptuous, bcrypt, voluptuous-serialize, ruamel.yaml, cryptography, pyyaml, aiohttp, python-slugify, MarkupSafe, multidict, yarl

  Running setup.py bdist_wheel for voluptuous ... done

  Stored in directory: /root/.cache/pip/wheels/e8/e3/d0/a2d476b9cd09b8f5979789e0aaf07119726a3cfb19ee67aa1e

  Running setup.py bdist_wheel for bcrypt ... done

  Stored in directory: /root/.cache/pip/wheels/ae/b1/2c/dc178774d435228aff4679c4837de4d5ee1dd5568a370fc79c

  Running setup.py bdist_wheel for voluptuous-serialize ... done

  Stored in directory: /root/.cache/pip/wheels/3e/9b/29/39588479cf4bcef41d590319a8f96fb5f74e8c43e2baf258a6

  Running setup.py bdist_wheel for ruamel.yaml ... done

  Stored in directory: /root/.cache/pip/wheels/db/41/e2/07450a5b4cf31ce36bd7a18edf3a28e9231b6709cc6e805e1a

  Running setup.py bdist_wheel for cryptography ... done

  Stored in directory: /root/.cache/pip/wheels/d0/02/96/64b1439e5409591b6b0294d1da2f66a4ae4f0548d1bdb225b7

  Running setup.py bdist_wheel for pyyaml ... done

  Stored in directory: /root/.cache/pip/wheels/d9/45/dd/65f0b38450c47cf7e5312883deb97d065e030c5cca0a365030

  Running setup.py bdist_wheel for aiohttp ... done

  Stored in directory: /root/.cache/pip/wheels/f2/8b/d3/ee080552ff95efe1f875d838c77b26127539e6a9e20240937e

  Running setup.py bdist_wheel for python-slugify ... done

  Stored in directory: /root/.cache/pip/wheels/0f/96/ca/85f5b01165975402d1e37f8dd346df00dc39be1d0761bd17bb

  Running setup.py bdist_wheel for MarkupSafe ... done

  Stored in directory: /root/.cache/pip/wheels/f2/aa/04/0edf07a1b8a5f5f1aed7580fffb69ce8972edc16a505916a77

  Running setup.py bdist_wheel for multidict ... done

  Stored in directory: /root/.cache/pip/wheels/2c/da/e3/ca777643441696420fa99eb91a75a3915269f544c42d944492

  Running setup.py bdist_wheel for yarl ... done

  Stored in directory: /root/.cache/pip/wheels/e3/f0/13/d7c1c5cd76ef321fb635ce79232ca973cd0c91fabaaa71e1c7

Successfully built voluptuous bcrypt voluptuous-serialize ruamel.yaml cryptography pyyaml aiohttp python-slugify MarkupSafe multidict yarl

Installing collected packages: voluptuous, pycparser, cffi, six, bcrypt, certifi, more-itertools, zipp, importlib-metadata, urllib3, chardet, idna, requests, pytz, astral, MarkupSafe, jinja2, async-timeout, PyJWT, voluptuous-serialize, ruamel.yaml, asn1crypto, cryptography, pyyaml, attrs, multidict, yarl, aiohttp, text-unidecode, python-slugify, homeassistant

Successfully installed MarkupSafe-1.1.1 PyJWT-1.7.1 aiohttp-3.5.4 asn1crypto-0.24.0 astral-1.10.1 async-timeout-3.0.1 attrs-19.1.0 bcrypt-3.1.7 certifi-2019.6.16 cffi-1.12.3 chardet-3.0.4 cryptography-2.7 homeassistant-0.98.5 idna-2.8 importlib-metadata-0.19 jinja2-2.10.1 more-itertools-7.2.0 multidict-4.5.2 pycparser-2.19 python-slugify-3.0.3 pytz-2019.2 pyyaml-5.1.2 requests-2.22.0 ruamel.yaml-0.15.100 six-1.12.0 text-unidecode-1.2 urllib3-1.25.3 voluptuous-0.11.7 voluptuous-serialize-2.2.0 yarl-1.3.0 zipp-0.6.0


구동 테스트


(homeassistant) root@AOL-Debian:/home/homeassistant# hass

Unable to find configuration. Creating default one in /root/.homeassistant

Config directory: /root/.homeassistant

2019-09-07 21:16:39 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of pyotp==2.2.7

2019-09-07 21:16:46 INFO (SyncWorker_0) [homeassistant.util.package] Attempting install of PyQRCode==1.2.1

2019-09-07 21:16:57 INFO (SyncWorker_3) [homeassistant.loader] Loaded automation from homeassistant.components.automation

2019-09-07 21:16:57 INFO (SyncWorker_6) [homeassistant.loader] Loaded group from homeassistant.components.group

2019-09-07 21:16:57 INFO (SyncWorker_4) [homeassistant.loader] Loaded script from homeassistant.components.script

2019-09-07 21:16:57 INFO (SyncWorker_5) [homeassistant.loader] Loaded default_config from homeassistant

..........................................................

s==0.7.0

2019-09-07 21:17:07 INFO (MainThread) [homeassistant.setup] Setting up http

2019-09-07 21:17:07 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.0 seconds.

2019-09-07 21:17:07 INFO (MainThread) [homeassistant.setup] Setting up system_log

2019-09-07 21:17:07 INFO (MainThread) [homeassistant.setup] Setup of domain system_log took 0.0 seconds.

2019-09-07 21:17:07 INFO (SyncWorker_8) [homeassistant.util.package] Attempting install of sqlalchemy==1.3.7


초기에 설치 및 세팅 과정이 진행됨으로 시간이 5분정도 소요될 수 있습니다.


http://aolipaddr:8123/ 으로 접근하시면 아래와 같이 창이 열립니다.









3. 설정 폴더 지정


설정폴더가 홈 디렉터리 .homeassistant 로 지정되어 있어서 이동하고 실행 명령을 변경합니다.


(homeassistant) root@AOL-Debian:/home/homeassistant/bin# cp -r ~/.homeassistant/ ../


(homeassistant) root@AOL-Debian:/home/homeassistant# mv .homeassistant/ config


(homeassistant) root@AOL-Debian:/home/homeassistant# ls

bin  config  include  lib  pyvenv.cfg  share

(homeassistant) root@AOL-Debian:/home/homeassistant# hass --config /home/homeassistant/config/





4. 자동 실행


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

--2019-09-07 22:42:56--  https://github.com/djjproject/android_over_linux/raw/master/init.d/hass

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/hass [following]

--2019-09-07 22:42:57--  https://raw.githubusercontent.com/djjproject/android_over_linux/master/init.d/hass

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: 2706 (2.6K) [text/plain]

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


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


2019-09-07 22:42:58 (11.6 MB/s) - ‘/etc/init.d/hass’ saved [2706/2706]


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

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



root@AOL-Debian:~# service hass start

Starting service… Done



root@AOL-Debian:~# ps -ef | grep hass

root     26355     1 99 22:43 ?        00:00:04 /home/homeassistant/bin/python3 /home/homeassistant/bin/hass -v --config /home/homeassistant/config --pid-file /var/run/hass/hass.pid --log-file /var/log/homeassistant/home-assistant.log --daemon

root     26417 26046  0 22:43 pts/0    00:00:00 grep hass


감사합니다.

반응형

댓글