Statistics not correct

Hi,

I’m not sure where to post this as I do not have any clue on how to investigate.
So I’m just spitting out what I see and hope for the best.

Background: I have a digital gas meter and I’ve added this meter to the energy dashboard.
When I take a look at the graph of the meter, it is looking ‘fine’ as far as I can tell

But when I take a look at the energy dashboard, it tells me I used 70m³ of gas on the 2nd of November

That does not feel like it is correct.
Taking a look at the entries in the database it ‘jumps’ all of a sudden with that same value of 70

My question is 2 parted:

  • Does anybody know what might have triggered this?
  • Does anybody know on how to correct it?

Thanks a lot for your replies.

what’s creating the sensor? List all that apply

The sensor is created by a ‘SlimmeLezer’ which I have flashed the ESPHome.

Based on the data is see, it looks like the sensor is correct.

does the sensor go unavailable when unreachable or does it go to zero?

I unplugged the device and I see the sensor has become ‘unavailable’

Then something in the sensor decided to make it momentarily go to 70 at 4pm

I didn’t think of that. Zooming in on the graph:


So this indeed confirms your story. For some reason, it went down to 0 and than back to it’s actual value (in this case ±70)

  • This means I need to check why that sensor went down to zero.
  • Do you have an idea on how to correct the stats?

I don’t believe you can correct the stats. Your consumption sensor, is it a template sensor or directly from esphome?

directly from ESPHome

can you share that config?

Sure, It is based on what I found online.

substitutions:
  device_id: Slimmelezer
  device_name: slimmelezer
  
  ip_address: !secret static_ip_slimmelezer
  
  # Common properties
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password
  
  ip_gateway: !secret static_ip_gateway
  ip_subnet: !secret static_ip_subnet
  ip_dns: !secret static_ip_dns
  
  ap_wifi_password: !secret wifi_fallback_password
  
  webserver_username: admin
  webserver_password: !secret esphome_web_server_password
  
  ota_password: !secret esphome_ota_password
  api_password: !secret home_assistant_api_password
  api_encryption: !secret home_assistant_api_encryption_key
  log_level: DEBUG
  
  throttle: 15s

external_components:
  - source:
      type: git
      url: https://github.com/mmakaay/esphome
      ref: fix-dsmr-read-chunk-size
    components: [ "dsmr" ]
    refresh: 60s


     
esphome:
  build_path: ./build/${device_id}
  name: ${device_name}
  comment: "${device_description}"
  platform: ESP8266
  esp8266_restore_from_flash: true
  board: d1_mini
  project:
    name: zuidwijk.slimmelezer
    version: "1.0"
 
<<: !include includes/components/wifi/wifi.yaml

<<: !include includes/components/logger/logger.yaml

<<: !include includes/components/ota/ota.yaml

<<: !include includes/components/webserver/webserver.yaml

<<: !include includes/components/api/api.yaml
 
uart:
  id: uart_bus
  baud_rate: 115200
  rx_pin: D7
 
dsmr:
  id: dsmr_instance
  crc_check: false
 
sensor:
  - platform: dsmr
    energy_delivered_tariff1:
      name: "Energy Consumption Day"
      id: verbruik_dag_totaal
      state_class: total_increasing
      filters:
        - throttle: ${throttle}
    energy_delivered_tariff2:
      name: "Energy Consumption Night"
      state_class: total_increasing
      filters:
        - throttle: ${throttle}
    power_delivered:
      name: "Power Consumed"
      accuracy_decimals: 3
      filters:
        - throttle: ${throttle}
    electricity_failures:
      name: "Electricity Failures"
      icon: mdi:alert
      disabled_by_default: true
    electricity_long_failures:
      name: "Long Electricity Failures"
      icon: mdi:alert
      disabled_by_default: true
    voltage_l1:
      name: "Voltage L1"
      filters:
        - throttle: ${throttle}
    voltage_l2:
      name: "Voltage L2"
      filters:
        - throttle: ${throttle}
    voltage_l3:
      name: "Voltage L3"
      filters:
        - throttle: ${throttle}
    current_l1:
      name: "Current L1"
      filters:
        - throttle: ${throttle}
    current_l2:
      name: "Current L2"
      filters:
        - throttle: ${throttle}
    current_l3:
      name: "Current L3"
      filters:
        - throttle: ${throttle}
    gas_delivered_be:
      name: "Gas Consumed"
      state_class: total_increasing
      filters:
        - throttle: ${throttle}

  - !include includes/components/sensor/uptime.yaml
  
  - !include includes/components/sensor/wifi.yaml
      
  - !include includes/components/text_sensor/wifi.yaml

  - platform: template
    name: "$device_name Uptime"
    id: uptime_human
    icon: mdi:clock-start
  
