Add Cards/Apexcharts/El priser per time

This commit is contained in:
2026-08-21 15:41:50 +02:00
parent a22699baeb
commit f434d5d09e

View File

@@ -0,0 +1,209 @@
type: grid
columns: 1
square: false
cards:
- type: grid
columns: 1
square: false
cards:
- type: custom:apexcharts-card
apex_config:
chart:
height: 350
header:
title: Elpriser pr. time (dynamiske farver)
show: true
show_states: false
graph_span: 48h
now:
show: true
label: Nu
span:
start: day
all_series_config:
unit: ' kr.'
yaxis:
- min: 0
apex_config:
tickAmount: 6
series:
- entity: sensor.energi_data_service
name: Billig
type: column
color: '#4CAF50'
show:
legend_value: false
data_generator: >
let data = [];
const avg = entity.attributes.today_mean;
const greenLimit = avg * 0.8;
let prices = entity.attributes.raw_today || [];
if (entity.attributes.tomorrow_valid &&
entity.attributes.raw_tomorrow) {
prices = prices.concat(entity.attributes.raw_tomorrow);
}
prices.forEach(item => {
const p = item.price;
data.push([
new Date(item.hour).getTime(),
p < greenLimit ? p : null
]);
});
return data;
- entity: sensor.energi_data_service
name: Normal
type: column
color: '#FFEB3B'
show:
legend_value: false
data_generator: >
let data = [];
const avg = entity.attributes.today_mean;
const greenLimit = avg * 0.8;
const orangeLimit = avg * 1.2;
let prices = entity.attributes.raw_today || [];
if (entity.attributes.tomorrow_valid &&
entity.attributes.raw_tomorrow) {
prices = prices.concat(entity.attributes.raw_tomorrow);
}
prices.forEach(item => {
const p = item.price;
data.push([
new Date(item.hour).getTime(),
(p >= greenLimit && p < orangeLimit) ? p : null
]);
});
return data;
- entity: sensor.energi_data_service
name: Dyr
type: column
color: '#FF9800'
show:
legend_value: false
data_generator: >
let data = [];
const avg = entity.attributes.today_mean;
const orangeLimit = avg * 1.2;
const redLimit = avg * 1.5;
let prices = entity.attributes.raw_today || [];
if (entity.attributes.tomorrow_valid &&
entity.attributes.raw_tomorrow) {
prices = prices.concat(entity.attributes.raw_tomorrow);
}
prices.forEach(item => {
const p = item.price;
data.push([
new Date(item.hour).getTime(),
(p >= orangeLimit && p < redLimit) ? p : null
]);
});
return data;
- entity: sensor.energi_data_service
name: Meget dyr
type: column
color: '#F44336'
show:
legend_value: false
data_generator: >
let data = [];
const avg = entity.attributes.today_mean;
const redLimit = avg * 1.5;
let prices = entity.attributes.raw_today || [];
if (entity.attributes.tomorrow_valid &&
entity.attributes.raw_tomorrow) {
prices = prices.concat(entity.attributes.raw_tomorrow);
}
prices.forEach(item => {
const p = item.price;
data.push([
new Date(item.hour).getTime(),
p >= redLimit ? p : null
]);
});
return data;
- entity: sensor.elpriser_excl_afgift
name: Excl. afgifter
type: line
color: '#03A9F4'
stroke_width: 4
extend_to: false
show:
extremas: true
legend_value: false
data_generator: |
let data = [];
if (entity.attributes.raw_today) {
data = entity.attributes.raw_today.map((item) => [
new Date(item.hour).getTime(),
item.price
]);
}
if (entity.attributes.tomorrow_valid &&
entity.attributes.raw_tomorrow) {
data = data.concat(
entity.attributes.raw_tomorrow.map((item) => [
new Date(item.hour).getTime(),
item.price
])
);
}
return data;
grid_options:
rows: auto
columns: full
grid_options:
rows: auto
columns: full