Implements : Automation Hub
Hostname : pixie0
Make : Raspberry Pi 2
Model : B+
Software : Debian Jessie, Home Assistant
Purchased : 2015-05-14 £42 (kit) from CPC
Delivered : 2015-05-15
Static ttyUSB for zwave and rfxcom
Aeonlabs Z-Stick S2 is /dev/ttyUSB21
, Rfxcom is /dev/ttyUSB22
/etc/udev/rules.d/99-usb-serial.rules
:
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001", SYMLINK+="ttyUSB21"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A1XHAXCI", SYMLINK+="ttyUSB22"
RTC
- Enable I2C
-
apt-get install i2c-tools
Home-Assistant mysql Database
CREATE DATABASE hass;
GRANT ALL PRIVILEGES ON hass.* TO 'hass'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Fix Host Blocked error
https://dev.mysql.com/doc/refman/5.7/en/blocked-host.html
mysql> SET GLOBAL max\_connect\_errors=10000;
mysql> flush hosts;
OpenZWave
Upgrading
sudo su hass
. /srv/hass/hass_venv/bin/activate
cd /srv/hass/src/python-openzwave
git pull origin
cd openzwave
git pull origin
cd ..
make build
make install
Upgrading via python-openzwave
Using openzwave dev branch from github:
. /srv/hass/hass_venv/bin/activate
pip install python_openzwave --install-option="--flavor=dev" --no-deps --ignore-installed --no-cache-dir
LetsEncrypt
Certbot is now installed as a package.
Renewing
- Leave nginx running
- Allow iptables 80 tcp input
-
Enable 80 port forward on router to pixie3
uci show firewall.@redirect[4].name # confirm the key uci set firewall.@redirect[4].enabled=1 uci changes uci commit firewall reload_config
Run
sudo certbot renew --nginx
- Check cert
openssl x509 -text -in /etc/letsencrypt/live/ha.home.whalebarn.com/cert.pem
-
Disallow iptables 80 and disable 80 port forward
uci show firewall.@redirect[4].name # confirm the key uci set firewall.@redirect[4].enabled=0 uci changes uci commit firewall reload_config
Restart nginx
Renewing from Git (Obsolete)
As above except:
- Run
sudo ~pi/src/letsencrypt/certbot-auto renew --nginx
- Check cert
openssl x509 -text -in /etc/letsencrypt/live/ha.home.whalebarn.com/cert.pem
Fix nginx startup
Missing /var/log/nginx
Fails to start after boot because /var/log/nginx
hasn't been created
Add to
/etc/systemd/system/multi-user.target.wants/nginx.service
ExecStartPre=/bin/bash -c 'mkdir -p /var/log/nginx; /usr/sbin/nginx -t -q -g "daemon on; master_process on;"'
to create the log dir and run nginx config test
New solution. Copy and customize nginx.service
:
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
PermissionsStartOnly=true # do the mkdir as root
ExecStartPre=-/bin/mkdir -p /var/log/nginx # create log dir, tolerate failure
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
Can't connect to Upstream
Make nginx depend on home-assistant startup.
sudo mkdir -p /etc/systemd/system/nginx.service.d
sudo vim /etc/systemd/system/nginx.service.d/override.conf
Create /etc/systemd/system/nginx.service.d/override.conf
:
[Unit]
Wants=home-assistant.service
After=home-assistant.service
Python with PyEnv
Manage python version upgrades with pyenv.
http://www.knight-of-pi.org/pyenv-for-python-version-management-on-raspbian-stretch/
sudo apt-get install bzip2 libbz2-dev libreadline6 libreadline6-dev libffi-dev libssl1.0-dev sqlite3 libsqlite3-dev -y
git clone git://github.com/yyuu/pyenv.git .pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
. ~/.bashrc
System-wide install of 3.8.5:
mkdir tmp
sudo su # otherwise TMPDIR doesn't affect the pyenv subshell...
TMPDIR=`pwd`/tmp .pyenv/plugins/python-build/bin/python-build 3.8.5 /usr/local/python-3.8.5/
Zwave2Mqtt
Chose this over ozwdaemon (which requires a custom build of QT 5.12!)
Build openzwave
Version 1.6+. User pi
mkdir -p src/open-zwave
git clone https://github.com/OpenZWave/open-zwave.git
# tag v1.6 failed with gcc 6.3
git checkout -b live master
make
sudo make install
Install node and npm
User hass
sudo apt-get install npm
# npm config set registry https://registry.npmjs.org # unnecessary?
# https://github.com/nebrius/raspi-serial/issues/8
sudo npm install -g npm # upgraded to 6.14.8, old /usr/bin/npm still 1.4.21
sudo npm install -g n
sudo n stable # upgraded to node v12.18.4
Build zwave2mqtt
User hass
mkdir -p src/zwave2mqtt
# though actually I just pushed v4.0.3 and "live" from canard
git clone https://github.com/OpenZWave/Zwave2Mqtt
npm install # takes a long time because it's freaking 571MB of stuff
npm run build
Other issues
- After building with node v8 then upgrading to node v12 had to reinstall fibers
npm install fibers
before doingnpm run build
- More version issues so
npm rebuild