im trying to create a bar graph with a span of a year and monthly summary. Im using a custom state measurement entity wthich count our laundry. My problem is when I set “type to state” under the statistics series no value is available and wont show. If I remove this setting, it shows me correctly the last value of the month, but not the current value during the month:
Hi Oliver,
thanks for your reply, that was really helping a lot. I think in my case I did the mistake that I didnt worked with a “utility meter” helper. I just created a custom sensor with measurement state class and tried to use that. Your thread bring me to the right point I just have to wait for the end of the month to see if the apexchart will display my values correctly like I want
Did you ever resolve this ? I have the same problem, the apex-chart, only shows results for the current month, but all results for the year is in the database.
I think you need to use LTS (long term statistics) if you want to show data that far back. HA will purge data from the recorder after 10 days (default). You can change this but it impacts performance so its not advised.
You can combine group_by and statistics in apexcharts and that works well for daily data grouped by day or week (7 days). I am working on same approach for monthly (daily stats grouped by month) but I am having trouble.
I am also working on a new solution and that is to create a LTS monthly sensor (refer to the History Statistics integration to see how to do this).
below are my weekly and monthly views + example yaml (using daily statistics grouped).
For this to work, you need to reset the statistics sensor at 12am each day. like this…
This is exactly the view I want, but the whole configuration drops statistics and I dont understand why. You can see theres no data for june. Im using utility meter helpers as sensor for this graph. When anybody would tell me how I can create LTS for a utility helper entitiy, I would appreciate your help
Okay so when I understand the LTS feature correctly, I only have to set a unit of measurement and the data should be available in the long term stats.
This is definitely true for my case. Both sensors I am using are custom utility meters entities from helpers created from the gui and both show me under the dev tools the unit of measurement is count.
So why it’s dropping or not display the stats it’s the question?!
Yesterday I was updating home assistant to the latest version and now the stats from July will not be displayed any more. When I look under the dev tools and pick up the utility meter I see that there is the last period still available as value.
I’m sorry that I’m not any help here, as I struggle with the same issue, and my database only purges every 6 months. I’ll keen on trying to figure this out.
Does not work for me… it report 0. I’m using daily energy counters. Long terms statistics seems to work because i can see them in default HA statistics graph.
Any idea?
It looks to me that this was fixed in any release. I have now the full statistics available for the last 3 month and it does not drop it anymore. The values also survived several home assistant updates, so maybe this was in any release fixed.
I don’t know yet, as I did a fatal upgrade from 2022.06 to 2023.12 in december. let’s just say with a Top Gun saying - it crashed and burned… LOL
So ealy january I started to reconfigure from scratch, whitch is now finally working as intended - always a fun time spend…
I therefore only have two months worth of data, but can confirm that these are showing. I’m exited to see if this continues and I get the full 6 months of data eventually, but from what you’re stating, it looks like it.
Hi.
I’m not able to retrieve statistics data with apexcharts-card. When using statistics configuration for the chart, data is not loaded and graph gets stuck. If I remove statistics from YAML, everything works fine - but without LTS statistics on chart.
Any idea how could I fix it?
type: custom:apexcharts-card
graph_span: 15d
span:
end: day
apex_config:
chart:
height: 150px
experimental:
color_threshold: true
show:
last_updated: false
header:
show: true
show_states: true
colorize_states: true
title: Consumo Diário de Energia
yaxis:
- min: 0
max: auto
decimals: 2
apex_config:
tickAmount: 5
title:
text: kWh
series:
- entity: sensor.consumo_energia_diario_kwh
statistics:
type: max
period: day
group_by:
func: max
duration: 1d
show:
header_color_threshold: true
extremas: false
datalabels: false
color: '#3170EE'
type: column
float_precision: 2
name: Consumo por mês
I found this thread while searching for a way to show the solar production for every month for the last year. been using your code (big thanks!) but the past month isn’t displayed correctly. I am using a helper to count the produced kWh and it resets every first day of the new month. Do I need to make changes to the helper or is it something in the code that is wrong? Tried some stuff for the code, but nothing worked