Hei @sbarmen - veldig fin chart du har satt sammen her 😊
Prøvde å legge inn nå, men får følgende feilmelding:
/// apexcharts-card version 2.1.2 /// value.series[0] is not a ChartCardSeriesExternalConfig; value.series[0].color_threshold[0] is not a ChartCardColorThreshold; value.series[0].color_threshold[0].value is missing
type: custom:apexcharts-card
experimental:
color_threshold: true
header:
show: true
title: Strømpris og Forbruk
show_states: true
standard_format: true
colorize_states: true
now:
show: true
label: Nå
graph_span: 2d
span:
start: day
apex_config:
dataLabels:
enabled: true
legend:
show: true
chart:
height: 210px
yaxis:
- id: price
show: true
decimalsInFloat: 0
floating: false
forceNiceScale: true
extend_to: end
- id: usage
show: true
opposite: true
decimalsInFloat: 0
floating: false
forceNiceScale: true
extend_to: end
series:
- entity: sensor.nord_pool_no3_current_price
yaxis_id: price
extend_to: now
name: Pris
unit: ' øre/kWh'
stroke_width: 1
type: area
curve: stepline
float_precision: 0
color: '#db4437'
color_threshold:
- color: '#42a047'
- color: '#ffa600'
- color: '#db4437'
show:
legend_value: false
in_header: before_now
data_generator: >
return (entity.attributes.raw_today.map((start, index) => { return [new
Date(start["start"]).getTime(),
entity.attributes.raw_today[index]["value"]];
})).concat(entity.attributes.raw_tomorrow.map((start, index) => { return
[new Date(start["start"]).getTime(),
entity.attributes.raw_tomorrow[index]["value"]]; }));
- entity: sensor.tibber_pulse_hjem_accumulated_consumption_current_hour
yaxis_id: usage
type: column
name: Forbruk
stroke_width: 2
invert: false
group_by:
func: max
show:
legend_value: false
Klarer du å se hvorfor?
Mener jeg har lagt inn sensorene riktig. Men ser Nor Pool ikke har mean price-sensor, så la inn annen sensor i stedet.
Her er koden jeg la inn:
type: custom:config-template-card
variables:
sensor_price: "\"sensor.nord_pool_no3_current_price\""
sensor_usage: "\"sensor.tibber_pulse_hjem_accumulated_consumption_current_hour\""
low_price: states['sensor.nord_pool_no3_lowest_price'].attributes.min
high_price: states['sensor.nord_pool_no3_highest_price'].attributes.max
mean_price: states['sensor.nord_pool_no3_next_price'].attributes.mean
current_price: states['sensor.nord_pool_no3_current_price'].state
state_color: |
(low, high, current) => {
const range = high - low;
const third_low = low + range / 3;
const third_high = high - range / 3;
if (current <= third_low) {
return '#42a047'; // Grønn
} else if (current <= third_high) {
return '#ffa600'; // Oransje
} else {
return '#db4437'; // Rød
}
}
entities:
- ${sensor_price}
card:
type: custom:apexcharts-card
experimental:
color_threshold: true
header:
show: true
title: Strømpris og Forbruk
show_states: true
standard_format: true
colorize_states: true
now:
show: true
label: Nå
graph_span: 2d
span:
start: day
apex_config:
dataLabels:
enabled: true
legend:
show: true
chart:
height: 210px
yaxis:
- id: price
show: true
decimalsInFloat: 0
floating: false
forceNiceScale: true
extend_to: end
- id: usage
show: true
opposite: true
decimalsInFloat: 0
floating: false
forceNiceScale: true
extend_to: end
series:
- entity: ${sensor_price}
yaxis_id: price
extend_to: now
name: Pris
unit: " øre/kWh"
stroke_width: 1
type: area
curve: stepline
float_precision: 0
color: ${state_color(low_price, high_price, current_price)}
color_threshold:
- value: ${low_price}
color: "#42a047"
- value: ${mean_price}
color: "#ffa600"
- value: ${high_price}
color: "#db4437"
show:
legend_value: false
in_header: before_now
data_generator: >
return (entity.attributes.raw_today.map((start, index) => { return [new
Date(start["start"]).getTime(),
entity.attributes.raw_today[index]["value"]];
})).concat(entity.attributes.raw_tomorrow.map((start, index) => { return
[new Date(start["start"]).getTime(),
entity.attributes.raw_tomorrow[index]["value"]]; }));
- entity: ${sensor_usage}
yaxis_id: usage
type: column
name: Forbruk
stroke_width: 2
invert: false
group_by:
func: max
show:
legend_value: false