diff --git a/content/components/sensor/_index.md b/content/components/sensor/_index.md index 45c94625bb..49d6ab0fc6 100644 --- a/content/components/sensor/_index.md +++ b/content/components/sensor/_index.md @@ -163,6 +163,8 @@ filters: - exponential_moving_average: alpha: 0.1 send_every: 15 + - high_pass: 0.75 + - low_pass: 0.25 - throttle: 1s - throttle_average: 1s - throttle_with_priority: @@ -212,10 +214,18 @@ filters: {{< include "filter/heartbeat.md" >}} +### `high_pass` + +{{< include "filter/high_pass.md" >}} + ### `lambda` {{< include "filter/lambda.md" >}} +### `low_pass` + +{{< include "filter/low_pass.md" >}} + ### `max` {{< include "filter/max.md" >}} diff --git a/content/components/sensor/filter/high_pass.md b/content/components/sensor/filter/high_pass.md new file mode 100644 index 0000000000..6894fccc35 --- /dev/null +++ b/content/components/sensor/filter/high_pass.md @@ -0,0 +1,29 @@ +--- +description: "" +headless: true +--- + +Basic [high pass filter](https://en.wikipedia.org/wiki/High-pass_filter>) for the sensor values, +assuming the sensor values are sampled at a constant rate. This filter will remove low-frequency +components and offset from the sensor values. + +The formula for the high pass filter is: ``y[i] := α × y[i−1] + α × (x[i] − x[i−1])``, +where ``x`` is the input value and ``y`` is the output value. + +A large α implies that the output will decay very slowly but will also be strongly influenced by +even small changes in input. + +A small α implies that the output will decay quickly and will require large changes in the input +to cause the output to change much. A value of 0.5 (when time constant equal sampling period) might be a good starting point for experimentation. + +```yaml +# Example configuration entry +- platform: wifi_signal + # ... + filters: + - high_pass: 0.75 +``` + +Configuration variables: + +- **alpha** (*Required*, float): *Alpha* smoothing factor for the high pass filter. From 0 to 1. diff --git a/content/components/sensor/filter/low_pass.md b/content/components/sensor/filter/low_pass.md new file mode 100644 index 0000000000..8f1cb393f2 --- /dev/null +++ b/content/components/sensor/filter/low_pass.md @@ -0,0 +1,26 @@ +--- +description: "" +headless: true +--- + +Basic [low pass filter](https://en.wikipedia.org/wiki/Low-pass_filter>) for the sensor values, +assuming the sensor values are sampled at a constant rate. This filter will remove high-frequency +components and noise from the sensor values. + +The formula for the low pass filter is: ``y[i] := α * x[i] + (1-α) * y[i-1]``, +where ``x`` is the input value and ``y`` is the output value. + +A lower α implies that the output will respond more slowly to changes in the input but will also +be less influenced by noise. We can say the system has more inertia. A value of 0.5 (when time constant equal sampling period) might be a good starting point for experimentation. + +```yaml +# Example configuration entry +- platform: wifi_signal + # ... + filters: + - low_pass: 0.25 +``` + +Configuration variables: + +- **alpha** (*Required*, float): *Alpha* smoothing factor for the low pass filter. From 0 to 1.