Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match both percentage and value for delta filter #2985

Open
DrBlokmeister opened this issue Dec 10, 2024 · 0 comments
Open

Match both percentage and value for delta filter #2985

DrBlokmeister opened this issue Dec 10, 2024 · 0 comments

Comments

@DrBlokmeister
Copy link

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:

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant