Skip to content

Commit f3d5529

Browse files
fix filters: examples (#272)
spacing was invalid yaml
1 parent 636f176 commit f3d5529

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed

readme.md

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -433,67 +433,67 @@ Filters are applied in order.
433433
type: custom:plotly-graph
434434
entities:
435435
- entity: sensor.temperature_in_celsius
436-
filters:
437-
- store_var: myVar # stores the datapoints inside `vars.myVar`
438-
- load_var: myVar # loads the datapoints from `vars.myVar`
439-
440-
# The filters below will only be applied to numeric values. Missing (unavailable) and non-numerics will be left untouched
441-
- add: 5 # adds 5 to each datapoint
442-
- multiply: 2 # multiplies each datapoint by 2
443-
- calibrate_linear:
444-
# Left of the arrow are the measurements, right are the expected values.
445-
# The mapping is then approximated through linear regression, and that correction is applied to the data.
446-
- 0.0 -> 0.0
447-
- 40.0 -> 45.0
448-
- 100.0 -> 102.5
449-
- deduplicate_adjacent # removes all adjacent duplicate values. Useful for type: marker+text
450-
- delta # computes the delta between each two consecutive numeric y values.
451-
- derivate: h # computes rate of change per unit of time: h # ms (milisecond), s (second), m (minute), h (hour), d (day), w (week), M (month), y (year)
452-
- integrate: h # computes area under the curve in a specific unit of time using Right hand riemann integration. Same units as the derivative
453-
- integrate:
454-
unit: h # defaults to h
455-
reset_every: 1h # Defaults to 0 (never reset). Any duration unit (ms, s, m, h, d, w, M, y).
456-
offset: 30m # defaults to 0. Resets happen 30m later
457-
458-
- map_y_numbers: Math.sqrt(y + 10*100) # map the y coordinate of each datapoint. Same available variables as for `map_y`
459-
# In the filters below, missing and non numeric datapoints will be discarded
460-
- sliding_window_moving_average: # best for smoothing
461-
# default parameters:
462-
window_size: 10
463-
extended: false # when true, smaller window sizes are used on the extremes.
464-
centered: true # compensate for averaging lag by offsetting the x axis by half a window_size
465-
- exponential_moving_average: # good for smoothing
466-
# default parameters:
467-
alpha: 0.1 # between 0 an 1. The lower the alpha, the smoother the trace.
468-
- median: # got to remove outliers
469-
# default parameters:
470-
window_size: 10
471-
extended: false
472-
centered: true
473-
- trendline # converts the data to a linear trendline // TODO: force line.shape = linear
474-
- trendline: linear # defaults to no forecast, no formula, no error squared
475-
- trendline:
476-
type: polynomial # linear, polynomial, power, exponential, theil_sen, robust_polynomial, fft
477-
forecast: 1d # continue trendline after present. Use global time_offset to show beyond present.
478-
degree: 3 # only appliable to polynomial regression and fft.
479-
show_formula: true
480-
show_r2: true
481-
# The filters below receive all datapoints as they come from home assistant. Y values are strings or null (unless previously mapped to numbers or any other type)
482-
- map_y: 'y === "heat" ? 1 : 0' # map the y values of each datapoint. Variables `i` (index), `x`, `y`, `state`, `statistic`, `xs`, `ys`, `states`, `statistics`, `meta`, `vars` and `hass` are in scope. The outer quoutes are there because yaml doesn't like colons in strings without quoutes.
483-
- map_x: new Date(+x + 1000) # map the x coordinate (javascript date object) of each datapoint. Same variables as map_y are in scope
484-
- fn: |- # arbitrary function. Only the keys that are returned are replaced. Returning null or undefined, leaves the data unchanged (useful )
485-
486-
({xs, ys, meta, states, statistics, hass}) => {
487-
# either statistics or states will be available, depending on if "statistics" are fetched or not
488-
# attributes will be available inside states only if an attribute is picked in the trace
489-
return {
490-
ys: states.map(state => +state?.attributes?.current_temperature - state?.attributes?.target_temperature + hass.states["sensor.temperature"].state,
491-
meta: { unit_of_measurement: "delta" }
492-
};
493-
},
494-
- resample: 5m # Rebuilds data so that the timestamps in xs are exact multiples of the specified interval, and without gaps. The parameter is the length of the interval and defaults to 5 minutes (see #duration for the format). This is useful when combining data from multiple entities, as the index of each datapoint will correspond to the same instant of time across them.
495-
- filter: y !== null && +y > 0 && x > new Date(Date.now()-1000*60*60) # filter out datapoints for which this returns false. Also filters from xs, states and statistics. Same variables as map_y are in scope
496-
- force_numeric # converts number-lookinig-strings to actual js numbers and removes the rest. Any filters used after this one will receive numbers, not strings or nulls. Also removes respective elements from xs, states and statistics parameters
436+
filters:
437+
- store_var: myVar # stores the datapoints inside `vars.myVar`
438+
- load_var: myVar # loads the datapoints from `vars.myVar`
439+
440+
# The filters below will only be applied to numeric values. Missing (unavailable) and non-numerics will be left untouched
441+
- add: 5 # adds 5 to each datapoint
442+
- multiply: 2 # multiplies each datapoint by 2
443+
- calibrate_linear:
444+
# Left of the arrow are the measurements, right are the expected values.
445+
# The mapping is then approximated through linear regression, and that correction is applied to the data.
446+
- 0.0 -> 0.0
447+
- 40.0 -> 45.0
448+
- 100.0 -> 102.5
449+
- deduplicate_adjacent # removes all adjacent duplicate values. Useful for type: marker+text
450+
- delta # computes the delta between each two consecutive numeric y values.
451+
- derivate: h # computes rate of change per unit of time: h # ms (milisecond), s (second), m (minute), h (hour), d (day), w (week), M (month), y (year)
452+
- integrate: h # computes area under the curve in a specific unit of time using Right hand riemann integration. Same units as the derivative
453+
- integrate:
454+
unit: h # defaults to h
455+
reset_every: 1h # Defaults to 0 (never reset). Any duration unit (ms, s, m, h, d, w, M, y).
456+
offset: 30m # defaults to 0. Resets happen 30m later
457+
458+
- map_y_numbers: Math.sqrt(y + 10*100) # map the y coordinate of each datapoint. Same available variables as for `map_y`
459+
# In the filters below, missing and non numeric datapoints will be discarded
460+
- sliding_window_moving_average: # best for smoothing
461+
# default parameters:
462+
window_size: 10
463+
extended: false # when true, smaller window sizes are used on the extremes.
464+
centered: true # compensate for averaging lag by offsetting the x axis by half a window_size
465+
- exponential_moving_average: # good for smoothing
466+
# default parameters:
467+
alpha: 0.1 # between 0 an 1. The lower the alpha, the smoother the trace.
468+
- median: # got to remove outliers
469+
# default parameters:
470+
window_size: 10
471+
extended: false
472+
centered: true
473+
- trendline # converts the data to a linear trendline // TODO: force line.shape = linear
474+
- trendline: linear # defaults to no forecast, no formula, no error squared
475+
- trendline:
476+
type: polynomial # linear, polynomial, power, exponential, theil_sen, robust_polynomial, fft
477+
forecast: 1d # continue trendline after present. Use global time_offset to show beyond present.
478+
degree: 3 # only appliable to polynomial regression and fft.
479+
show_formula: true
480+
show_r2: true
481+
# The filters below receive all datapoints as they come from home assistant. Y values are strings or null (unless previously mapped to numbers or any other type)
482+
- map_y: 'y === "heat" ? 1 : 0' # map the y values of each datapoint. Variables `i` (index), `x`, `y`, `state`, `statistic`, `xs`, `ys`, `states`, `statistics`, `meta`, `vars` and `hass` are in scope. The outer quoutes are there because yaml doesn't like colons in strings without quoutes.
483+
- map_x: new Date(+x + 1000) # map the x coordinate (javascript date object) of each datapoint. Same variables as map_y are in scope
484+
- fn: |- # arbitrary function. Only the keys that are returned are replaced. Returning null or undefined, leaves the data unchanged (useful )
485+
486+
({xs, ys, meta, states, statistics, hass}) => {
487+
# either statistics or states will be available, depending on if "statistics" are fetched or not
488+
# attributes will be available inside states only if an attribute is picked in the trace
489+
return {
490+
ys: states.map(state => +state?.attributes?.current_temperature - state?.attributes?.target_temperature + hass.states["sensor.temperature"].state,
491+
meta: { unit_of_measurement: "delta" }
492+
};
493+
},
494+
- resample: 5m # Rebuilds data so that the timestamps in xs are exact multiples of the specified interval, and without gaps. The parameter is the length of the interval and defaults to 5 minutes (see #duration for the format). This is useful when combining data from multiple entities, as the index of each datapoint will correspond to the same instant of time across them.
495+
- filter: y !== null && +y > 0 && x > new Date(Date.now()-1000*60*60) # filter out datapoints for which this returns false. Also filters from xs, states and statistics. Same variables as map_y are in scope
496+
- force_numeric # converts number-lookinig-strings to actual js numbers and removes the rest. Any filters used after this one will receive numbers, not strings or nulls. Also removes respective elements from xs, states and statistics parameters
497497
```
498498
499499
#### Examples

0 commit comments

Comments
 (0)