home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.05k stars 29.71k forks source link

Energy dashboard not showing the correct value of gas usage #69184

Closed dm82m closed 2 years ago

dm82m commented 2 years ago

The problem

My energy dashboard is not showing the correct value of the gas usage. Its a total different value and I dont understand why. I have a template sensor that holds one state a day. This state represents the gas usage of the day before and is extracted from another sensor by automation and roughly transformed to m3 from kWh.

So the source field is: sensor.wtc_g_pc_tageswarmemenge_vortag_gesamt_we0 The destination field is: sensor.wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3

The database contains the correct value for the sensor "wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3" and also has only this one state, see:

state_id,domain,entity_id,state,attributes,event_id,last_changed,last_updated,created,old_state_id
215141,sensor,sensor.wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3,4.468999999999999,"{""unit_of_measurement"":""m\u00b3"",""friendly_name"":""wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3"",""state_class"":""total_increasing"",""icon"":""mdi:gas-cylinder"",""device_class"":""gas"",""updated_by"":""python_script.set_state""}",220642,2022-04-03 03:00:00.047849,2022-04-03 03:00:00.047849,2022-04-03 03:00:00.047849,177771

and also the sensor itself has the right value:

image

but the energy dashboard shows a complete different value:

image image

What version of Home Assistant Core has the issue?

core-2022.3.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

configuration.yaml
sensors:
  - platform: template
    sensors:
      wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3:
        unit_of_measurement: "m³"
        value_template: None

automation.yaml
- alias: "Gas Usage last day"
  trigger:
    - platform: time
      at: '05:00:00'
  action:
    - service: python_script.set_state
      data_template:
        entity_id: sensor.wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3
        state: '{{ states("sensor.wtc_g_pc_tageswarmemenge_vortag_gesamt_we0") | replace(",",".") | float / 10 }}'
        updated_by: python_script.set_state

customize.yaml
sensor.wtc_g_pc_tageswarmemenge_vortag_gesamt_we0_m3:
  state_class: total_increasing
  icon: mdi:gas-cylinder
  device_class: gas

Anything in the logs that might be useful for us?

No response

Additional information

No response

dm82m commented 2 years ago

I guess the state_class could be wrong. I try to set it to total and see if that helps.

dm82m commented 2 years ago

no HA issue, solved it on my own, see: https://github.com/erikkastelec/hass-WEM-Portal/issues/19