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
74.18k stars 31.15k forks source link

Max value does not update in December if set to "this Year" and this year is Leap year #132156

Open peteh opened 22 hours ago

peteh commented 22 hours ago

The problem

I track some measurements in homeassistant and show the max value as well. I use the statistic card to show the max value for the current year.

However it seems like theses don't update anymore during December - the last update was in November

core-2024.11.3 and core-2024.11.4 both seem to be at least affected

What version of Home Assistant Core has the issue?

core-2024.11.4

What was the last working version of Home Assistant Core?

Based on further analysis, this might have never worked

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Not sure if it's an integration I'm using the statistics card to show the max value image

However it does not update anymore since about a month and it's current value is higher: image

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

When I set to "this month" it works - the current value is shown. Is December not counted into "this year" maybe? Could be some < and <= issue somewhere

I also found a workaround for the yaml config of the statistic card:

type: statistic
period:
  fixed_period:
    start: 2024-01-01
    end: 2024-12-31
stat_type: max
name: Depot Gains ATH
entity: sensor.xxx
layout_options:
  grid_columns: 4
  grid_rows: 2

This counts from 1st of Jan to end of December and gives the correct value. So I'm relatively certain that the calculation for "this year" does not include December. I haven't found the right place in the code to double check though.

Additional information

No response

peteh commented 20 hours ago

Went down the rabbit hole and fixed it. The PR is attached to this issue.