Skip to content

Refresh plotly from a click handler #556

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

You must be logged in to vote

I found a way to make it work:

type: custom:plotly-graph
fn: $ex { window.solar_smooth = Boolean(window.solar_smooth);}
config:
  modeBarButtonsToAdd:
    - name: button1
      click: >-
        $ex (gd) => { window.solar_smooth = !window.solar_smooth;
        gd.parentElement.querySelector("#reset").click(); }
defaults:
  entity:
    line:
      shape: spline
    filters:
      - resample: 1m
      - exponential_moving_average:
          alpha: "$ex window.solar_smooth ? 0.05 : 1"
entities:
  - entity: sensor.solar_power_of_p1
    name: P1 (Est)
  - entity: sensor.solar_power_of_p2
    name: P2 (Ouest)
  - entity: sensor.solar_production_instantanee
    name: Total
hours_to_show: 24

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@FrnchFrgg
Comment options

@dbuezas
Comment options

@FrnchFrgg
Comment options

@FrnchFrgg
Comment options

@dbuezas
Comment options

Comment options

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

Comment options

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

Comment options

You must be logged in to vote
0 replies
Answer selected by FrnchFrgg
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