DS218로 Home Assistant 포기

작년까지 Home Bridge -> Home Assistant(DS218) 이전하여 사용을 해왔으나
큰 문제점이 있었다

1. chroot의 호환성이 완벽하지 못한점 – 억지로 설치했으니…
2. 1의 문제로 인해 HA업그레이드 불가 – 정확히는 파이썬 버전 업글 불가
3. 2를 해결하고자 과도한 시간 소요…

한번에 성공하는건 정말 운이 좋아야 하는것이고
시행착오를 겪는건 당연한 과정이지만…

왜 DS218+를 사지 않아서 도커를 구동시키지 못한것이 너무나 큰 후회가 되었다 ㅋㅋㅋ

HA가 제일 좋은 대안은 맞았으나
DS218위에 돌리려는건 무리한 짓이였고

결국 집에 굴러다니던 라즈베리파이에 HA이미지를 바로 올려서 사용하기로 했다

전용 이미지에 HACS, Supervisor 모두 사용 가능하다
앞서 내가 한 삽질의 과정들은 전혀 없다… 허무할 정도로 전혀…

혹시나 같은 방법으로 고민하시는분께...
그냥 라즈베리 돌리시는걸 진심으로 추천드립니다 ㅎㅎㅎ

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까지만 사용 가능합니다

DS218 Homebridge 세팅 2 (Homebridge 설치)

apt-get update

업데이트 안되어(오류)
wget -O – http://ltb-project.org/wiki/lib/RPM-GPG-KEY-LTB-project | sudo apt-key add –
이후 실행
https://github.com/ltb-project/self-service-password/issues/120

apt-get update
apt-get upgrade

[homebridge 설치를 위한 가이드 따라하기]
https://medium.com/@gregwym/setup-homebridge-on-synology-nas-without-docker-f42edd174d0e

apt-get install build-essential
wget http://nodejs.org/dist/latest-v8.x/node-v8.16.2.tar.gz
tar -zxvf node~~~
cd node~~
./configure

실행 안됨(파이썬 없다 함)

cd..
apt-get install python
./configure
make -j4(쿼드코어니까)(2시간 정도 걸림) 
apt-get install libavahi-compat-libdnssd-dev git

locale 경고 거슬림

apt install locales -y
dpkg-reconfigure locales
dpkg-reconfigure tzdata
//할수없음
mount -t proc proc proc/
/etc/init.d/dbus start
apt install less vim curl rsync screen openssh-server bash-completion -y
apt-get install build-essential -y
apt-get install nano -y
apt-get install cmake libboost-dev libboost-thread-dev libboost-system-dev libsqlite3-dev subversion curl libcurl4-openssl-dev libusb-dev zlib1g-dev libudev-dev -y
apt-get install apt-utils -y
apt-get install python -y
apt-get install git -y
apt-get install libavahi-compat-libdnssd-dev -y
cd ~
git clone https://github.com/joyent/node.git
cd node

이까지 하고 설치 가이드 따라 진행(드디어 npm 가능)

npm install -g --unsafe-perm homebridge

DS218 Homebridge 세팅 1 (chroot 설치)

DS218은 Docker가 지원되지 않아
기존 사용하던 Raspberry를 대체하여 Homebridge를 구동하기 위해
chroot를 이용.

[패키지 소스 추가]
Step 1
Log into your NAS as administrator and go to Main Menu → Package Center → Settings and set Trust Level to Synology Inc. and trusted publishers.

Step 2
In the Package Sources tab, click Add, type SynoCommunity as Name and http://packages.synocommunity.com/ as Location and then press OK to validate.

Step 3
Go back to the Package Center and enjoy SynoCommunity's packages in the Community tab.

하지만 debian chroot 없음(2019년 10월 기준)

git 설치해봤으나 실행 안됨, 삭제 안됨
https://github.com/OKit-Scripts-Projects/DSM.Customizations/blob/master/App.Debian-Chroot.md#Instructions

바로 받아 수동설치 할 수 있는 사이트가 있으나 DS218은 없음
https://github.com/SynoCommunity/spksrc/wiki/Architecture-per-Synology-model

CPU에 따라 분류가 되며

rtd1296 (armv8)
x18 Series
DS418j - synology_rtd1293_ds418j
DS418 - synology_rtd1296_ds418
DS218 - synology_rtd1296_ds218
DS218play - synology_rtd1296_ds218play
DS118 - synology_rtd1296_ds118

418로 설치 진행
python 설치가 필요하다 함

커뮤니티의 safihre python 설치 후 패키지 수동설치 완료

[chroot start]
sudo -i
cd /var/packages/debian-chroot/scripts/
./start-stop-status chroot