Well it turned out that I did not look deep enough, or actually in the structure. The 2nd list is under a "next" level, so by just adding another data_generator I fixed it kind of - however if anyone has a better solution please let me know. I am still new to this kind of programming.
For reference here is the latest code that gives me what I was looking for:
type: custom:apexcharts-card
experimental:
color_threshold: true
apex_config:
legend:
show: false
xaxis:
labels:
datetimeFormatter:
hour: HH
tooltip:
fixed:
enabled: true
position: topLeft
graph_span: 2d
show:
last_updated: true
header:
title: Elkostnad och nyttjande
show: true
show_states: true
colorize_states: true
span:
start: day
now:
show: true
series:
- entity: binary_sensor.test_billigaste_tid
name: Cheapest
type: area
curve: stepline
yaxis_id: kWh
opacity: 0.6
stroke_width: 0
color: lightgreen
show:
extremas: false
in_header: false
data_generator: |
let data = [];
let periods = entity.attributes.list || [];
periods.forEach((p) => {
let s = new Date(p.start).getTime();
let e = new Date(p.end).getTime();
data.push([s, 1]); // jump up at start
data.push([e, 1]); // stay high until end
data.push([e, 0]); // drop straight down
});
return data;
- entity: binary_sensor.test_billigaste_tid
name: Cheapest
type: area
curve: stepline
yaxis_id: kWh
opacity: 0.6
stroke_width: 0
color: lightgreen
show:
extremas: false
in_header: false
data_generator: |
let data = [];
let periods = entity.attributes.next.list || [];
periods.forEach((p) => {
let s = new Date(p.start).getTime();
let e = new Date(p.end).getTime();
data.push([s, 1]); // jump up at start
data.push([e, 1]); // stay high until end
data.push([e, 0]); // drop straight down
});
return data;
- entity: binary_sensor.cheapest_hours
name: Cheapest
type: area
curve: stepline
yaxis_id: kWh
opacity: 0.9
stroke_width: 0
color: lightgray
show:
extremas: false
in_header: false
data_generator: |
let data = [];
let periods = entity.attributes.list || [];
periods.forEach((p) => {
let s = new Date(p.start).getTime();
let e = new Date(p.end).getTime();
data.push([s, 1]); // jump up at start
data.push([e, 1]); // stay high until end
data.push([e, 0]); // drop straight down
});
return data;
- entity: binary_sensor.cheapest_hours
name: Cheapest
type: area
curve: stepline
yaxis_id: kWh
opacity: 0.9
stroke_width: 0
color: lightgray
show:
extremas: false
in_header: false
data_generator: |
let data = [];
let periods = entity.attributes.next.list || [];
periods.forEach((p) => {
let s = new Date(p.start).getTime();
let e = new Date(p.end).getTime();
data.push([s, 1]); // jump up at start
data.push([e, 1]); // stay high until end
data.push([e, 0]); // drop straight down
});
return data;
- entity: sensor.electricity_prices_today
yaxis_id: SEK
type: line
show:
extremas: false
in_header: false
float_precision: 3
stroke_width: 3
extend_to: false
color: green
color_threshold:
- value: 1.5
color: blue
- value: 2
color: green
- value: 2.5
color: yellow
- value: 3
color: orange
- value: 3.5
color: red
- value: 4
color: pink
- value: 5
color: "#ffffff"
data_generator: |
const data = entity.attributes.data.map((entry) => {
// Center each 15-minute period correctly
const start = new Date(entry.start).getTime();
const end = new Date(entry.end).getTime();
const midpoint = start + (end - start) / 2;
return [midpoint, entry.value];
});
return data;
- entity: sensor.electricity_prices_tomorrow
yaxis_id: SEK
type: line
show:
extremas: false
in_header: false
float_precision: 3
stroke_width: 3
extend_to: false
color: green
color_threshold:
- value: 1.5
color: blue
- value: 2
color: green
- value: 2.5
color: yellow
- value: 3
color: orange
- value: 3.5
color: red
- value: 4
color: pink
- value: 5
color: "#ffffff"
data_generator: |
const data = entity.attributes.data.map((entry) => {
// Center each 15-minute period correctly
const start = new Date(entry.start).getTime();
const end = new Date(entry.end).getTime();
const midpoint = start + (end - start) / 2;
return [midpoint, entry.value];
});
return data;
- entity: sensor.shellypro3em_ece334eddd28_total_active_power
yaxis_id: kWh
name: Power Usage Chart
color: orange
opacity: 0.8
float_precision: 2
show:
extremas: false
in_header: true
type: line
curve: stepline
stroke_width: 1
extend_to: false
unit: kW
transform: return x /1000;
group_by:
func: avg
duration: 15m
- entity: sensor.electricity_prices_today
name: Current Price
yaxis_id: SEK
float_precision: 3
show:
in_header: true
in_chart: false
unit: Kr/kWh
color: green
yaxis:
- id: SEK
min: 0
max: ~6
opposite: true
apex_config:
tickAmount: 6
forceNiceScale: true
title:
text: SEK
- id: kWh
min: 0
max: ~4
apex_config:
tickAmount: 6
forceNiceScale: true
title:
text: kWh
I wonder how many of the issues raised in your repo (33 open, ranging from 2021 to last week) could be solved already in my fork. Probably quite some.
Anyway, I think it's appropriate to have HACS ship my repo instead of yours, since mine has all you have, plus updates and fixes.
Before contacting HACS I am required to ask for your feedback.
Can you give the green light, or a reasoned statement if declining the proposal? In a week time I will proceed with an official request to HACS with a link to this post.
According to the docs, setting max to "~40" should set a soft limit that is overridden if the series contains values above that, but that isn't working.
If I set max to "auto" then it autoscales to a max of 29 (which is even more wrong) and "|+10|" autoscales to 39, so it seems clear that the problem is that the value calculated for auto-scaling is wrong, and both "~40" and "|+10|" rely on that value, so neither works correctly.
Have you tried asking a LLM about it, providing the full YAML and the link to the apexcharts card? Be sure to use more than the basic model (free tier gpt-4.1 or gemini-flash are not that good) and to enable "web search" if applicable.
Also, it would be good for a support request like yours to actually take a screenshot where the tooltip shows the peak value is shown to be higher than the Ymax...
stepSize seems to be not working when using soft bound for the max value. At first I tought it would generally not work, but then I found, that it just the upper soft bound that fives the problem.
These do not work (just give random y axis labels as if nothing is configured)
hi,
great you are working on this resource, and developing it beyond its current capabilities
personally I find your request a bit unnecessarily blunt to Romrider, as he has no reason at all to retract his resource, simply because not having updated for a while.
Itās how things are.
a deadline like this is even more upsetting to me, let alone the author. In a week? Come on, letās all be reasonable here.
besides, what do you think is the round time of a FR in HACSā¦
You are perfectly free to also upload your version, and proceed from there. I believe the community could welcome development of the apexcharts card indeed
this of course has to be seen, so why not just jump in and try to do so.
Id welcome the new card for sure, if indeed it would fix those few issues/frās.
I raised a few myself, and would love to get those fixed, but that is not my point for this post.
WOW! This is IT. The card weāve been waiting for. Brilliant! THANK YOU! @cataseven
I cannot believe that nobody have seen the need for this type of card ⦠I thought āitās me.. and not youā
Only had a quick look and browse through the documentation. Need to test this properly. Trying to fugure och if there is an opton to use a ādata generatorā to grab from InfluxDBā¦
Iām having issues displaying the labels for my weekly cost card. The first is nearly right, except the last bucket is missing the label. While the second attempt brings back the label but as the location is offset, they donāt sit right under the bars. Any help please.
If you are a user of HACS and you look for apexcharts card, would you want to find an entry with a card unmaintained for more than 6 months?
Iām happy to help maintain the card, but there was no reply so I forked. Proposing to replace the one in HACS is not meant to be impolite, itās meant to help the actual users.
Yeah I didnāt take any action.
My card is going forward, but having it on HACS would imply more constant involvement on my part so Iāll do it later when I have more time.
Feel free to switch to my fork (it has nothing less than the original one, only improvements so itās a safe switch) and then if the issue persists Iāll be happy to give it a look.
However Iām thinking about having a āhomework firstā policy: tickets for issues should come with the output of a LLM provided with all the information and asked about potential causes of the issue, and proposals for solutions, to reduce my work.