DS218 Home Assistant 설치

Homebridge의 초기 구동속도 문제(도커버전은 못써봐서 알수없지만…)로 답답해 하던중
Home Assistant쪽이 엄청난 능력자들이 많이 모여 업데이트가 빠른데다
Homekit과의 연결도 된다 하여 시도를 해 보았음

!!주의!! 삽질 과정이 포함되어 있음!!

chroot 진입

apt-get update
apt-get upgrade -y
apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev autoconf

적당한 위치에

mkdir homeassistant
python3 -m venv homeassistant
cd homeassistant
source bin/activate
(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $

python3 -m pip install wheel

pip3 install homeassistant

에러

Downloading/unpacking homeassistant
Downloading homeassistant-0.110.4-py3-none-any.whl (8.2MB): 8.2MB downloaded
Downloading/unpacking requests==2.23.0 (from homeassistant)
Downloading requests-2.23.0-py2.py3-none-any.whl (58kB): 58kB downloaded
Downloading/unpacking aiohttp==3.6.1 (from homeassistant)
Downloading aiohttp-3.6.1.tar.gz (1.1MB): 1.1MB downloaded
Running setup.py (path:/tmp/pip-build-02mwnxeq/aiohttp/setup.py) egg_info for package aiohttp
Traceback (most recent call last):
File "", line 17, in 
File "/tmp/pip-build-02mwnxeq/aiohttp/setup.py", line 13, in 
raise RuntimeError("aiohttp 3.x requires Python 3.5.3+")
RuntimeError: aiohttp 3.x requires Python 3.5.3+
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in 
File "/tmp/pip-build-02mwnxeq/aiohttp/setup.py", line 13, in 
raise RuntimeError("aiohttp 3.x requires Python 3.5.3+")
RuntimeError: aiohttp 3.x requires Python 3.5.3+
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in 
File "/tmp/pip-build-02mwnxeq/aiohttp/setup.py", line 13, in 
raise RuntimeError("aiohttp 3.x requires Python 3.5.3+")
RuntimeError: aiohttp 3.x requires Python 3.5.3+
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-02mwnxeq/aiohttp
Storing debug log for failure in /root/.pip/pip.log

그래서 3.5.3 설치

wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz

tar -xvf Python-3.5.3.tgz

폴더 들어가서

./configure –prefix=$HOME

make && make install

마지막에 에러

ImportError: No module named ‘_ctypes’

Makefile:1046: recipe for target ‘install’ failed

make: *** [install] Error 1

추가로 설치(https://stackoverflow.com/questions/27022373/python3-importerror-no-module-named-ctypes-when-using-value-from-module-mul)

apt-get install zlib1g-dev libsqlite3-dev tk-dev

apt-get install libncursesw5-dev libgdbm-dev libc6-dev

그래서 python3 모두 삭제

apt-get remove python3

설치했던 폴더도 삭제 후 재설치

https://dlehdgml0480.tistory.com/8

apt-get install build-essential checkinstall
apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \\
    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

cd /opt (나는 다른 경로)
 $ sudo wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
 $ sudo tar xzf Python-3.8.1.tgz

cd Python-3.8.1
$ sudo ./configure --enable-optimizations
$ sudo make altinstall
python3.8 -V

Python-3.8.1

이 다음 venv 만들기

python3.8 -m venv homeassistant source bin/activate

그리고 진행하면

python3 -m pip install wheel

(homeassistant) root@DS218:~/python/Python-3.8.1/homeassistant# python3.8 -m pip install wheel
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting wheel
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
  Could not fetch URL  There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/wheel/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  ERROR: Could not find a version that satisfies the requirement wheel (from versions: none)
ERROR: No matching distribution found for wheel
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL  There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
(homeassistant) root@DS218:~/python/Python-3.8.1/homeassistant#

이런 경우 https://m.blog.naver.com/PostView.nhn?blogId=dkzksp0812&logNo=221257119485&proxyReferer=https:%2F%2Fwww.google.com%2F 참고하면 설정 변경이 있으나

와 같은 에러를 보이면서 실행이 안되는 경우 yum install openssl yum install openssl-devel 파이썬 설치파일(tgz) 압축푼 경로로 이동하여 vim Modules/Setup.dist 아래와 같이 주석을 풀어준다. _socket socketmodule.c

Socket module helper for SSL support; you must comment out the other

socket line above, and possibly edit the SSL variable:

SSL=/usr/local/openssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto 그 다음 다음과 같이 하면 pip install 이 올바로 실행된다. ./configure make make install

그래도 안됨

https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget 
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

이거 따라한후 wheel 설치 완료

pip install –upgrade pip 이것도 완료

python3 -m pip install wheel

pip3 install homeassistant

hass //오래걸림

결론은… Python 3.6까지가 최선이고 그 이후버전은 OpenSSL 버전 이슈로 pip 동작을 안함 3.7. 3.8 모두 안되며 OpenSSL은 chroot 버전이 8(jessie)이다보니 더이상 업데이트 불가능 Python 3.6이라 Home Assistant 또한 최신버전 업데이트 불가

DS218 사용자라면(도커 없는….ㅠㅠ)
0.103.6까지만 사용 가능합니다