Hello. Since Months (!) i try to read my Gas meter. I got a result, so the ESP8266 works. But what I get just doesn’t make sense.
My Configuration:
esphome:
name: "esp8266-gas-keller"
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "###"
ota:
password: "###"
# Example configuration entry
wifi:
ssid: !secret privatewifi_ssid
password: !secret privatewifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Gas-Fallback Hotspot"
password: "###"
captive_portal:
globals:
- id: total_pulses
type: int
restore_value: false
initial_value: '0' # mit diesem Wert startet der Gaszählerstand
- id: imp_ratio
type: float
restore_value: false
initial_value: '0.01'
binary_sensor:
- platform: gpio
id: internal_pulse_counter
pin:
number: D1
mode: INPUT_PULLUP
name: "Live-Impuls"
filters:
- delayed_on: 10ms
on_press:
then:
- lambda: id(total_pulses) += 1;
- platform: status
name: "Status Gassensor"
sensor:
- platform: template
name: "Gasvebrauch Puls"
device_class: gas
unit_of_measurement: "m³"
state_class: "total_increasing"
icon: "mdi:fire"
accuracy_decimals: 2
lambda: |-
return id(total_pulses) * id(imp_ratio);
ESP_LOGD("Gaszähler Impulse Tag", "Pulse bisher %d", id(total_pulses));
- platform: template
name: "Gasverbrauch in kWh"
device_class: gas
unit_of_measurement: "kWh"
state_class: "total_increasing"
icon: "mdi:fire"
accuracy_decimals: 2
lambda: |-
return id(total_pulses) * id(imp_ratio) * 10;
ESP_LOGD("Gaszähler kWh Tag", "Pulse bisher %d", id(total_pulses));
The result is “0”. Without exception! And when I look at the source code, I just don’t understand why. Because i can´t finde any error. Whould you please help me? Thanks!