Plotly interactive Graph Card

  1. Search for legendonly in the discussions section of the repo
  2. Search for show_value in the repo’s readme
  3. Leave a star if you succeed :slight_smile:
2 Likes

I got this issue with high frequency values (high volume/very granular measurement intervals) limiting the ability to show the plot on my Ipad dashboard, it shows up on my PC (after a delay of a few seconds) but that has of course more horsepower than the ipad so I guess it’s the amount of values it’s trying to show which is causing the hickup.

The issue is related to “sensor.total_momentary_active_import” and it creates a new value every 10 seconds. Is there a way to limit this through a filter in plotly or do I need to create a template/filter function and use that entity instead?

type: custom:plotly-graph
entities:
  - entity: sensor.total_momentary_active_import
    name: Förbrukning
    unit_of_measurement: kW
    fill: tozeroy
    line:
      color: green
    width: 3
  - entity: sensor.electricity_spot_price_total
    name: Nordpool Pris
    unit_of_measurement: SEK/kWh
    fill: tozeroy
    fillcolor: rgba(215, 200, 200, 0.1)
    line:
      color: orange
layout:
  dragmode: pan
  margin:
    t: 30
    l: 45
    r: 40
    b: 50
  xaxis:
    tickmode: linear
    rangeselector:
      'y': 1.2
      buttons:
        - count: 1
          step: day
        - count: 7
          step: day
hours_to_show: 168
defaults:
  entity:
    lambda: |-
      (ys, xs)=>({
        y:ys.filter(y=>!Number.isNaN(parseFloat(y))),
        x:xs.filter((x,i)=>!Number.isNaN(parseFloat(ys[i]))),
      })

1 Like

:wave: you can extend your filters
x:xs.filter((x,i)=>i%5==0 && !Number.isNaN(parseFloat(ys[i]))),
(Take only every fifth data point)

And the same in the y axis.
The card will still fetch all data, but plotting should be faster

I tried this but it just altered the graph to represent a completely different envelope on the curve.

image

What I’m going to try now is to use the built in filter function in the HA config file instead, not sure which one will work so I will try both:

#Filtered Power usage
  - platform: filter
    name: "energy0"
    entity_id: sensor.total_momentary_active_import
    filters:
      - filter: outlier
        window_size: 4
        radius: 2.0
      - filter: lowpass
        time_constant: 10
      - filter: time_simple_moving_average
        window_size: 168:00
        precision: 2

  - platform: filter
    name: "energy1"
    entity_id: sensor.total_momentary_active_import
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2  

hi, a follow up question - is there a way to limit precision on show_value ?

EDIT:
Actually, scrap that - I started diving into discussions on project github page and I see some fascinating solutions ! again, MANY THANKS for this awesome card !

EDIT 2:
So I’ve tried:

And this is the results that I get in legend:

Any ideas why name formatting doesn’t work ?

1 Like

@mateine Any ideas why the name thing doesn’t work for me while it worked for some people in your repo discussion ?

Hey Tom,
To use templates in yaml like that you need yet another component from HACS. You’ll have to dig in the text of that discussion :slight_smile:

I shall, thanks !

Thanks for creating Plotly. Bringing my UI to life.

Being new in HA I’m still finding my feet.

Is it Possible to include entity data in the Graph title?
For instance Master Bedroom Humidity 62%

Thanks
-s

1 Like

Oh, I didn’t create Plotly, that’s a huge project developed by a Canadian company of the same name. They’ve been around for 10 years!
I only introduced it to home assistant, and I agree they make a wonderful couple :slight_smile:

To put state data into the title you can use a second custom card: GitHub - iantrich/config-template-card: 📝 Templatable Lovelace Configurations

Search for “template” in the discussions section of this card’s repo for examples

Not because I think it should be fixed, but just because it’s fun to see: Plotly does not know how to handle summer time changes very well :crazy_face:


Most baffling is that there’s 3 lines, probably it traced back when the time was set back.

2 Likes

Hahaha that’s awesome! I’d say it handled it quite well (except for the backwards trace)

This is what well handled looks like in Grafana:

Why is this well handled? I cannot see, what happened in the first and what in the second hour between 2 and 3 last night, can you? Honestly, the double line above is more well handled. Perhaps even better possible with two line types or colors, but if there are different values, you should be able to see them.

Grafana hanles it well because the line represents the actual progress in time. You can clearly see when the clock was set back. There have been two moments last night called 2:30 and both are represented on the timeline, so it is perfectly clear what happened when. So to answer your question: yes I can, the second 2:30 on the timeline is after the clock was set back.

Plotly however mangled the timeline, with now clue whatsoever which line happened when. The timeline does not represent what actually happened. Plotly makes it seem time itself doubled back on itself. The only thing that changed however is how we call the moment in time. Time has progressed naturally like in the grafana graph.

Ah ok, have overseen, that there is two times this time frame on x axis.

You are by all means right, but I wouldn’t say that “plotly” doesn’t handle it. It is rather this card the one that doesn’t: it asks plotly to make a scatter plot. It is doing what the code asks it to do, so blame me instead :laughing: .

@mateine
I’m trying to build a graphs that shows combined consumption from several sensors, and would like to agregate all the values to create something in shape of that:

Can you provide some pointers ?

Keywords: Stackgroup, fill, tonexty
Search here: Scatter traces in JavaScript
The single numbers at the bottom can’t be done with this card at the moment (plotting only), but you can use another an entity or template card for thar :slight_smile:

2 Likes

Thank ! I was just using that one to show stacking of traces on top of each other - other funky things around it are irrelevant.