$fn inside fn in filter (syntax - don't know how) #368
-
I know (thanks to David) how to have indicators.... but now I have in a filter section the following: filters:
- filter: i < xs.length - 1
- delta
- fn: |
({ys,xs,hass}) => ({
xs: [...xs, new Date().setHours(0,0,0)],
ys: [...ys, hass.states['sensor.from_netz_daily'].state],
})
To have the indicator I need to have a line like this for the last value i.e. the now that is in the -fn in the filter fn: $fn ({ys, vars}) => {vars.solar = ys.at(-1);} How do I put this in the section? - fn: |
({ys,xs,hass, vars}) => ({
xs: [...xs, new Date().setHours(0,0,0)],
ys: [...ys, hass.states['sensor.from_netz_daily'].state],
**_vars: [?????? ]_**
}) I have a workaround, which is to create an entity that is internal only and then use the fn for the value... ie I am basically duplicating the input stream.... thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Hi again! - fn: |
({ys,xs,hass, vars}) => {
vars.solar = ys.at(-1);
return {
xs: [...xs, new Date().setHours(0,0,0)],
ys: [...ys, hass.states['sensor.from_netz_daily'].state],
}
}) Although if you need the |
Beta Was this translation helpful? Give feedback.
-
I think >90% of all people using plotly on HA use it for environment (temp/hum etc) or for energy related stuff. THE major usecases ... |
Beta Was this translation helpful? Give feedback.
Right, I think you missed my comment at the end of the last answer:
That means: don't use a var inside the indicator. Instead, set
entity: sensor.from_netz_daily
and usevalue: $ex ys.at(-1)
.If this doesn't solve it, please post your full yaml inside a code block