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/08/30 13:34] scipioprojects:internetofthings:homeassistant [2022/07/08 10:19] (current) daniel
Line 27: Line 27:
  
 <code bash> <code bash>
-apt install python3 python3-venv +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 50: Line 50:
 </file> </file>
  
-==== z-wave ==== +enable service
- +
-<file txt /etc/udev/rules.d/local.conf> +
-SUBSYSTEM=="tty", ACTION=="add", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave" +
-</file> +
 <code bash> <code bash>
-sudo apt install cython3 libudev-dev python3-sphinx python3-setuptools+systemctl daemon-reload 
 +systemctl enable hass
 </code> </code>
  
-<code bash> 
-. ~/lib/bin/activate 
-pip install cython 
-</code> 
  
-as normal user (no root)+configuration example
 <code bash> <code bash>
-. ~/lib/bin/activate +sudo apt install git mc 
-cd ~/ +git clone https://github.com/scipioni/home-assistant-example.git home-assistant-scipio
-git clone --depth 1 https://github.com/OpenZWave/python-openzwave.git +
-cd python-openzwave +
-make build +
-make install+
 </code> </code>
  
-<code bash> 
-sudo apt install libmicrohttpd-dev 
-cd ~/ 
-git clone --depth 1 https://github.com/OpenZWave/open-zwave-control-panel.git 
-cd open-zwave-control-panel/ 
-# patch Makefile: see below 
-ln -s ~/lib/lib/python3.4/site-packages/libopenzwave-0.3.1-py3.4-linux-armv7l.egg/config 
-make 
-</code> 
  
-patch Makefile+==== z-wave ==== 
 + 
 +Installazione ZWave su raspberry pi 
 <code> <code>
---- Makefile.orig 2017-01-05 08:32:39.315501504 +0100 
-+++ 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> 
  
-=== z-wave panel control ===+opzionale, rimuovere docker se si hanno installazioni vecchie: 
 +sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli 
 +sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  
  
-<code bash+ 
-sudo systemctl stop home-assistant +sudo apt update 
-cd ~/open-zwave-control-panel +sudo apt install raspberrypi-kernel raspberrypi-kernel-headers 
-./ozwcp -p 8888+sudo apt install ca-certificates curl gnupg lsb-release 
 + 
 +sudo mkdir -p /etc/apt/keyrings 
 + 
 +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 
 + 
 +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>
  
-open http://pi:8888 and initialize /dev/ttyACM0+Visitare http://ip-raspberry:8091
  
-<code bash> +Andare sulle settings dal menu laterale 
-CTRL+C + 
-sudo systemctl start home-assistant+**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> 
 +ws://localhost:3000
 </code> </code>
 +Ora homeassistant è pronto per cercare nuovi dispositivi zwave, dalla schermata di configurazione dell'integrazione ZwaveJS
  
  
 +==== configurazioni z-wave vecchie ====
 +
 +TKB Home TZ10.XX / TZ10.36 termostato [[reference|<Product type="0201" id="0501" name="TZ10.XX Wall Thermostat" config="wenzhou/tz10.xml"/>]]
 +
 +<file txt /etc/udev/rules.d/local.conf>
 +SUBSYSTEM=="tty", ACTION=="add", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave"
 +</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>
 +
 +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 369: 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 375: 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.1504092881.txt.gz
  • Last modified: 2017/08/30 13:34
  • by scipio