dbuezas / lovelace-plotly-graph-card

Highly customisable Lovelace card to plot interactive graphs. Brings scrolling, zooming, and much more!
411 stars 20 forks source link

Global or tag based date and time picker. #403

Open kylian-002 opened 7 months ago

kylian-002 commented 7 months ago

Describe the solution you'd like I would like to have the ability to use a single set of date and time selection controls to select the date and time for all cards on a given dashboard, or perhaps for a selected few that are selectable by tags. This functionality would be similar to how the "energy-date-selection" card works for the energy dashboard but applicable to Plotly cards and usable for purposes other than energy-related data.

How would it be defined in yaml?

type: custom:plotly-graph
entities:
  - entity: sensor.monthly_internet_energy
     entity_feature_config: xxx
global_feature_config: xxx
tag: tagname
dbuezas commented 7 months ago

You could post values from one plot into a sensor using the hass object, then fetch it in the other one. The currently visible range is in get('vidible_range')

dbuezas commented 7 months ago

Ok, I tried it and it does work but it is not great to be honest.

One thing you could do is to put all plots in a single card like this: https://github.com/dbuezas/lovelace-plotly-graph-card/discussions/13

dbuezas commented 7 months ago

For the record, this was my experiment:

https://github.com/dbuezas/lovelace-plotly-graph-card/assets/777196/8896767a-20e8-4a16-aac4-dd81c70a6d7d

Master chart

type: custom:plotly-graph
entities:
  - entity: sensor.senseair_co2
fn: >
  $ex hass.callApi("POST", "states/sensor.plotly_visible_range", {state:
  JSON.stringify(get("visible_range"))})

Other synched chart

type: custom:plotly-graph
entities:
  - entity: sensor.senseair_co2
  - entity: sensor.plotly_visible_range
    internal: false
    comment1: for some reason, plotly doesnt update the layout if this is internal true
    comment2: this is here just to make plotly refresh when visible range changes
    yaxis: y10
    'y': []
layout:
  xaxis:
    range: |
      $ex JSON.parse(hass.states["sensor.plotly_visible_range"].state)
hours_to_show: 24
refresh_interval: auto
kylian-002 commented 7 months ago

Ok, I tried it and it does work but it is not great to be honest.

One thing you could do is to put all plots in a single card like this: #13

I think this wil work for my usecase. Thanks!