diff --git a/local_code/ESPHome/configuration.yaml b/local_code/ESPHome/configuration.yaml index 5e53ee8..c13af16 100644 --- a/local_code/ESPHome/configuration.yaml +++ b/local_code/ESPHome/configuration.yaml @@ -5,6 +5,12 @@ external_components: esphome: name: doorwhat friendly_name: doorwhat + on_boot: + priority: -100 + then: + - lambda: |- + id(sensor_ready) = true; + - delay: 2s # 2 Sekunden Verzögerung für Stabilität esp32: board: esp32dev @@ -21,17 +27,6 @@ ota: - platform: esphome password: "1618b7dc423684c5d3661481ce284359" -font: - - file: "gfonts://Roboto" - id: my_font - size: 18 - -image: - - file: "cat.svg" - id: cat_img - resize: 64x64 - type: BINARY - wifi: ssid: !secret wifi_ssid password: !secret wifi_password @@ -61,6 +56,17 @@ color: - id: black hex: "FFFFFF" +font: + - file: "gfonts://Roboto" + id: my_font + size: 18 + +image: + - file: "cat.svg" + id: cat_img + resize: 64x64 + type: BINARY + globals: - id: last_on_time type: std::string @@ -70,6 +76,10 @@ globals: type: std::string restore_value: no initial_value: '"Noch nie"' + - id: sensor_ready + type: bool + restore_value: no + initial_value: 'true' # Direkt auf 'true' setzen, damit der Sensor immer bereit ist text_sensor: - platform: template @@ -82,13 +92,20 @@ text_sensor: binary_sensor: - platform: gpio pin: - number: 18 - mode: INPUT + number: 21 + mode: INPUT_PULLUP + inverted: True id: opto_in name: "Optokoppler Eingang" + internal: false + publish_initial_state: true + filters: + - delayed_off: 20ms on_press: then: + - delay: 1s - lambda: |- + if (!id(sensor_ready)) return; auto time = id(ha_time).now(); std::string new_time; if (time.is_valid()) { @@ -96,14 +113,13 @@ binary_sensor: } else { new_time = "Zeit unbekannt"; } - id(previous_on_time) = id(last_on_time); id(last_on_time) = new_time; - id(letzter_gong_sensor).publish_state(id(last_on_time)); id(vorheriger_gong_sensor).publish_state(id(previous_on_time)); - component.update: my_display + display: - platform: waveshare_epaper model: 2.90in3c @@ -111,10 +127,10 @@ display: dc_pin: 16 reset_pin: 17 busy_pin: 5 - rotation: 270 + rotation: 90 reset_duration: 2ms id: my_display - update_interval: 600s # alle 10 Minuten automatisch + update_interval: 600s lambda: |- it.print(0, 4, id(my_font), id(black), "DoorWhat v1.0");