More sensor filters

This commit is contained in:
Otto Winter 2018-05-18 08:21:52 +02:00
parent 15b0521693
commit d421b904f3
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
4 changed files with 30 additions and 13 deletions

View File

@ -124,6 +124,16 @@ Filter
:protected-members:
:undoc-members:
.. doxygenclass:: sensor::HeartbeatFilter
:members:
:protected-members:
:undoc-members:
.. doxygenclass:: sensor::DebounceFilter
:members:
:protected-members:
:undoc-members:
.. doxygenclass:: sensor::DeltaFilter
:members:
:protected-members:
@ -134,11 +144,6 @@ Filter
:protected-members:
:undoc-members:
.. doxygenclass:: sensor::AndFilter
:members:
:protected-members:
:undoc-members:
.. doxygenclass:: sensor::UniqueFilter
:members:
:protected-members:

View File

@ -41,7 +41,7 @@ not work.
# Use pin number 0
number: 0
# One of INPUT, INPUT_PULLUP or OUTPUT
mode: INPUT
mode: OUTPUT
inverted: False
Configuration variables:

View File

@ -135,6 +135,8 @@ sensor <https://www.home-assistant.io/components/sensor.filter/>`__.
alpha: 0.1
send_every: 15
- throttle: 1s
- heartbeat: 5s
- debounce: 0.1s
- delta: 5.0
- unique:
- or:
@ -168,8 +170,17 @@ every filter there is currently:
- **send_every**: How often a sensor value should be pushed out.
- **throttle**: Throttle the incoming values. When this filter gets an incoming value,
it checks if the last value passed out of this filter is at least the value of this filter
old. If it is not older than the configured value, the value is not passed forward.
it checks if the last incoming value is at least ``specified time period`` old.
If it is not older than the configured value, the value is not passed forward.
- **heartbeat**: Send the last value that this sensor in the specified time interval.
So a value of ``10s`` will cause the filter to output values every 10s regardless
of the input values.
- **debounce**: Only send values if the last incoming value is at least ``specified time period``
old. For example if two values come in at almost the same time, this filter will only output
the last value and only after the specified time period has passed without any new incoming
values.
- **delta**: This filter stores the last value passed through this filter and only
passes incoming values through if the absolute difference is greater than the configured
@ -184,8 +195,6 @@ every filter there is currently:
will only pass forward values that are *either* at least 1s old or are if the absolute
difference is at least 5.0.
- **and**: Similar to or. Only pass on a value if all child filters pass.
- **lambda**: Perform a simple mathematical operation over the sensor
values. The input value is ``x`` and the result of the lambda is used
as output. Each floating point operation should have ``.0`` attached

View File

@ -51,12 +51,13 @@ Configuration variables:
and `MQTT
Component </esphomeyaml/components/mqtt.html#mqtt-component-base-configuration>`__.
Throttling Output
Debouncing Output
~~~~~~~~~~~~~~~~~
This sensor can output a lot of values in a short period of time when turning the knob.
In order to not put too much stress on your network connection, you can leverage esphomelib's
sensor filters. The following will only send out values once every half second max:
sensor filters. The following will only send out values if the last input value is at least
0.1s seconds old *or* if the new rotary encoder value has changed by 10 from the previous value.
.. code:: yaml
@ -67,4 +68,6 @@ sensor filters. The following will only send out values once every half second m
pin_a: D1
pin_b: D2
filters:
- throttle: 0.5s
- or:
- debounce: 0.1s
- delta: 10