Created
November 28, 2022 22:47
-
-
Save djmaze/852c27c37f4f223f346782635b93b1ae to your computer and use it in GitHub Desktop.
ESPHome-Config, um einen Gaszähler per Reed-Kontakt auszulesen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
globals: | |
- id: total_pulses | |
type: int | |
restore_value: true | |
initial_value: '0' # startet mit 0 | |
- id: imp_ratio | |
type: float | |
restore_value: false | |
initial_value: '0.01' # vom Gaszaehler | |
- id: Zustandszahl | |
type: float | |
restore_value: false | |
initial_value: '0.9643' # aus der Gasrechnung | |
- id: Brennwert | |
type: float | |
restore_value: false | |
initial_value: '10.276' # aus der Gasrechnung | |
- id: initial_consumption | |
type: float | |
restore_value: false | |
initial_value: '19967086' # hier kann der Gaszählerstand initialisiert werden (Faktor 1000 um einen genaueren Wert zu erzeugen) | |
- id: initial_energy_consumption | |
type: float | |
restore_value: false | |
initial_value: id(initial_consumption) * id(Brennwert) * id(Zustandszahl) / 1000.0 | |
binary_sensor: | |
- platform: gpio | |
id: internal_pulse_counter | |
pin: | |
number: GPIO5 # Pin, an dem der Reed-Kontakt hängt | |
mode: INPUT_PULLUP | |
name: "Live-Impuls" | |
filters: | |
- delayed_on: 100ms | |
on_press: | |
then: | |
- lambda: id(total_pulses) += 1; | |
#- light.turn_on: | |
# id: led # optional: für eine LED, die den Gaszählerpuls visualisiert | |
#on_release: | |
# then: | |
# - light.turn_off: status # optional: für eine LED, die den Gaszählerpuls visualisiert | |
## Optional: Diese LED soll blinken, sobald ein Signal vom Gaszähler erkannt wird | |
#output: | |
#- platform: gpio | |
#pin: GPIO0 | |
#id: 'led' | |
sensor: | |
- platform: template | |
name: "Gasverbrauch" | |
device_class: gas | |
update_interval : 10s | |
unit_of_measurement: "m³" | |
state_class: total_increasing | |
icon: "mdi:fire" | |
accuracy_decimals: 2 | |
lambda: return (id(initial_consumption)/1000.0) + (id(total_pulses) * id(imp_ratio)); | |
- platform: template | |
name: 'Gasverbrauch Energy' | |
device_class: energy | |
state_class: total_increasing | |
update_interval : 10s | |
icon: 'mdi:fire' | |
accuracy_decimals: 1 | |
unit_of_measurement: "kWh" | |
lambda: return id(initial_energy_consumption) + (id(total_pulses) * id(imp_ratio) * id(Brennwert) * id(Zustandszahl)); | |
- platform: template | |
name: 'Pulse Counter total' | |
update_interval : 10s | |
icon: "mdi:counter" | |
accuracy_decimals: 0 | |
unit_of_measurement: "pulses" | |
lambda: return id(total_pulses); |
Eventuell reicht es, wenn du einmal die Firmware neu deployst mit restore_value: false
bei total_pulses
. (Also Zeile 4 im obigen Code.) Und direkt danach wieder mit restore_value: true
. Habe das aber noch nicht ausprobiert.
Hi,
Danke. Da es derzeit aber läuft fass ich es grade nicht an. Beim letzten mal hab ich ne ganze weile per Magneten Pulse hinzuaddiert :-D bzw. des ganze eine bestimmte Weile abgesteckt gelassen. Aber vielleicht brauche ich es nochmal dann versuche ich es bestimmt. ich hatte schon mit den Werten rumgespielt, aber nichts sinnvolles erreicht.
Danke auf jeden Fall.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
Sorry hatte keine Benachrichtigung bekommen dass du mir geantwortet hattest...
Ich zumindest der Verbrauch der auf der Anzeige steht wäre nett wenn ich ihn zurücksetzen könnte.
Hab bspw. Letztens einen neuen Zähler eingebaut bekommen...