lolouk44
(lolouk44)
October 15, 2021, 12:13pm
1
Is there a way to make the days_to_show
dynamic on a statistics-graph?
I’ve tried this:
- type: statistics-graph
title: 'Lolo Weight'
days_to_show: '{{states("input_number.lolo_weight_chart_days_to_show") | int}}'
stat_types: mean
entities:
- entity: sensor.lolo_weight
name: Weight
But all I get is loading statistics
Am I missing something?
It would be nice to be able to change the time scale with an input_number
or input_text
I did something like that with https://github.com/iantrich/config-template-card
type: custom:vertical-stack-in-card
title: BIER
cards:
- type: entities
entities:
- entity: input_select.hours_to_show
- type: entities
entities:
- entity: input_select.sensors_to_show
show_header_toggle: false
- type: custom:config-template-card
variables:
- states['input_select.hours_to_show'].state
- states['input_select.sensors_to_show'].state
- setEntities: |
entities => {
if '${var[1]}' === 'Alles' {
return ["sensor.temperatuur_bier", "sensor.temperatuur_fermenteerkast"];
}
else {
return ["sensor.temperatuur_bier", "sensor.temperatuur_fermenteerkast"];
}
entities:
- input_select.hours_to_show
- input_select.sensors_to_show
card:
type: custom:mini-graph-card
entities:
- entity: sensor.temperatuur_bier
- entity: sensor.setpunt_bier
- entity: sensor.setpunt_fermenteerkast
- entity: sensor.temperatuur_fermenteerkast
- entity: sensor.temperatuur_garage
hours_to_show: ${vars[0]}
hour24: true
points_per_hour: 15
line_width: 3
height: 250
show:
points: hover
labels: true
labels_secondary: true
fill: fade
1 Like
antsuc
(Jay Antoney)
January 4, 2022, 4:02am
3
Hey @lolouk44 - Did you ever solve this? I’m glad I’m not the only one that has come across this issue.
My template results to a number in the Dev Tools and I even tried with and without |int , but all I get is loading statistics as well.
I’ve submitted a bug - See if we’re just crazy
statistics-graph card shows “Loading statistics…” when using a dynamic variable for days_to_show · Issue #11085 · home-assistant/frontend (github.com)
lolouk44
(lolouk44)
January 4, 2022, 9:41am
4
Nope. The Days to show is static / hard coded for me. Not checked theunderlying code but I suspect it does not accept templates.
antsuc
(Jay Antoney)
February 5, 2022, 10:08am
5
For the sake of someone else reading this. As of FEB 2022 - it’s not supported and sounds like it’s not going to be unless we get a script monkey to help us out - cause I sure don’t know how
------ spacegaier on GITHUB (Refer to the github link earlier) ------
This is not supported. The docs state that you have to provide a numeric value in the card configuration, but you are providing a string and hoping that the frontend will evaluate that provided template into a number, which is not the case (not for this card, nor in general…with the exception of the markdown card).
You could raise a feature request, if you think that this is a needed feature, but then the next question would be: Why this configuration variable and not others and where do we draw the line then?
lolouk44
(lolouk44)
February 5, 2022, 12:56pm
6
Guess the best compromise will be to use conditional cards with an input select to drive it.
1 Like
Ooo, that’s a crafty workaround. Somewhat hacky but I like it, will try this approach.
1 Like
old, but why unresolved?
fix the issue with config-template-card , like this with apexcharts:
type: custom:config-template-card
entities:
- input_select.apex_span
variables:
span: states['input_select.apex_span'].state
card:
type: custom:apexcharts-card
update_interval: 1min
graph_span: ${span}
config-template-card can make any card dynamic
it was posted by @gieljnssns as the first response to this ask, so @lolouk44 please mark it resolved?