-
-
Save Sub-7/cbe734888beef4278d214cfeeb6ee306 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment