projects:internetofthings:homeassistant

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:internetofthings:homeassistant [2017/09/23 08:38] – [hass] scipioprojects:internetofthings:homeassistant [2022/07/08 10:19] (current) daniel
Line 27: Line 27:
  
 <code bash> <code bash>
-apt install python3 python3-venv incron mc +sudo apt install python3 python3-venv incron mc python3-dev libffi-dev libssl-dev 
-python3 -m venv ~/lib +python3 -m venv ~/venv 
-. ~/lib/bin/activate +. ~/venv/bin/activate 
-echo "source ~/lib/bin/activate" >> ~/.bashrc +echo "source ~/venv/bin/activate" >> ~/.bashrc 
-pip install -U pip+pip install -U pip wheel
 pip install homeassistant pip install homeassistant
 </code> </code>
  
 service  service 
-<file txt /etc/systemd/system/home-assistant.service>+<file txt /etc/systemd/system/hass.service>
 [Unit] [Unit]
-Description=Home Assistant+Description=homeassistant
 After=network.target After=network.target
  
Line 44: Line 44:
 Type=simple Type=simple
 User=pi User=pi
-ExecStart=/home/pi/lib/bin/hass -c "/home/pi"+ExecStart=/home/pi/venv/bin/hass -c "/home/pi"
  
 [Install] [Install]
Line 53: Line 53:
 <code bash> <code bash>
 systemctl daemon-reload systemctl daemon-reload
-systemctl enable home-assistant+systemctl enable hass
 </code> </code>
  
Line 62: Line 62:
 git clone https://github.com/scipioni/home-assistant-example.git home-assistant-scipio git clone https://github.com/scipioni/home-assistant-example.git home-assistant-scipio
 </code> </code>
- 
  
  
 ==== z-wave ==== ==== z-wave ====
  
-<file txt /etc/udev/rules.d/local.conf> +Installazione ZWave su raspberry pi
-SUBSYSTEM=="tty", ACTION=="add", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave" +
-</file>+
  
-<code bash> +<code>
-sudo apt install cython3 libudev-dev python3-sphinx python3-setuptools +
-</code>+
  
-<code bash> +opzionale, rimuovere docker se si hanno installazioni vecchie: 
-~/lib/bin/activate +sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli 
-pip install cython +sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  
-</code>+
  
-as normal user (no root) 
-<code bash> 
-. ~/lib/bin/activate 
-cd ~/ 
-git clone --depth 1 https://github.com/OpenZWave/python-openzwave.git 
-cd python-openzwave 
-make build 
-make install 
-</code> 
  
-<code bash> +sudo apt update 
-sudo apt install libmicrohttpd-dev +sudo apt install raspberrypi-kernel raspberrypi-kernel-headers 
-cd ~/ +sudo apt install ca-certificates curl gnupg lsb-release 
-git clone --depth 1 https://github.com/OpenZWave/open-zwave-control-panel.git + 
-cd open-zwave-control-panel/ +sudo mkdir -p /etc/apt/keyrings 
-# patch Makefilesee below + 
-ln -s ~/lib/lib/python3.4/site-packages/libopenzwave-0.3.1-py3.4-linux-armv7l.egg/config +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 
-make+ 
 +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 
 + 
 +sudo apt-get update 
 +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin 
 +(se ci sono errori dpkg, riprovare dopo un reboot) 
 + 
 +sudo systemctl enable docker 
 +sudo systemctl start docker 
 + 
 +ls /dev/serial/by-id/ 
 +copiare il nome della chiavetta usb (es usb-0658_0200-if00) 
 + 
 +mkdir zwave 
 +cd zwave 
 +wget https://raw.githubusercontent.com/zwave-js/zwavejs2mqtt/master/docker/docker-compose.yml 
 +nano docker-compose.yml 
 +incollare il nome della chiavetta al posto di "insert_stick_reference_here" 
 +salvare 
 + 
 +sudo docker compose up -d
 </code> </code>
  
-patch Makefile+Visitare http://ip-raspberry:8091 
 + 
 +Andare sulle settings dal menu laterale 
 + 
 +**Sezione Zwave** 
 + 
 +serial port: lasciare /dev/zwave (la mappatura viene fatta dal docker compose) 
 + 
 +generare tutte e 4 le chiavi, S2 e S0, premendo sui pulsanti con le frecce circolari 
 + 
 +**Sezione general** 
 + 
 +enable log 
 + 
 +scorrere in basso 
 + 
 +abilitare "disable MQTT gateway" 
 + 
 +**Sezione Home Assistant** 
 + 
 +Abilitare WS server 
 + 
 +**Salvare** 
 + 
 +Dall'interfaccia di home assistant installare l'integrazione ZwaveJS 
 + 
 +Inserire come url:
 <code> <code>
