I only just realized that “days_back” can be misunderstood.
As is, it isn’t showing the number of days including today. So if you select 1, it should show today. If you select 2, it should be today and yesterday. Played around but did not manage to get it working. I would have thought that the offset would need to be 0 to display the current day. But maybe that is not as easy as in this case the graph_span would show time in the future with no data (which would be the correct way to display it, but maybe causes a code error?).
So I am guessing that the “offset” would need to be conditional?
I am not really sure, since I am not using it myself.
Have a look at the apex chart card documentation to find out more information regarding the offset option.
I looked at the start, end and offsetoptions before posting and I did not see anything useful. But I think that the approach might need to be changed. Rather than using just the offset, maybe one needs to adjust the graph_span also?
So I think it has to be
card:
type: custom:apexcharts-card
graph_span: ${days}
span:
start: day
offset: 1-${days}
But my offset syntax is wrong. Sorry, I am still not quite familiar with the templating syntax used by HA and find it quite counter-intuitive
P.S.: I did test it, btw, and the approach works. Just the offset syntax needs fixing
If you want to display the current day, would’n it be simpler to add ‘0’ as an option in the input_select?
Then if you choose ‘0’ it would show today, ‘1’ yesterday and so on…
This way you don’t have to change the code.
No, not really, because I almost always want to see today versus a different day. So the present day always needs to be part of it.
If I add 0, then I only add today but never can I see today and x days back.
I was wondering: is this not kind of the wrong way around?
Auto entities could create the list of available areas, eliminating the need to create an input_select for areas.
So would it not be possible to use auto entities to populate an areas dropdown which then serves as variable to the next card?
Hi there,
I’m using this code and all is working like a charm! Thanks a lot!
I’m trying to set a friendly name for the options of my input_select.
Now the dropdown list shows f.e. sensor_temperature_kitchen… i wolud display “Kitcken”…
How to solve?? Thanks a lot.
Was REALLY happy about this until I found that the config-template-card doesn’t update live like the native cards wrapped in it (in my case, mini-graph-cards). The duration change reflects instantly contrary to one other report, but the sensors themselves don’t update anymore after that without another duration change or manual refresh