Skip to content

[Bug] Average value for previous days changes after the day has ended (Month view, Group by Day) #286

Description

@ElianST

Data Files: Please add all 3 text files of the entity(s).

Added

2. Your YAML Code

type: custom:statistics-graph-chart-card
card_header: COP maand
card_background_color: " rgba(36, 37, 41, 0.3)"
card_border: false
show_y_axis_label: true
brush_zoom: false
points_per_hour: 6
tooltip_match_axis: false
tooltip_order: default
height: 200
show_full_period: true
x_grid_style: dashed
y_grid_style: dashed
show_date_picker: true
date_picker_group: "2"
date_picker_modes:
  - month
align_header: center
state_layout: horizontal
group_by: date
entities:
  - entity: sensor.dagelijkse_cop_warmtepomp
    statistic_id: null
    name: Gemiddeld
    color: "#54b134"
    state_color: "#ffffff"
    state_size: "20"
    show_trend_icon: false
    show_line: false
    graph_type: bar
    align_state: center
    primary_state_as: avg
    name_position: below
    show_extrema: never
    tap_action:
      action: more-info
    aggregate_func: last
    show_state: false
  - entity: sensor.maandelijkse_cop_warmtepomp
    statistic_id: null
    name: Gemiddeld
    color: "#54b134"
    state_color: "#ffffff"
    state_size: "20"
    show_trend_icon: false
    show_line: false
    graph_type: bar
    align_state: center
    primary_state_as: last
    name_position: below
    show_extrema: never
    tap_action:
      action: more-info
    aggregate_func: last
    show_graph: false
    show_color_dot: true
    show_fill: false
annotations: []
grid_options:
  columns: 24
  rows: auto

Dagelijkse COP sensor (template a sensor):

{% set output = states('sensor.garage_blackbird_p80_heat_pump_dagelijks_warmtepomp_output') | float(0) %}
{% set input = states('sensor.garage_blackbird_p80_heat_pump_dagelijks_warmtepomp_input') | float(0) %}

{# 1. Jouw totale verwachte stand-by verbruik per 24 uur #}
{% set standby_per_dag = 0.2 %}

{# 2. Bereken hoeveel minuten van de dag (van de 1440) er al op zitten #}
{% set minuten_vandaag = (now().hour * 60) + now().minute %}
{% set fractie_van_dag = minuten_vandaag / 1440 %}

{# 3. Bereken het stand-by verbruik tot dit exacte moment #}
{% set standby_tot_nu = standby_per_dag * fractie_van_dag %}

{# 4. Haal dit actuele stand-by verbruik van de totale input af #}
{% set active_input = input - standby_tot_nu %}

{# 5. Bereken de COP, voorkom delen door nul of negatieve waarden #}
{% if active_input > 0.01 %}
  {{ (output / active_input) | round(2) }}
{% else %}
  0
{% endif %}

3. Bug Description

Hi all,

I'm trying to create a monthly graph that shows the average daily COP (Group by Day, Average).

The graph looks correct for the current day while the day is still in progress. For example, on July 7 the graph correctly showed an average COP of 3.6, which also matched the sensor value for that day.

However, when I check the graph the next day, the value for the previous day changes and is no longer correct. In the screenshot, July 7 now shows an average of 1.3, even though the sensor reported an average COP of 3.6 until the very end of the day.

The same thing is happening again today:

July 8 currently looks correct.
I expect that when I check tomorrow, the displayed average for July 8 will also be incorrect.

The underlying sensor data appears to be correct. Looking back at the sensor history shows that it reported the expected COP value throughout the entire day. This makes it seem like the issue is in how the graph recalculates or groups historical daily averages after the day has finished, rather than with the sensor data itself.

Image

Dagelijkse_COP_5min.txt
Dagelijkse_COP_1uur.txt
Dagelijkse_COP_1dag.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions