# ESP32 Test-Rauchmelder für Node-RED Smoke Detection Flow # # Funktionen: # - Switch "Rauch erkannt setzen" -> steuert Binary Sensor # - Switch "Sirene" -> steuert die onboard LED # - Binary Sensor "Rauch erkannt" -> on/off basierend auf Switch # - BOOT Button (GPIO0) -> Toggle für Rauch-Status # # Die meisten ESP32 Boards haben eine LED an GPIO2 # Der BOOT Button ist typischerweise an GPIO0 esphome: name: test-rauchmelder friendly_name: Test Rauchmelder esp32: board: esp32dev framework: type: arduino # WLAN-Konfiguration wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Fallback Access Point falls WLAN nicht erreichbar ap: ssid: "Test-Rauchmelder" password: "12345678" captive_portal: # Logging aktivieren logger: # Home Assistant API api: encryption: key: !secret api_encryption_key # OTA Updates ota: - platform: esphome password: !secret ota_password # Webserver für Debugging (optional) web_server: port: 80 # ============================================ # GPIO für Onboard LED (meist GPIO2 bei ESP32) # ============================================ output: - platform: gpio pin: GPIO2 id: onboard_led_output light: - platform: binary name: "Sirene LED" id: sirene_led output: onboard_led_output # Wird intern gesteuert, nicht direkt exposed # ============================================ # SWITCHES # ============================================ # Globale Variable für Rauch-Status globals: - id: rauch_erkannt_status type: bool restore_value: no initial_value: 'false' switch: # Switch 1: Rauch erkannt setzen - platform: template name: "Rauch erkannt setzen" id: switch_rauch_setzen icon: "mdi:fire" optimistic: true restore_mode: ALWAYS_OFF on_turn_on: - globals.set: id: rauch_erkannt_status value: 'true' - binary_sensor.template.publish: id: binary_rauch_erkannt state: ON - logger.log: "Rauch erkannt wurde aktiviert!" on_turn_off: - globals.set: id: rauch_erkannt_status value: 'false' - binary_sensor.template.publish: id: binary_rauch_erkannt state: OFF - logger.log: "Rauch erkannt wurde deaktiviert!" # Switch 2: Sirene (steuert die Onboard LED) - platform: template name: "Sirene" id: switch_sirene icon: "mdi:alarm-light" optimistic: true restore_mode: ALWAYS_OFF on_turn_on: - light.turn_on: sirene_led - logger.log: "Sirene AN - LED leuchtet!" on_turn_off: - light.turn_off: sirene_led - logger.log: "Sirene AUS - LED aus!" # ============================================ # BINARY SENSOR # ============================================ binary_sensor: # BOOT Button (GPIO0) als Toggle für Rauch-Status - platform: gpio pin: number: GPIO0 mode: INPUT_PULLUP inverted: true name: "Boot Button" id: boot_button internal: true # Nicht in HA anzeigen filters: - delayed_on: 10ms # Entprellen on_press: then: - switch.toggle: switch_rauch_setzen - logger.log: "Boot Button gedrückt - Toggle Rauch-Status!" # Binary Sensor: Rauch erkannt (gesteuert durch Switch) - platform: template name: "Rauch erkannt" id: binary_rauch_erkannt device_class: smoke icon: "mdi:smoke-detector" lambda: |- return id(rauch_erkannt_status); # Status-Sensor für Verbindung - platform: status name: "Status" # ============================================ # ZUSÄTZLICHE SENSOREN (optional) # ============================================ sensor: # WLAN Signalstärke - platform: wifi_signal name: "WLAN Signal" update_interval: 60s # Uptime - platform: uptime name: "Laufzeit" update_interval: 60s # ============================================ # TEXT SENSOR # ============================================ text_sensor: # IP Adresse - platform: wifi_info ip_address: name: "IP Adresse" ssid: name: "Verbundenes WLAN" # ============================================ # BUTTON für Neustart # ============================================ button: - platform: restart name: "Neustart"