-
I use the following configuration in a graph: type: custom:plotly-graph
fn: $ex vars.smooth = false
config:
modeBarButtonsToAdd:
- name: button1
click: $ex (gd) => { vars.smooth = !vars.smooth; }
defaults:
entity:
filters:
- sliding_window_moving_average:
window_size: "$ex vars.smooth ? 200 : 1"
entities:
- entity: sensor.solar_power_of_p1
- entity: sensor.solar_power_of_p2
- entity: sensor.solar_production_instantanee
hours_to_show: 24 The graph behaves as I want depending on the value I set vars.smooth to, but clicking on the button does not trigger a refresh and new execution of the filters. I can use How should I proceed ? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
I didn't add a force refresh method to call, so you'd have to use a helper sensor instead. You can set it via the hass object, you'll have to put a |
Beta Was this translation helpful? Give feedback.
-
Sadly, storing a variable in Yet, when I put |
Beta Was this translation helpful? Give feedback.
-
type: custom:plotly-graph
fn: $ex { window.solar_vars = Array(); window.solar_vars[0] = false }
config:
modeBarButtonsToAdd:
- name: button1
click: $ex (gd) => { window.solar_vars[0] = !window.solar_vars[0]; console.log(window.solar_vars); }
defaults:
entity:
line:
shape: spline
filters:
- resample: 1m
- exponential_moving_average:
alpha: "$ex { window.solar_vars[0] ? 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: $ex "Total" + Math.random() + window.solar_vars[0]
fn: $ex { console.log(window.solar_vars); }
hours_to_show: 24 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
I found a way to make it work: