Substitutions Template Zweck
Wiederverwendbare ESPHome-Konfiguration mit Variablen für einfache Anpassung und Wartung. Vorteile
Wiederverwendbarkeit: Ein Template für mehrere ähnliche Geräte
Einfache Anpassung: Nur Substitutions ändern statt ganzen Code
Weniger Fehler: Zentrale Definition wichtiger ...
Code-Vorschau
Haupt-Konfiguration
Tipp: Markieren & ⌘/Ctrl + C zum Kopieren
configuration.yaml
1# Standard ESPHome Substitutions Template2# Macht Konfigurationen wiederverwendbar und einfacher anpassbar3substitutions:4# Geräte-Identifikation5device_name:"sensor-device"# Interner Name (Kleinbuchstaben, keine Leerzeichen)6friendly_name:"Sensor Device"# Anzeigename in Home Assistant7device_description:"ESPHome Gerät mit Sensoren und Aktoren"89# Hardware-Konfiguration10board_type:"esp32dev"# esp32dev, nodemcuv2, d1_mini, etc.11framework_version:"recommended"# recommended, latest, 5.4.0, etc.1213# Pin-Zuweisungen (für dein Board anpassen)14pin_sda:"GPIO21"# I²C SDA Pin15pin_scl:"GPIO22"# I²C SCL Pin16pin_led:"GPIO2"# Status-LED Pin17pin_button:"GPIO0"# Boot-Button Pin1819# Timing-Einstellungen20update_interval_fast:"10s"# Für kritische Sensoren21update_interval_normal:"30s"# Für reguläre Sensoren 22update_interval_slow:"60s"# Für Status-Sensoren2324# Netzwerk-Einstellungen25wifi_fast_connect:"true"26wifi_power_save:"light"27ap_password:"12345678"# Fallback AP Passwort (min. 8 Zeichen)2829# Home Assistant Einstellungen30api_encryption_key:!secret api_encryption_key
31ota_password:!secret ota_password
3233# Hardware-spezifische Einstellungen34i2c_scan:"true"35log_level:"INFO"# VERBOSE, DEBUG, INFO, WARN, ERROR3637# Basis-Gerätekonfiguration mit Substitutions38esphome:39name: ${device_name}40friendly_name: ${friendly_name}41comment: ${device_description}4243# Plattform-Konfiguration44platform: ESP32
45board: ${board_type}46framework:47type: arduino
48version: ${framework_version}4950# WiFi mit Substitutions51wifi:52ssid:!secret wifi_ssid
53password:!secret wifi_password
54fast_connect: ${wifi_fast_connect}55power_save_mode: ${wifi_power_save}5657ap:58ssid:"${friendly_name} Fallback"59password: ${ap_password}6061# API mit Verschlüsselung62api:63encryption:64key: ${api_encryption_key}6566# OTA-Updates67ota:68-platform: esphome
69password: ${ota_password}7071# Protokollierung72logger:73level: ${log_level}7475# Status-LED mit Substitution76status_led:77pin:78number: ${pin_led}79inverted:false8081# I²C-Bus mit Substitutions82i2c:83sda: ${pin_sda}84scl: ${pin_scl}85scan: ${i2c_scan}86frequency: 100kHz
8788# Captive Portal89captive_portal:9091# Beispiel-Sensor mit Substitutions92sensor:93-platform: uptime
94name:"${friendly_name} Uptime"95update_interval: ${update_interval_slow}96entity_category: diagnostic
9798-platform: wifi_signal
99name:"${friendly_name} WiFi Signal"100update_interval: ${update_interval_slow}101entity_category: diagnostic
102103# Beispiel-Binärsensor mit Substitutions104binary_sensor:105-platform: gpio
106pin:107number: ${pin_button}108mode: INPUT_PULLUP
109inverted:true110name:"${friendly_name} Button"111id: device_button
112on_press:113-logger.log:"Button pressed!"114115-platform: status
116name:"${friendly_name} Status"117entity_category: diagnostic
118119# Beispiel-Neustart-Button120button:121-platform: restart
122name:"${friendly_name} Restart"123entity_category: diagnostic