warberg
(Warberg)
September 7, 2023, 8:25pm
1
Hi
I have tried to create a horizontal line in my apex chart. The line should vary according to the value of an attribute. I get it to work for a fixed value of y: but not for the attribute. Can anyone figure out what I’m doing wrong?
apex_config:
annotations:
yaxis:
- 'y': {{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_0', 'average') | float }}
jchh
((not John))
September 7, 2023, 9:19pm
2
Try putting it in quotes as the template is on a single line
apex_config:
annotations:
yaxis:
- 'y': “{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_0', 'average') | float }}”
warberg
(Warberg)
September 8, 2023, 7:20am
3
Thank you, but it didn’t solve the issue.
It gives no errors but no line is visible. It also autocorrects the code to
- 'y': >-
{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_0', 'average') |
float }}
When in developer tools/Template, the following code works fine and returns a value.
{{ state_attr('sensor.nordpool_kwh_se3_sek_3_095_0', 'average') | float }}
Did you find a solution?
I tried to use the data_generator, but have not succeeded yet.
JSa1987
(JSa1987)
October 5, 2023, 11:18pm
5
Hello,
I’m also trying to achieve the same… Anybody managed to do this?
JSa1987
(JSa1987)
October 8, 2023, 3:42pm
6
I found a possible solution. Assuming that your chart shows the last 24 hrs of data you can use group_by
to select the last value in the 24 hrs bucket:
- entity: input_number.irrigation_rain_skip
group_by:
func: last
duration: 24h
type: area
This worked for my application.
andypnz
(Andrew Palmer)
December 31, 2023, 8:38pm
7
Did anyone find a solution?
This does not error, but does not work either
apex_config:
annotations:
yaxis:
- 'y': '{{states("sensor.30_min_anerage_electricity_profit_cost") }}'
borderColor: '#00E396'
borderWidth: 4
label:
text: mean
complex1
(Frank)
December 31, 2023, 9:13pm
8
Install the config-template-card card and try next:
type: custom:config-template-card
variables:
- '"sensor.electricity_price_today"'
- states["sensor.30_min_anerage_electricity_profit_cost"].state
entities: ${vars[0]}
card:
type: custom:apexcharts-card
[....]
apex_config:
annotations:
position: front
yaxis:
- 'y': ${vars[1]}
1 Like
jerker74
(Jerker Andersson)
September 11, 2024, 11:54am
10
I want to have a slide value controlling a horisontal line in my apex chart and I cant get it to work. No matter the value of the slide it will always be a line at the top of the y axis. If I hard code the value it will be correct. In this case the line should be at 0.1.
type: custom:apexcharts-card
now:
show: true
label: NU
graph_span: 48h
apex_config:
annotations:
yaxis:
- 'y': input_number.prisgrans_laddning
borderColor: red
label:
borderColor: red
style:
color: '#fff'
background: red
text: Laddgräns
plotOptions:
bar:
borderRadius: 2
yaxis:
align_to: 0
decimalsInFloat: 2
tickAmount: 5
forceNiceScale: true
xaxis:
labels:
datetimeFormatter:
hour: HH
all_series_config:
extend_to: false
show:
offset_in_name: true
header:
title: Dagens & morgondagens spotpris
show: true
show_states: true
colorize_states: true
span:
start: day
offset: +0h
series:
- entity: sensor.nordpool_kwh_se3_sek_3_10_0
type: column
color: green
float_precision: 3
stroke_width: 2
name: Dagens timpris
show:
in_header: false
legend_value: false
extremas: true
data_generator: |
return entity.attributes.raw_today.map((start, index) => {
return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"]];
});
- entity: sensor.nordpool_kwh_se3_sek_3_10_0
type: column
color: yellow
float_precision: 3
stroke_width: 2
name: Morgondagens timpris
show:
in_header: false
legend_value: false
extremas: true
data_generator: |
return entity.attributes.raw_tomorrow.map((start, index) => {
return [new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"]];
});
- entity: sensor.nordpool_kwh_se3_sek_3_10_0
name: Timpris just nu
color: green
type: column
show:
in_chart: false
float_precision: 3
- entity: sensor.nordpool_kwh_se3_sek_3_10_0
attribute: average
type: column
color: pink
float_precision: 3
stroke_width: 2
name: Dagens snittpris
group_by:
duration: 2d
show:
in_chart: false
legend_value: false
- entity: sensor.nordpool_kwh_se3_sek_3_10_0
attribute: max
type: column
color: orange
float_precision: 3
stroke_width: 2
name: Dagens högsta pris
group_by:
duration: 2d
show:
in_chart: false
legend_value: false
- entity: sensor.nordpool_kwh_se3_sek_3_10_0
attribute: min
type: column
color: green
float_precision: 3
stroke_width: 2
name: Dagens lägsta pris
group_by:
duration: 2d
show:
in_chart: false
legend_value: false
Guidau
(Guidau)
October 12, 2024, 5:46pm
11
Have you found a solution?