Gaszähler mittels Reedkontakt einlesen

Vielen Dank für eure Beiträge!

Ich hatte mir den Smartnetz.at Gassensor besorgt. Aber Tasmota und MQTT sind in meinen Augen unnötig kompliziert wenn ein ESP32 C3 Super Mini Board zum Einsatz kommt.

> esphome:
>
>   name: gaszahler
>
>   friendly_name: Gaszähler
>
>   platformio_options:
>
>     board_build.flash_mode: dio
>
> esp32:
>
>   board: esp32-c3-devkitm-1
>
>   variant: ESP32C3
>
>   framework:
>
>     type: esp-idf
>
> #Config for status_led (on GPIO8):
>
> #light:
>
> \#  - platform: status_led
>
> \#    name: "Status LED"
>
> \#    id: esp_status_led
>
> \#    icon: "mdi:alarm-light"
>
> \#    pin:
>
> \#      number: GPIO8
>
> \#      inverted: true
>
> \#    restore_mode: ALWAYS_OFF  
>
> 
>
> #esp32:
>
> \#  board: esp32-c3-devkitm-1
>
> \#  framework:
>
> \#    type: esp-idf
>
> 
>
> \# Enable logging
>
> logger:
>
> web_server:
>
>   port: 80
>
>   local: true
>
> 
>
> \# Enable Home Assistant API
>
> api:
>
>   encryption:
>
>     key: "XXX"
>
> ota:
>
>   - platform: esphome
>
>     password: "XXX"
>
> wifi:
>
>   ssid: !secret wifi_ssid
>
>   password: !secret wifi_password
>
> \# Enable fallback hotspot (captive portal) in case wifi connection fails
>
>   ap:
>
>     ssid: "Gaszahler Fallback Hotspot"
>
>     password: "XXX"
>
> captive_portal:
>
> globals:
>
>   - id: total_pulses
>
>     type: int
>
>     restore_value: false
>
>     initial_value: '12278260'  # mit diesem Wert startet der Gaszählerstand
>
> binary_sensor:
>
>   - platform: gpio
>
>     id: internal_pulse_counter
>
>     pin:
>
>       number: GPIO3
>
>       mode: INPUT_PULLUP
>
>     name: "Live-Impuls"
>
>     filters:
>
>       - delayed_on: 10ms
>
>     on_press:
>
>       then:
>
>         - lambda: id(total_pulses) += 1;
>
>         - output.turn_off: led  # für die LED, zur Anzeige des Schaltvorgangs
>
>     on_release:
>
>       then:
>
>         - output.turn_on: led  # für die LED, zur Anzeige des Schaltvorgangs
>
> sensor: 
>
>   - platform: template
>
>     name: "Gasverbrauch"
>
>     device_class: gas
>
>     unit_of_measurement: "m³"
>
>     state_class: "total_increasing"
>
>     icon: "mdi:meter-gas-outline"
>
>     accuracy_decimals: 3
>
>     lambda: |-
>
>       return id(total_pulses) \* 0.01;
>
> \# Diese LED blinkt, wenn ein Signal vom Reedkontakt erkannt wird
>
> output:
>
>   - platform: gpio # Die interne LED auf dem Board
>
>     pin: GPIO8
>
>     id: 'led'
>
>     inverted: true
>
> #esp32_ble_tracker:
>
> \#  scan_parameters:
>
> \# We currently use the defaults to ensure Bluetooth
>
> \# can co-exist with WiFi In the future we may be able to
>
> \# enable the built-in coexistence logic in ESP-IDF
>
> \#    active: true
>
> #bluetooth_proxy:
>
> \#  active: true

Ich bekomme die Impulse direkt und somit ohne weitere Fehlerquellen. Und vor allem lokal ohne irgendwelche Cloud Dienste (mit) zu nutzen ;.)

:crayon:by HarryP: Code-/Logzeilen formatiert (bitte immer in </> einbinden)

s.a.: ( Neues Update & Features - Hier in der Community 🫶 )