Wiederverwendbare ESPHome-Konfiguration mit Variablen für einfache Anpassung und Wartung. - Wiederverwendbarkeit: Ein Template für mehrere ähnliche Geräte - Einfache Anpassung: Nur Substitutio...
Wiederverwendbare ESPHome-Konfiguration mit Variablen für einfache Anpassung und Wartung.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Standard ESPHome Substitutions Template
# Macht Konfigurationen wiederverwendbar und einfacher anpassbar
substitutions:
# Geräte-Identifikation
device_name: "sensor-device" # Interner Name (Kleinbuchstaben, keine Leerzeichen)
friendly_name: "Sensor Device" # Anzeigename in Home Assistant
device_description: "ESPHome Gerät mit Sensoren und Aktoren"
# Hardware-Konfiguration
board_type: "esp32dev" # esp32dev, nodemcuv2, d1_mini, etc.
framework_version: "recommended" # recommended, latest, 5.4.0, etc.
# Pin-Zuweisungen (für dein Board anpassen)
pin_sda: "GPIO21" # I²C SDA Pin
pin_scl: "GPIO22" # I²C SCL Pin
pin_led: "GPIO2" # Status-LED Pin
pin_button: "GPIO0" # Boot-Button Pin
# Timing-Einstellungen
update_interval_fast: "10s" # Für kritische Sensoren
update_interval_normal: "30s" # Für reguläre Sensoren
update_interval_slow: "60s" # Für Status-Sensoren
# Netzwerk-Einstellungen
wifi_fast_connect: "true"
wifi_power_save: "light"
ap_password: "12345678" # Fallback AP Passwort (min. 8 Zeichen)
# Home Assistant Einstellungen
api_encryption_key: !secret api_encryption_key
ota_password: !secret ota_password
# Hardware-spezifische Einstellungen
i2c_scan: "true"
log_level: "INFO" # VERBOSE, DEBUG, INFO, WARN, ERROR
# Basis-Gerätekonfiguration mit Substitutions
esphome:
name: ${device_name}
friendly_name: ${friendly_name}
comment: ${device_description}
# Plattform-Konfiguration
platform: ESP32
board: ${board_type}
framework:
type: arduino
version: ${framework_version}
# WiFi mit Substitutions
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: ${wifi_fast_connect}
power_save_mode: ${wifi_power_save}
ap:
ssid: "${friendly_name} Fallback"
password: ${ap_password}
# API mit Verschlüsselung
api:
encryption:
key: ${api_encryption_key}
# OTA-Updates
ota:
- platform: esphome
password: ${ota_password}
# Protokollierung
logger:
level: ${log_level}
# Status-LED mit Substitution
status_led:
pin:
number: ${pin_led}
inverted: false
# I²C-Bus mit Substitutions
i2c:
sda: ${pin_sda}
scl: ${pin_scl}
scan: ${i2c_scan}
frequency: 100kHz
# Captive Portal
captive_portal:
# Beispiel-Sensor mit Substitutions
sensor:
- platform: uptime
name: "${friendly_name} Uptime"
update_interval: ${update_interval_slow}
entity_category: diagnostic
- platform: wifi_signal
name: "${friendly_name} WiFi Signal"
update_interval: ${update_interval_slow}
entity_category: diagnostic
# Beispiel-Binärsensor mit Substitutions
binary_sensor:
- platform: gpio
pin:
number: ${pin_button}
mode: INPUT_PULLUP
inverted: true
name: "${friendly_name} Button"
id: device_button
on_press:
- logger.log: "Button pressed!"
- platform: status
name: "${friendly_name} Status"
entity_category: diagnostic
# Beispiel-Neustart-Button
button:
- platform: restart
name: "${friendly_name} Restart"
entity_category: diagnostic