Filters
Filters can be used on supported components to modify incoming state values.
sensor: - platform: shell name: 'RAM Usage' command: echo 1.123345 filters: - round: 2
# Sensor value will be shown as 1.12Available Filters
Section titled “Available Filters”Rounds numeric sensor values to the configured number of decimal places.
sensor: - platform: shell name: 'CPU Usage' command: echo 12.3456 filters: - round: 2
# Result: 12.35invert
Section titled “invert”Inverts a boolean binary sensor value (true becomes false, false becomes true).
binary_sensor: - platform: shell name: 'Door Closed' command: test -f /tmp/door_open && echo true || echo false filters: - invert:
# If command returns true, the reported state becomes falsedelayed_on
Section titled “delayed_on”Delays propagation of true values by the configured duration. false values are still passed immediately.
binary_sensor: - platform: gpio name: 'Motion' pin: 17 filters: - delayed_on: 1sdelayed_off
Section titled “delayed_off”Delays propagation of false values by the configured duration. true values are still passed immediately.
binary_sensor: - platform: gpio name: 'Motion' pin: 17 filters: - delayed_off: 5sFilter Support by Component
Section titled “Filter Support by Component”| Component | Supported Filters |
|---|---|
| Sensor | round |
| Binary Sensor | invert, delayed_on, delayed_off |
| Button | None |
| Number | None |
| Switch | None |
See each component page for details and examples.