I wanted to have the electricity prices displayed on the home panel. I used HACS, nordpool and apexchard-cards. Theres numerous implementations of this, but didn’t find any that suited my preferences, so here’s what I ended up with:
The only limitation is that I haven’t found a way to adjust the grid charge for holidays. The workday sensor is binary, and the apexchart-cards don’t support that.
type: custom:apexcharts-card
stacked: false
header:
show: true
title: Strømprisen
show_states: true
colorize_states: false
now:
show: true
label: Nå
graph_span: 24h
span:
start: hour
offset: '-6h'
apex_config:
xaxis:
labels:
format: HH
show: true
chart:
height: 300px
zoom:
enabled: false
toolbar:
show: false
tools:
zoom: false
zoomin: false
zoomout: false
pan: false
reset: true
tooltip:
fixed:
enabled: true
position: topLeft
series:
- entity: sensor.nordpool
name: Pris inklusiv nettleie
type: column
color: orange
opacity: 0.5
extend_to: end
float_precision: 1
show:
in_header: before_now
in_chart: true
legend_value: false
extremas: true
data_generator: |
const rawToday = entity.attributes.raw_today || [];
const rawTomorrow = entity.attributes.raw_tomorrow || [];
const combinedData = [...rawToday, ...rawTomorrow];
return combinedData.map((entry, index) => {
// Nettleie price from Elvia 2023/24
const summerDay = 44.4;
const summerNight = 37.3;
const winterDay = 35.2;
const winterNight = 28.95;
// Declare variables
var nettleie = 2;
var currentDate = new Date(entry.start);
var currentMonth = currentDate.getMonth();
var summer;
var dayTime;
var weekend;
var holiday; //Needs to find a way to check this agains binary_sensor.workday_sensor
// Findt if it's day,night,summer, winter, weekend and hour(index)
if (currentMonth > 3) { summer = true } else { summer = false }
if (index > 5 && index < 22) { dayTime = true } else { dayTime = false }
if (currentDate.getDay() == 0 || currentDate.getDay() == 6) { weekend = true } else { weekend = false }
//Summer prices
if (dayTime && summer && !weekend) { nettleie = summerDay }
else if (!dayTime && summer && !weekend) { nettleie = summerNight }
else if (summer && weekend) { nettleie = summerNight }
// Winter prices
else if (dayTime && !summer && !weekend) { nettleie = winterDay }
else if (!dayTime && !summer && !weekend) { nettleie = winterNight }
else if (!summer && weekend) { nettleie = winterNight }
return [new Date(entry.start), entry.value + nettleie];
});
- entity: sensor.nordpool
name: Pris nå
type: column
curve: stepline
extend_to: end
float_precision: 1
opacity: 1
stroke_width: 3
color: blue
show:
in_header: before_now
in_chart: true
legend_value: false
extremas: true
datalabels: false
data_generator: |
const rawToday = entity.attributes.raw_today || [];
const rawTomorrow = entity.attributes.raw_tomorrow || [];
const combinedData = [...rawToday, ...rawTomorrow];
return combinedData.map((time) => {
//return entity.attributes.raw_today.map((p) => {
return [new Date(time.start), time.value];
});
yaxis:
- min: 0
max: auto
decimals: 0
apex_config:
tickAmount: 4