Skip to content

texttemplate - display a calculated extra entity value #359

Answered by gregmc2023
gregmc2023 asked this question in Q&A
Discussion options

You must be logged in to vote

Well, I don't understand why, in customdata, y returned the first value rather than the last value, but ys[ys.length - 1] did the trick.
Here's where I ended up:

type: custom:plotly-graph
entities:
  - entity: sensor.wattpilot_totally_charged
    statistic: sum
    period: 5minute
    showlegend: false
    filters:
      - map_y_numbers: (y - ys[0])/1000
    name: Energy added
    unit_of_measurement: ' '
    show_value: true
    customdata: |
      $ex ys.map(y => ({ extra_attr: ys[ys.length - 1]/80 * 100 }) )
    texttemplate: <b> %{y:.1f} kWh</b> <br> %{customdata.extra_attr:.0f} %
hours_to_show: 168
layout:
  height: 250
  margin:
    r: 200
    l: 40
    t: 50

Thanks again for your…

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@gregmc2023
Comment options

Comment options

You must be logged in to vote
1 reply
@gregmc2023
Comment options

Comment options

You must be logged in to vote
4 replies
@dbuezas
Comment options

@gregmc2023
Comment options

@dbuezas
Comment options

@gregmc2023
Comment options

Answer selected by gregmc2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants