mit Tasmota und ESPHome
Damit wir den ESP mit ESPHome flashen können, müssen wir zuächst das Minimal-Image von Tasmota flashen.
ESP-01 flashen
Mit tasmonizer und den ESP-Flasher (DIP-Schalter auf PROG) ein Backup erstellen und das Tasmota Image (releases) flashen. In diesem Fall ist der Speicher 1MB und die tasmota.bin sollte darauf passen. Die WiFi und die MQTT-Settings ebenfalls mit tasmonizer hochladen.
ESP-01 aus dem ESP-Flasher entfernen und auf das Board zurück stecken.
Konfiguration Tasmota
Rule1 on System#Boot do Backlog Baudrate 9600; SerialSend5 0 endon on Power1#State=1 do SerialSend5 A00101A2 endon on Power1#State=0 do SerialSend5 A00100A1 endon
Links:
Configuration File
esphome:
name: esp8266-relay-lc-tech
friendly_name: ESP8266 RELAY LC Tech esp8266:
board: esp01_1m
# Enable Home Assistant API
api:
...
# Disable uart/serial logging
logger:
baud_rate: 0
uart:
tx_pin: 1
rx_pin: 3
baud_rate: 9600
switch:
- platform: template
name: "Relais 1"
optimistic: true
turn_on_action:
- uart.write: [0xA0, 0x01, 0x01, 0xA2]
turn_off_action:
- uart.write: [0xA0, 0x01, 0x00, 0xA1]
mit ESPHome
Hinweis: siehe Artikel ESP8266 RELAY LC Technology für evtl. besseren Workaround via Tasmota Rules.
Links:
Das Relais via Serieller Schnittstelle ansprechen (Auszug aus tasmota)
SerialLog 1
Baudrate 115200
SerialSend5 A00101A2
SerialSend5 A00100A1
Für Relais 2:
SerialSend5 A00201A3
SerialSend5 A00200A2
Für Relais 3:
SerialSend5 A00301A4
SerialSend5 A00300A3
Für Relais 4:
SerialSend5 A00401A5
SerialSend5 A00400A4
ESPHome ventilsteuerung.yaml
esphome: name: esp01-ventilsteuerung-01 friendly_name: esp01-ventilsteuerung-01 platform: ESP8266 board: esp01_1m # Enable logging logger: baud_rate: 0 #need this to free up UART pins # Enable Home Assistant API api: encryption: key: "KEY" ota: - platform: esphome password: "PASS" wifi: ssid: !secret wifi_ssid password: !secret wifi_password power_save_mode: none reboot_timeout: 5min fast_connect: true # Enable fallback hotspot (captive portal) in case wifi connection fails #ap: # ssid: "Esp01-Ventilsteuerung-01" # password: "PASS" # ap_timeout: 2min captive_portal: # Enable Web server. #web_server: # port: 80 time: - platform: homeassistant id: homeassistant_time # Sensors with general information. sensor: # Uptime sensor. - platform: uptime name: Relay Uptime # WiFi Signal sensor. - platform: wifi_signal name: Relay WiFi Signal update_interval: 60s uart: baud_rate: 115200 # speed to STC15L101EW tx_pin: GPIO1 rx_pin: GPIO3 switch: - platform: template name: 'Relay 1' id: relay1 turn_on_action: - uart.write: [0xA0, 0x01, 0x01, 0xA2] turn_off_action: - uart.write: [0xA0, 0x01, 0x00, 0xA1] optimistic: true - platform: template name: 'Relay 2' id: relay2 turn_on_action: - uart.write: [0xA0, 0x02, 0x01, 0xA3] turn_off_action: - uart.write: [0xA0, 0x02, 0x00, 0xA2] optimistic: true - platform: template name: 'Relay 3' id: relay3 turn_on_action: - uart.write: [0xA0, 0x03, 0x01, 0xA4] #- switch.turn_off: relay4 turn_off_action: - uart.write: [0xA0, 0x03, 0x00, 0xA3] optimistic: true - platform: template name: 'Relay 4' id: relay4 turn_on_action: - uart.write: [0xA0, 0x04, 0x01, 0xA5] #- switch.turn_off: relay3 turn_off_action: - uart.write: [0xA0, 0x04, 0x00, 0xA4] optimistic: true valve: - platform: template name: "Frischwasser" device_class: water id: valve_frischwasser open_action: then: - switch.turn_off: relay4 - switch.turn_on: relay3 - delay: 5s - switch.turn_off: relay3 close_action: then: - switch.turn_off: relay3 - switch.turn_on: relay4 - delay: 5s - switch.turn_off: relay4 optimistic: true
Mini-PC für kleine Netzwerkaufgaben
Links:
Voraussetzungen:
Nutzung/Ideen:
FriendlyCore Ubuntu Issues:
sudo mv /etc/resolv.conf /etc/resolv.conf.old
sudo nano /etc/resolv.conf
nameserver 1.1.1.1
nameserver 8.8.8.8
search fritz.box
ab Raspberry Pi 2
Code für den Raspberry Pi unter github.com/ckarrie/ckw-hass-rb-exp700.
Preis: ~20,00€
Dokumentationen vom Hersteller: joy-it.net
aka ESP-01
Links:
Arduino-IDE:
Unter Datei > Voreinstellungen folgende Borverwalter-URL ergänzen:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Bestand:
Aktuell besitze ich zwei ESP-01'er, auf dem einen läuft ein Webserver mit einer Dummy-Grafik, der zweite ist auf ein 5V Relais-Modul bestückt.
WebSchalter3.1:
!Aktuell funktioniert das Schalten des Relais nicht, evtl. sind die Pinnummern falsch
NETGEAR Switch Integration in Homeassistant
Code für HomeAssistant unter github.com/ckarrie/ckw-ha-gs108e.
Raspberry Pi 1 mit PiFace Digital IO, MQTT und Python 3
Wir nutzen unseren alten Raspberry Pi 1 mit dem PiFace Digital und verbinden die Input- und Outputports via MQTT. Sofern Homeassistant mit eurem MQTT-Broker verbunden ist, wird das neue Gerät dank MQTT-Discovery erkannt.
Der Quellcode für den Raspberry Pi liegt unter github.com/ckarrie/ckw-ha-mqtt.
mkdir ~/src/
cd ~/src/
git clone https://github.com/ckarrie/ckw-ha-mqtt
Für Python 3 muss mit
git checkout py3
der Branch gewechselt werden.
Hardware:
Software:
Installation:
sudo apt install python3-pip
sudo apt install screen
sudo pip3 install pifacecommon
sudo pip3 install pifacedigitalio
sudo pip3 install paho-mqtt
Integration in Homeassistant:
hostname ist mit dem Hostnamen von eurem Raspberry zu ersetzen.
Input Entitäts-IDs:
binary_sensor.hostname_input_0 (Eingang 0)
binary_sensor.hostname_input_1 (Eingang 1)
binary_sensor.hostname_input_2 (Eingang 2)
binary_sensor.hostname_input_3 (Eingang 3)
binary_sensor.hostname_input_4 (Eingang 4)
binary_sensor.hostname_input_5 (Eingang 5)
binary_sensor.hostname_input_6 (Eingang 6)
binary_sensor.hostname_input_7 (Eingang 7)
Output Entitäts-IDs:
switch.hostname_switch_0 (Relais 0)
switch.hostname_switch_1 (Relais 1)
switch.hostname_switch_2 (Output 2)
switch.hostname_switch_3 (Output 3)
Screenshots aus Homeassistant:
Auszug aus der Frontend yaml-Datei:
type: entities
entities:
- entity: binary_sensor.rpi_keller_piface_input_0
- entity: binary_sensor.rpi_keller_piface_input_1
- entity: binary_sensor.rpi_keller_piface_input_2
- entity: switch.rpi_keller_piface_switch_0
- entity: switch.rpi_keller_piface_switch_1
title: RPI Piface Keller
Converting Tasmota Templates to ESPHome
We use our NOUS L13T running Tasmota and migrate it to Homeassistant's ESPHome (Link to Amazon, Official Link).
After some research about GPIO formats in the Tasmota Template, I decided to migrate my NOUS L13T to ESPHome. Let's take a look at it.
GPIO Template to PIN mapping:
GPIO | 00 | 01 | 02 | 03 | 04 | 05 | 09 | 10 | 12 | 13 | 14 | 15 | 16 | 17 |
Name | D3 | D3 | FL | FL | D7 | D8 | D0 | A0 | ||||||
Index of Array | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
i.e. the Tasmota Template: {"NAME":"NOUS Smart breaker L13T", "GPIO": [1,161,1,160,225,224,1,1,544,1,32,1,1,1], "FLAG": 0, "BASE": 18}
results in following mapping.
We use https://tasmota.github.io/docs/Components/#tasmota to look up the corresponding component. An Array Value of "1" stands for "User" an can be customized in the Tasmota WebUI.
Array Index | Array Value | Tasmota Component | Description |
0 | 1 | User | |
1 | 161 | Switch2 | Switch, internal pull-up resistor |
2 | 1 | User | |
3 | 160 | Switch1 | Switch, internal pull-up resistor |
4 | 225 | Relay2 | Relay |
5 | 224 | Relay1 | Relay |
6 | 1 | User | |
7 | 1 | User | |
8 | 544 | LedLink | Link LED |
9 | 1 | User | |
10 | 32 | Button1 | Button active low, internal pull-up resistor |
11 | 1 | User | |
12 | 1 | User | |
13 | 1 | User |
My corresponding ESPHome yaml looks like this:
substitutions: devicename: "NOUS L13T Sommerküche Licht" esphome: name: nous-l13t-sommerkueche-licht friendly_name: "${devicename}" esp8266: board: esp01_1m # Enable logging logger: # Enable Home Assistant API api: encryption: key: "xxxxxxxxxxxx" ota: password: "xxxxxxxxxxxx" wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot # (captive portal) in case wifi connection fails ap: ssid: "Nous-L13T-Sommerkueche-Licht" password: "xxxxxxxxxxxx" captive_portal: # Status LED light: - platform: status_led id: led pin: number: GPIO12 inverted: true binary_sensor: - platform: status name: "Status" # toggle relay on/off - platform: gpio name: "Button Switch 1" pin: number: GPIO03 inverted: true mode: input: true pullup: true id: "button_state_switch_1" on_press: then: - switch.turn_on: "button_switch_1" on_release: then: - switch.turn_off: "button_switch_1" - switch.turn_off: "button_switch_2" on_double_click: min_length: 50ms max_length: 350ms then: - switch.toggle: "button_switch_2" - platform: gpio name: "Button Switch 2" pin: number: GPIO01 inverted: true mode: input: true pullup: true id: "button_state_switch_2" on_press: - switch.toggle: "button_switch_2" switch: - platform: template name: "Switch 1" icon: mdi:power optimistic: true id: "button_switch_1" lambda: |- if (id(relay_1).state) { return true; } else { return false; } turn_on_action: - switch.turn_on: relay_1 - light.turn_on: led turn_off_action: - switch.turn_off: relay_1 - light.turn_off: led - platform: template name: "Switch 2" icon: mdi:power optimistic: true id: "button_switch_2" lambda: |- if (id(relay_2).state) { return true; } else { return false; } turn_on_action: - switch.turn_on: relay_2 turn_off_action: - switch.turn_off: relay_2 - platform: gpio pin: GPIO05 id: "relay_1" - platform: gpio pin: GPIO04 id: "relay_2"
I did some "special" actions on Button Switch 1: pressing On+Off+On fast turns on Light 2 (and Light 1 is turn on by on_press
).
Have fun!
mit ESPHome
Link zu YAML-Dateien: https://github.com/esphome/firmware/blob/main/voice-assistant/m5stack-atom-echo.yaml