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

[basicprofiles] Add support for functions (DELTA, MEDIAN, AVG, STDDEV, MIN, MAX) in State Filter #17362

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

jimtng
Copy link
Contributor

@jimtng jimtng commented Sep 3, 2024

  • Improve the conditions flexibility so that any type of operand can be on either side of the operator, e.g.: ItemName > 10 and 10 < ItemName
  • Add support for functions:
    • $DELTA to represent the absolute difference between the incoming value and the previously accepted value.
    • $AVERAGE, or $AVG to represent the average of the previous incoming values, excluding the incoming value.
    • $MEDIAN to represent the median value of the previous incoming values.
    • $STDDEV to represent the population standard deviation of the previous unfiltered incoming values.
    • $MIN to represent the minimum value of the previous incoming values.
    • $MAX to represent the maximum value of the previous incoming values.
      By default, 5 samples of the previous values are kept.
      This can be customized by specifying the "window size" or sample count applicable to the function, e.g. $MEDIAN(10) will return the median of the last 10 values.
      All the functions except $DELTA support a custom window size.

Example:

Filter out incoming data with very small difference from the previous one:

Number:Power PowerUsage {
  channel="mybinding:mything:mychannel" [ profile="basic-profiles:state-filter", conditions="$DELTA > 10 W" ]
}

@jimtng jimtng force-pushed the basicprofiles-statefilter-functions branch from 1e5bcd6 to 28f7722 Compare September 3, 2024 08:59
@jimtng jimtng changed the title Basicprofiles-statefilter-functions [basicprofiles] Add support for functions (DELTA, MEDIAN, AVG, MIN, MAX) in State Filter Sep 3, 2024
@jimtng jimtng force-pushed the basicprofiles-statefilter-functions branch from 28f7722 to 0c4b178 Compare September 3, 2024 09:05
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/filter-transform-energy-meter-readings-to-delete-single-readings-for-state-machine/156276/9

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/state-filter-range-filter-profile/158025/20

@jimtng jimtng marked this pull request as ready for review September 3, 2024 09:14
@jimtng jimtng requested a review from J-N-K as a code owner September 3, 2024 09:14
@jimtng jimtng force-pushed the basicprofiles-statefilter-functions branch 3 times, most recently from a6a3815 to ff3620c Compare September 3, 2024 13:26
@jimtng jimtng changed the title [basicprofiles] Add support for functions (DELTA, MEDIAN, AVG, MIN, MAX) in State Filter [basicprofiles] Add support for functions (DELTA, MEDIAN, AVG, STDDEV, MIN, MAX) in State Filter Sep 3, 2024
…, MIN, MAX) in State Filter

Support any type of operand on either side of the operator
e.g.: `ItemName > 10` and `10 < ItemName`

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
@jimtng jimtng force-pushed the basicprofiles-statefilter-functions branch from ff3620c to 9a03888 Compare September 3, 2024 13:35
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
@jlaur jlaur added the enhancement An enhancement or new feature for an existing add-on label Sep 3, 2024
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Would be nice if @J-N-K can confirm.

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/how-to-get-the-last-5-values-from-the-rrd4j/158569/5

@lsiepel lsiepel requested a review from a team October 28, 2024 19:03
@lsiepel
Copy link
Contributor

lsiepel commented Oct 28, 2024

Would be nice if another @openhab/add-ons-maintainers joins this conversion as i don't feel comfortable enough to just merge this as transformations and profiles are not my expertise.

@jlaur
Copy link
Contributor

jlaur commented Oct 28, 2024

Would be nice if another @openhab/add-ons-maintainers joins this conversion as i don't feel comfortable enough to just merge this as transformations and profiles are not my expertise.

Perhaps we can try to ping @J-N-K again since he is both binding maintainer and @openhab/add-ons-maintainers. 🙂

@jimtng jimtng added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Dec 3, 2024
@lsiepel lsiepel merged commit 12e7212 into openhab:main Dec 3, 2024
5 checks passed
@lsiepel lsiepel added this to the 4.3 milestone Dec 3, 2024
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Dec 16, 2024
…, MIN, MAX) in State Filter (openhab#17362)

* [basicprofiles] Add support for functions (DELTA, MEDIAN, AVG, STDDEV, MIN, MAX) in State Filter

Support any type of operand on either side of the operator
e.g.: `ItemName > 10` and `10 < ItemName`

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this pull request Jan 2, 2025
…, MIN, MAX) in State Filter (openhab#17362)

* [basicprofiles] Add support for functions (DELTA, MEDIAN, AVG, STDDEV, MIN, MAX) in State Filter

Support any type of operand on either side of the operator
e.g.: `ItemName > 10` and `10 < ItemName`

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants