Skip to content

Please help, when displaying the value of entity #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
thoath2 opened this issue Mar 2, 2025 · 0 comments
Open

Please help, when displaying the value of entity #542

thoath2 opened this issue Mar 2, 2025 · 0 comments

Comments

@thoath2
Copy link

thoath2 commented Mar 2, 2025

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.

Image

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:

Image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant