32aebead633e39989eb2d8de20081d61637f3bea
Network/Pixie.md
| ... | ... | @@ -3,25 +3,25 @@ title: Pixie |
| 3 | 3 | --- |
| 4 | 4 | |
| 5 | 5 | Implements |
| 6 | -: [Automation Hub][1] |
|
| 6 | +: [Automation Hub][1] |
|
| 7 | 7 | |
| 8 | 8 | Hostname |
| 9 | -: pixie0 |
|
| 9 | +: pixie0 |
|
| 10 | 10 | |
| 11 | 11 | Make |
| 12 | -: Raspberry Pi 2 |
|
| 12 | +: Raspberry Pi 2 |
|
| 13 | 13 | |
| 14 | 14 | Model |
| 15 | -: B+ |
|
| 15 | +: B+ |
|
| 16 | 16 | |
| 17 | 17 | Software |
| 18 | -: Debian Jessie, [Home Assistant][2] |
|
| 18 | +: Debian Jessie, [Home Assistant][2] |
|
| 19 | 19 | |
| 20 | 20 | Purchased |
| 21 | -: 2015-05-14 £42 (kit) from CPC |
|
| 21 | +: 2015-05-14 £42 (kit) from CPC |
|
| 22 | 22 | |
| 23 | 23 | Delivered |
| 24 | -: 2015-05-15 |
|
| 24 | +: 2015-05-15 |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | |
| ... | ... | @@ -29,24 +29,24 @@ Delivered |
| 29 | 29 | |
| 30 | 30 | # Static ttyUSB for zwave and rfxcom |
| 31 | 31 | |
| 32 | -Aeonlabs Z-Stick S2 is `/dev/ttyUSB21`, Rfxcom is `/dev/ttyUSB22` |
|
| 32 | +Aeonlabs Z-Stick S2 is `/dev/ttyUSB21`, Rfxcom is `/dev/ttyUSB22` |
|
| 33 | 33 | |
| 34 | -`/etc/udev/rules.d/99-usb-serial.rules`: |
|
| 34 | +`/etc/udev/rules.d/99-usb-serial.rules`: |
|
| 35 | 35 | |
| 36 | 36 | SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001", SYMLINK+="ttyUSB21" |
| 37 | 37 | SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A1XHAXCI", SYMLINK+="ttyUSB22" |
| 38 | - |
|
| 38 | + |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | # RTC |
| 43 | 43 | |
| 44 | -<https://raw.githubusercontent.com/piface/PiFace-Real-Time-Clock/master/install-piface-real-time-clock.sh> |
|
| 44 | +<https://raw.githubusercontent.com/piface/PiFace-Real-Time-Clock/master/install-piface-real-time-clock.sh> |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | |
| 48 | -* Enable I2C |
|
| 49 | -* `apt-get install i2c-tools` |
|
| 48 | +* Enable I2C |
|
| 49 | +* `apt-get install i2c-tools` |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | |
| ... | ... | @@ -56,20 +56,20 @@ Aeonlabs Z-Stick S2 is `/dev/ttyUSB21`, Rfxcom is `/dev/ttyUSB22` |
| 56 | 56 | CREATE DATABASE hass; |
| 57 | 57 | GRANT ALL PRIVILEGES ON hass.* TO 'hass'@'%' WITH GRANT OPTION; |
| 58 | 58 | FLUSH PRIVILEGES; |
| 59 | - |
|
| 59 | + |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | ## Fix Host Blocked error |
| 64 | 64 | |
| 65 | -<https://dev.mysql.com/doc/refman/5.7/en/blocked-host.html> |
|
| 65 | +<https://dev.mysql.com/doc/refman/5.7/en/blocked-host.html> |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | mysql> SET GLOBAL max\_connect\_errors=10000; |
| 71 | 71 | mysql> flush hosts; |
| 72 | - |
|
| 72 | + |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | |
| ... | ... | @@ -87,31 +87,39 @@ Aeonlabs Z-Stick S2 is `/dev/ttyUSB21`, Rfxcom is `/dev/ttyUSB22` |
| 87 | 87 | cd .. |
| 88 | 88 | make build |
| 89 | 89 | make install |
| 90 | - |
|
| 90 | + |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | ## Upgrading via python-openzwave |
| 95 | 95 | |
| 96 | -Using openzwave dev branch from github: |
|
| 96 | +Using openzwave dev branch from github: |
|
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | . /srv/hass/hass_venv/bin/activate |
| 100 | 100 | pip install python_openzwave --install-option="--flavor=dev" --no-deps --ignore-installed --no-cache-dir |
| 101 | - |
|
| 101 | + |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | # [LetsEncrypt][29] |
| 106 | 106 | |
| 107 | -Certbot is now installed as a package. |
|
| 107 | +Certbot is now installed as a package. |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | ## Renewing |
| 112 | 112 | |
| 113 | -1. Leave nginx running |
|
| 114 | -2. Allow iptables 80 tcp input |
|
| 113 | +### Quick start |
|
| 114 | + |
|
| 115 | + rake pixie-open |
|
| 116 | + rake pixie-renew |
|
| 117 | + rake pixie-close |
|
| 118 | + |
|
| 119 | +### Process |
|
| 120 | + |
|
| 121 | +1. Leave nginx running |
|
| 122 | +2. Allow iptables 80 tcp input |
|
| 115 | 123 | 3. Enable 80 port forward on router to pixie3 |
| 116 | 124 | |
| 117 | 125 | ``` |
| ... | ... | @@ -122,9 +130,10 @@ Certbot is now installed as a package. |
| 122 | 130 | reload_config |
| 123 | 131 | ``` |
| 124 | 132 | |
| 125 | -4. Run `sudo certbot renew --nginx` |
|
| 126 | -5. Check cert `openssl x509 -text -in /etc/letsencrypt/live/ha.home.whalebarn.com/cert.pem` |
|
| 133 | +4. Run `sudo certbot renew --nginx` |
|
| 134 | +5. Check cert `openssl x509 -text -in /etc/letsencrypt/live/ha.home.whalebarn.com/cert.pem` |
|
| 127 | 135 | 6. Disallow iptables 80 and disable 80 port forward |
| 136 | + |
|
| 128 | 137 | ``` |
| 129 | 138 | uci show firewall.@redirect[1].name # confirm the key |
| 130 | 139 | uci set firewall.@redirect[1].enabled=0 |
| ... | ... | @@ -139,12 +148,12 @@ Certbot is now installed as a package. |
| 139 | 148 | |
| 140 | 149 | ## Renewing from Git (Obsolete) |
| 141 | 150 | |
| 142 | -As above except: |
|
| 151 | +As above except: |
|
| 143 | 152 | |
| 144 | 153 | |
| 145 | 154 | |
| 146 | -1. Run `sudo ~pi/src/letsencrypt/certbot-auto renew --nginx` |
|
| 147 | -2. Check cert `openssl x509 -text -in /etc/letsencrypt/live/ha.home.whalebarn.com/cert.pem` |
|
| 155 | +1. Run `sudo ~pi/src/letsencrypt/certbot-auto renew --nginx` |
|
| 156 | +2. Check cert `openssl x509 -text -in /etc/letsencrypt/live/ha.home.whalebarn.com/cert.pem` |
|
| 148 | 157 | |
| 149 | 158 | |
| 150 | 159 | |
| ... | ... | @@ -152,20 +161,20 @@ As above except: |
| 152 | 161 | |
| 153 | 162 | ## Missing `/var/log/nginx` |
| 154 | 163 | |
| 155 | -Fails to start after boot because `/var/log/nginx` hasn't been created |
|
| 164 | +Fails to start after boot because `/var/log/nginx` hasn't been created |
|
| 156 | 165 | |
| 157 | -Add to |
|
| 166 | +Add to |
|
| 158 | 167 | |
| 159 | -`/etc/systemd/system/multi-user.target.wants/nginx.service` |
|
| 168 | +`/etc/systemd/system/multi-user.target.wants/nginx.service` |
|
| 160 | 169 | ExecStartPre=/bin/bash -c 'mkdir -p /var/log/nginx; /usr/sbin/nginx -t -q -g "daemon on; master_process on;"' |
| 161 | - to create the log dir and run nginx config test |
|
| 170 | + to create the log dir and run nginx config test |
|
| 162 | 171 | |
| 163 | -New solution. Copy and customize `nginx.service`: |
|
| 172 | +New solution. Copy and customize `nginx.service`: |
|
| 164 | 173 | |
| 165 | 174 | [Unit] |
| 166 | 175 | Description=A high performance web server and a reverse proxy server |
| 167 | 176 | After=network.target |
| 168 | - |
|
| 177 | + |
|
| 169 | 178 | [Service] |
| 170 | 179 | Type=forking |
| 171 | 180 | PIDFile=/run/nginx.pid |
| ... | ... | @@ -177,38 +186,38 @@ New solution. Copy and customize `nginx.service`: |
| 177 | 186 | ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid |
| 178 | 187 | TimeoutStopSec=5 |
| 179 | 188 | KillMode=mixed |
| 180 | - |
|
| 189 | + |
|
| 181 | 190 | [Install] |
| 182 | 191 | WantedBy=multi-user.target |
| 183 | - |
|
| 192 | + |
|
| 184 | 193 | |
| 185 | 194 | |
| 186 | 195 | |
| 187 | 196 | ## Can't connect to Upstream |
| 188 | 197 | |
| 189 | -Make nginx depend on home-assistant startup. |
|
| 198 | +Make nginx depend on home-assistant startup. |
|
| 190 | 199 | |
| 191 | 200 | |
| 192 | 201 | |
| 193 | 202 | |
| 194 | 203 | sudo mkdir -p /etc/systemd/system/nginx.service.d |
| 195 | 204 | sudo vim /etc/systemd/system/nginx.service.d/override.conf |
| 196 | - |
|
| 197 | 205 | |
| 198 | -Create `/etc/systemd/system/nginx.service.d/override.conf`: |
|
| 206 | + |
|
| 207 | +Create `/etc/systemd/system/nginx.service.d/override.conf`: |
|
| 199 | 208 | |
| 200 | 209 | [Unit] |
| 201 | 210 | Wants=home-assistant.service |
| 202 | 211 | After=home-assistant.service |
| 203 | - |
|
| 212 | + |
|
| 204 | 213 | |
| 205 | 214 | |
| 206 | 215 | |
| 207 | 216 | # Python with PyEnv |
| 208 | 217 | |
| 209 | -Manage python version upgrades with pyenv. |
|
| 218 | +Manage python version upgrades with pyenv. |
|
| 210 | 219 | |
| 211 | -<http://www.knight-of-pi.org/pyenv-for-python-version-management-on-raspbian-stretch/> |
|
| 220 | +<http://www.knight-of-pi.org/pyenv-for-python-version-management-on-raspbian-stretch/> |
|
| 212 | 221 | |
| 213 | 222 | |
| 214 | 223 | |
| ... | ... | @@ -219,9 +228,9 @@ Manage python version upgrades with pyenv. |
| 219 | 228 | echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc |
| 220 | 229 | echo 'eval "$(pyenv init -)"' >> ~/.bashrc |
| 221 | 230 | . ~/.bashrc |
| 222 | - |
|
| 223 | 231 | |
| 224 | -System-wide install of 3.8.5: |
|
| 232 | + |
|
| 233 | +System-wide install of 3.8.5: |
|
| 225 | 234 | |
| 226 | 235 | |
| 227 | 236 | |
| ... | ... | @@ -229,19 +238,19 @@ System-wide install of 3.8.5: |
| 229 | 238 | mkdir tmp |
| 230 | 239 | sudo su # otherwise TMPDIR doesn't affect the pyenv subshell... |
| 231 | 240 | TMPDIR=`pwd`/tmp .pyenv/plugins/python-build/bin/python-build 3.8.5 /usr/local/python-3.8.5/ |
| 232 | - |
|
| 241 | + |
|
| 233 | 242 | |
| 234 | 243 | |
| 235 | 244 | |
| 236 | 245 | # Zwave2Mqtt |
| 237 | 246 | |
| 238 | -Chose this over ozwdaemon (which requires a custom build of QT 5.12!) |
|
| 247 | +Chose this over ozwdaemon (which requires a custom build of QT 5.12!) |
|
| 239 | 248 | |
| 240 | 249 | |
| 241 | 250 | |
| 242 | 251 | ## Build openzwave |
| 243 | 252 | |
| 244 | -Version 1.6+. User `pi` |
|
| 253 | +Version 1.6+. User `pi` |
|
| 245 | 254 | |
| 246 | 255 | |
| 247 | 256 | mkdir -p src/open-zwave |
| ... | ... | @@ -250,13 +259,13 @@ Version 1.6+. User `pi` |
| 250 | 259 | git checkout -b live master |
| 251 | 260 | make |
| 252 | 261 | sudo make install |
| 253 | - |
|
| 262 | + |
|
| 254 | 263 | |
| 255 | 264 | |
| 256 | 265 | |
| 257 | 266 | ## Install node and npm |
| 258 | 267 | |
| 259 | -User `hass` |
|
| 268 | +User `hass` |
|
| 260 | 269 | |
| 261 | 270 | |
| 262 | 271 | sudo apt-get install npm |
| ... | ... | @@ -266,13 +275,13 @@ User `hass` |
| 266 | 275 | sudo npm install -g n |
| 267 | 276 | sudo n stable # upgraded to node v12.18.4 |
| 268 | 277 | |
| 269 | - |
|
| 278 | + |
|
| 270 | 279 | |
| 271 | 280 | |
| 272 | 281 | |
| 273 | 282 | ## Build zwave2mqtt |
| 274 | 283 | |
| 275 | -User `hass` |
|
| 284 | +User `hass` |
|
| 276 | 285 | |
| 277 | 286 | |
| 278 | 287 | mkdir -p src/zwave2mqtt |
| ... | ... | @@ -280,13 +289,13 @@ User `hass` |
| 280 | 289 | git clone https://github.com/OpenZWave/Zwave2Mqtt |
| 281 | 290 | npm install # takes a long time because it's freaking 571MB of stuff |
| 282 | 291 | npm run build |
| 283 | - |
|
| 292 | + |
|
| 284 | 293 | |
| 285 | 294 | |
| 286 | 295 | |
| 287 | 296 | ## Other issues |
| 288 | 297 | |
| 289 | -* After building with node v8 then upgrading to node v12 had to reinstall fibers `npm install fibers` before doing `npm run build` |
|
| 298 | +* After building with node v8 then upgrading to node v12 had to reinstall fibers `npm install fibers` before doing `npm run build` |
|
| 290 | 299 | * More version issues so `npm rebuild` |
| 291 | 300 | |
| 292 | 301 | [1]: AutomationHub |