# ******* SWITCH *******
switch:
  - !include includes/components/switch/restart.yaml

Looks normal to me

I did change the config a bit

substitutions:
  device_id: Slimmelezer
  device_name: slimmelezer
  
  ip_address: !secret static_ip_slimmelezer
  
  # Common properties
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password
  
  ip_gateway: !secret static_ip_gateway
  ip_subnet: !secret static_ip_subnet
  ip_dns: !secret static_ip_dns
  
  ap_wifi_password: !secret wifi_fallback_password
  
  webserver_username: admin
  webserver_password: !secret esphome_web_server_password
  
  ota_password: !secret esphome_ota_password
  api_password: !secret home_assistant_api_password
  api_encryption: !secret home_assistant_api_encryption_key
  log_level: DEBUG
  
  throttle: 15s

external_components:
  - source:
      type: git
      url: https://github.com/mmakaay/esphome
      ref: fix-dsmr-read-chunk-size
    components: [ "dsmr" ]
    refresh: 60s
     
esphome:
  build_path: ./build/${device_id}
  name: ${device_name}
  comment: "${device_description}"
  platform: ESP8266
  esp8266_restore_from_flash: true
  board: d1_mini
  project:
    name: zuidwijk.slimmelezer
    version: "1.0"
 
<<: !include includes/components/wifi/wifi.yaml

<<: !include includes/components/logger/logger.yaml

<<: !include includes/components/ota/ota.yaml

<<: !include includes/components/webserver/webserver.yaml

<<: !include includes/components/api/api.yaml
 
uart:
  id: uart_bus
  baud_rate: 115200
  rx_pin: D7
 
dsmr:
  id: dsmr_instance
  crc_check: false
 
sensor:
  - platform: dsmr
    energy_delivered_tariff1:
      name: "Energy Consumption Day"
      id: verbruik_dag_totaal
      state_class: total_increasing
      icon: mdi:gauge
      filters:
        - throttle: ${throttle}
        - lambda: |-
            static float last_value_d = NAN;
            if (x > 0 && (isnan(last_value_d) || (x >= last_value_d))) {
              return last_value_d = x;
            } else {
              ESP_LOGW("Engergy day", "Received value %.3f which is lower than %.3f, returning last one", x, last_value_d);
              return last_value_d;
            }
    energy_delivered_tariff2:
      name: "Energy Consumption Night"
      state_class: total_increasing
      icon: mdi:gauge
      filters:
        - throttle: ${throttle}
        - lambda: |-
            static float last_value_n = NAN;
            if (x > 0 && (isnan(last_value_n) || (x >= last_value_n))) {
              return last_value_n = x;
            } else {
              ESP_LOGW("Engergy night", "Received value %.3f which is lower than %.3f, returning last one", x, last_value_n);
              return last_value_n;
            }
    power_delivered:
      name: "Power Consumed"
      accuracy_decimals: 3
      filters:
        - throttle: ${throttle}
    electricity_failures:
      name: "Electricity Failures"
      icon: mdi:alert
      disabled_by_default: true
    electricity_long_failures:
      name: "Long Electricity Failures"
      icon: mdi:alert
      disabled_by_default: true
    voltage_l1:
      name: "Voltage L1"
      filters:
        - throttle: ${throttle}
    voltage_l2:
      name: "Voltage L2"
      filters:
        - throttle: ${throttle}
    voltage_l3:
      name: "Voltage L3"
      filters:
        - throttle: ${throttle}
    current_l1:
      name: "Current L1"
      filters:
        - throttle: ${throttle}
    current_l2:
      name: "Current L2"
      filters:
        - throttle: ${throttle}
    current_l3:
      name: "Current L3"
      filters:
        - throttle: ${throttle}
    gas_delivered_be:
      name: "Gas Consumed"
      state_class: total_increasing
      filters:
        - throttle: ${throttle}
        - lambda: |-
            static float last_value_g = NAN;
            if (x > 0 && (isnan(last_value_g) || (x >= last_value_g))) {
              return last_value_g = x;
            } else {
              ESP_LOGW("Gas", "Received value %.3f which is lower than %.3f, returning last one", x, last_value_g);
              return last_value_g;
            }

  - !include includes/components/sensor/uptime.yaml
  
  - !include includes/components/sensor/wifi.yaml
 
text_sensor:    
  - !include includes/components/text_sensor/wifi.yaml

  - platform: template
    name: "$device_name Uptime"
    id: uptime_human
    icon: mdi:clock-start
  
# ******* SWITCH *******
switch:
  - !include includes/components/switch/restart.yaml