esphome / esphome/feature-requests
Match both percentage and value for delta filter
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
Currently a delta filter can either check if the value is different by a certain percentage or by a certain value. Not both. An 'or' filter can be created to combine both. However, no 'and' filter exists, meaning that you cannot check if the value changes by (for example) at least 10% and also by an absolute change of 20. I would like such a check.
An example of this implementation would look like:
```yaml
filters:
- delta:
percentage: 10
value: 20.0
match_both: true
```
**Please describe your use case for this integration and alternatives you've tried:**
I would use this for power plugs. If the current power usage is for example 5W, then I want to update immediately if the value is at least 5W different from the previous value, otherwise throttle_average over 60 seconds. However, if the current power usage is around 1000W, a 5W difference is too small to warrant an immediate update, so I would like to check if the new value is at least 10% different from the previous value.
Currently I use this:
```yaml
sensor:
- platform: bl0940
uart_id: uart_bus
update_interval: 0.5s
power:
name: "${device_name} Power"
unit_of_measurement: W
id: power
icon: mdi:gauge
filters:
- throttle_average: 5s
- or:
- throttle_average: 60s
- or: #I would like to use AND instead, or the aforementioned implementation of the delta filter
- delta: 20.0
- delta: 10%
```
Other than using globals and creating lambda filters for every separate sensor, there is no easy solution.
**Additional context**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.