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] State filter profile #531

Merged
merged 15 commits into from
Mar 24, 2024
Merged

Conversation

seime
Copy link
Contributor

@seime seime commented Oct 29, 2023

Simple filter profile to filter unwanted values originating from a Handler - based on some item(s)' state.

Optional support for replacement state to send instead

| Configuration Parameter | Type | Description |
|-------------------------|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `conditions` | text | Comma separated list of expressions on the format `ITEM_NAME OPERATOR ITEM_STATE`, ie `MyItem EQ OFF`. Use quotes around `ITEM_STATE` to treat value as string ie `'OFF`' |
| `mismatchState` | text | Optional state to pass instead if conditions are NOT met. Use quotes to treat as `StringType` |
Copy link
Member

Choose a reason for hiding this comment

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

Why is it necessary to quote strings? There is also an issue with the way you split the string. If the comparison value contains a ,, you split in the middle of a string. I know that this is really hard to handle correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example why it may be useful (required) to quote strings

I have an aircon with a mode (string) channel. It takes values such as HEAT, COOL, OFFand so on. In order to not re-create state parsing, I've used the OH TypeParser. For a value OFF it will return OnOffType.OFF, and not the string OFF.

I guess I could improve further by checking the item type, but that would also make the same syntax mean 2 different things, and my gut feeling is that there will still be situations where the (hypotetical) user would want the non-default functionality.

Regarding comma as separator between multiple expressions; made this configurable.

Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Signed-off-by: Arne Seime <[email protected]>
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

Just a few code-style comments, otherwise fine. Can you address those quickly? I would like to include that in the release later this week.

…rg/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java
…rg/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java
…rg/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java
…rg/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java
Copy link

stale bot commented Mar 19, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale An issue is marked stale after four weeks without activity and will be closed one week later. label Mar 19, 2024
@J-N-K J-N-K added enhancement New feature or request and removed stale An issue is marked stale after four weeks without activity and will be closed one week later. labels Mar 24, 2024
@J-N-K J-N-K added this to the 4.0.3 milestone Mar 24, 2024
@J-N-K J-N-K merged commit 6104110 into smarthomej:4.0.x Mar 24, 2024
2 checks passed
@J-N-K J-N-K changed the title State filter profile [basicprofiles] State filter profile Mar 24, 2024
J-N-K added a commit that referenced this pull request Mar 24, 2024
* State filter profile

Signed-off-by: Arne Seime <[email protected]>
Co-authored-by: J-N-K <[email protected]>
(cherry picked from commit 6104110)
Signed-off-by: Jan N. Klug <[email protected]>
J-N-K added a commit that referenced this pull request Mar 24, 2024
* State filter profile

Signed-off-by: Arne Seime <[email protected]>
Co-authored-by: J-N-K <[email protected]>
(cherry picked from commit 6104110)
Signed-off-by: Jan N. Klug <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants