generated from custom-cards/boilerplate-card
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Hello,
I have already installed a number of well-functioning plotly graphs. I like them very much. The software is very powerful. Now I have a problem with which I can't find a solution. Chatgpt also only turns in circles.
I have the following graph configuration:
type: custom:plotly-graph
title: PV-Überschuss-Management
defaults:
entity:
show_value: true
yaxes:
yaxes: null
fixedrange: true
autorange: true
side: left
overlaying: "y"
visible: true
showgrid: true
hours_to_show: current_day
refresh_interval: 10
min_y_axis: -50
max_y_axis: 10000
entities:
- entity: sensor.wp_hp1_inverter_power_consumption
yaxis: y1
name: |
$ex {
return (
"WP-Elektr. Leistg. "
+ "<span style='font-size: 16px; color: rgb(70 130 180)'>"
+ ys[ys.length - 1].toFixed(0)
+ " W </span>"
)
}
showlegend: true
statistic: mean
filters:
- map_y: "y < 0 ? 0 : (1 * y)"
extend_to_present: false
period: 5minute
fill: null
fillcolor: rgba(70, 130, 180, 0.5)
line:
color: rgba(70, 130, 180, 1)
width: 2
- entity: sensor.wp_emgr_power_consumption_setpoint
yaxis: y1
show_value: true
name: Soll
showlegend: true
filters:
- map_y: "y < 0 ? 0 : (1 * y)"
extend_to_present: false
fill: null
fillcolor: rgba(0, 0, 205, 0.5)
line:
color: rgba(0, 0, 205, 1)
width: 2
- entity: sensor.wp_aussentemperatur
yaxis: y2
name: |
$ex {
return (
"Außen "
+ "<span style='font-size: 16px; color: rgb(154 205 50)'>"
+ ys[ys.length - 1].toFixed(1)
+ " °C</span>"
)
}
showlegend: true
show_value: true
statistic: mean
filters:
- map_y: "y < -50 ? null : (1 * y)"
extend_to_present: false
period: 5minute
fill: null
fillcolor: rgba(154, 205, 50, 0.5)
line:
color: rgba(154, 205, 50, 1)
width: 2
layout:
height: 600
grid:
rows: 2
columns: 1
roworder: top to bottom
yaxis:
title:
text: W
yaxis2:
title:
text: °C
shapes:
- type: line
name: |
$ex {
var aktDate = new Date(); //Date.now();
var aktHour = aktDate.getHours();
var strAktHour = "0" + aktHour
strAktHour = strAktHour.substr(strAktHour.length - 2)
var aktMinute = aktDate.getMinutes();
var strAktMinute = "0" + aktMinute
strAktMinute = strAktMinute.substr(strAktMinute.length - 2)
var strHM = strAktHour + ":" + strAktMinute
return (
"Akt. Zeitpunkt "
+ [strHM] + " "
)
}
showlegend: true
x0: $ex Date.now()
x1: $ex Date.now()
y0: 0
y1: 1
xref: x
yref: paper
line:
color: grey
dash: dot
width: 2
This works perfectly. The graph is displayed well. The last value is also displayed right of the line.

But when I change the "name"-configuration
from
- entity: sensor.wp_emgr_power_consumption_setpoint
yaxis: y1
show_value: true
name: Soll
to
- entity: sensor.wp_emgr_power_consumption_setpoint
yaxis: y1
show_value: true
name: |
$ex {
return (
"Soll (WP-El. Leistg.) "
+ "<span style='font-size: 16px; color: rgb(0 0 205)'>"
+ ys[ys.length - 1].toFixed(1)
+ " W </span>"
)
}
there is an error "Error: at [entitsits.1name]: ys.length -1)]. Tofixed is not a function" -> See picture:

I have already tried everything, for example the test of "undefined" or "null"..., but it doesn't work. What can I do?
Thank You
Thomas
Metadata
Metadata
Assignees
Labels
No labels