---- Makefile.orig 2017-01-05 08:32:39.315501504 +0100 +ws://localhost:3000
-+++ Makefile 2017-01-05 08:33:38.385173320 +0100 +
-@@ -21,7 +21,7 @@ +
- CFLAGS := -c $(DEBUG_CFLAGS) +
- LDFLAGS := $(DEBUG_LDFLAGS) +
-  +
--OPENZWAVE := ../open-zwave/ +
-+OPENZWAVE := ../python-openzwave/openzwave/ +
- LIBMICROHTTPD := -L/usr/local/lib/ -lmicrohttpd +
-  +
- INCLUDES := -I $(OPENZWAVE)/cpp/src -I $(OPENZWAVE)/cpp/src/command_classes/+
-@@ -34,15 +34,15 @@ +
-  +
- # for Linux uncomment out next three lines +
- LIBZWAVE := $(wildcard $(OPENZWAVE)/*.a) +
--#LIBUSB := -ludev +
--#LIBS := $(LIBZWAVE) $(GNUTLS) $(LIBMICROHTTPD) -pthread $(LIBUSB) -lresolv +
-+LIBUSB := -ludev +
-+LIBS := $(LIBZWAVE) $(GNUTLS) $(LIBMICROHTTPD) -pthread $(LIBUSB) -lresolv +
-  +
- # for Mac OS X comment out above 2 lines and uncomment next 5 lines +
- #ARCH := -arch i386 -arch x86_64 +
- #CFLAGS += $(ARCH) +
- #LIBZWAVE := $(wildcard $(OPENZWAVE)/cpp/lib/mac/*.a) +
--LIBUSB := -framework IOKit -framework CoreFoundation +
--LIBS := $(LIBZWAVE) $(GNUTLS) $(LIBMICROHTTPD) -pthread $(LIBUSB) $(ARCH) -lresolv +
-+#LIBUSB := -framework IOKit -framework CoreFoundation +
-+#LIBS := $(LIBZWAVE) $(GNUTLS) $(LIBMICROHTTPD) -pthread $(LIBUSB) $(ARCH) -lresolv +
-  +
- %.o %.cpp +
-  $(CXX) $(CFLAGS) $(INCLUDES) -o $@ $<+
 </code> </code>
 +Ora homeassistant è pronto per cercare nuovi dispositivi zwave, dalla schermata di configurazione dell'integrazione ZwaveJS
  
-=== z-wave panel control === 
  
-<code bash> +==== configurazioni z-wave vecchie ====
-sudo systemctl stop home-assistant +
-cd ~/open-zwave-control-panel +
-./ozwcp -p 8888 +
-</code>+
  
-open http://pi:8888 and initialize /dev/ttyACM0+TKB Home TZ10.XX TZ10.36 termostato [[reference|<Product type="0201" id="0501" name="TZ10.XX Wall Thermostat" config="wenzhou/tz10.xml"/>]]
  
-<code bash+<file txt /etc/udev/rules.d/local.conf
-CTRL+C +SUBSYSTEM=="tty", ACTION=="add", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave" 
-sudo systemctl start home-assistant+</file> 
 + 
 +Add to ~/lib/lib/python3.5/site-packages/python_openzwave/ozw_config/manufacturer_specific.xml 
 +near <Manufacturer id="0118" name="Wenzhou TKB Control System"> 
 +<code> 
 +<Product type="0201" id="0501" name="TZ10.XX Wall Thermostat" config="wenzhou/tz10.xml"/>
 </code> </code>
  
 +wenzhou/tz10.xml 
 +<code> 
 +<?xml version="1.0" encoding="utf-8"?> 
 +<Product xmlns='http://code.google.com/p/open-zwave/'> 
 +   <!-- COMMAND_CLASS_BASIC does not respond to requests --> 
 +  <CommandClass id="32" action="remove" /> 
 +  <!-- This thermostat's setpoint descriptions are 0 based --> 
 +  <CommandClass id="66"> 
 +                <Value type="string" genre="user" instance="1" index="0" label="Operating State" units=" mode" value="Idle" /> 
 +  </CommandClass> 
 +  <CommandClass id="67" base="0" override_precision="2" /> 
 +</Product> 
 +</code>
 ===== reverse proxy ===== ===== reverse proxy =====
  
Line 384: Line 398:
 <code bash> <code bash>
 sudo apt install incron sudo apt install incron
 +</code>
 +
 +<code bash>
 +echo hass > /etc/incron.allow
 </code> </code>
  
Line 390: Line 408:
 /media/usb0/photo/C1_00626E611E80/snap/ IN_CLOSE_WRITE echo "$$ $@ $# $% $&" /media/usb0/photo/C1_00626E611E80/snap/ IN_CLOSE_WRITE echo "$$ $@ $# $% $&"
 </code> </code>
 +
 +===== grafana =====
 +
 +<graphviz dot>
 +digraph G {
 +
 +graph [rankdir = "LR" splines="true" remincross="true"];
 +node [fontsize = "10" shape = "box" style="filled" color=black penwidth=1 fillcolor="/blues6/1:/blues6/4" ranksep=1.5];
 +edge [weight=1.0  arrowsize=0.5  color="#999999"  fontsize = "10" penwidth=1];
 +
 +hass -> influxdb -> grafana -> browser
 +
 +
 +}  
 +
 +</graphviz>
 +
 +
 +
 +Add influxdb datasource{{ :projects:internetofthings:datasource-influxdb.png?direct |}}
 +
 +
 +===== alexa =====
 +
 +  * https://home-assistant.it/integrare-alexa-in-home-assistant-senza-usare-il-cloud-e-a-costo-zero/
 +
 +Modificare https://github.com/mike-grant/haaska per il multiclient.
 +
 +haaska.py gira come servizio sui lambda server amazon. Anziché leggere la configurazione (ad esempio bearer_token) da file,
 +prevedere una chiamata ad un web service esterno (ad esempio https://ha.csagalileo.org/alexa?client=id_client_alexa) da cui recuprare i dati. Ovviamente va mappato id_client_alexa con albertis
 +
 +Sniffare i metodi:
 +  * def get(self, endpoint):
 +  * def post(self, endpoint, data, wait=False):
  • projects/internetofthings/homeassistant.1506148713.txt.gz
  • Last modified: 2017/09/23 08:38
  • by scipio