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

[ism8] Allow linking switch-r to Contact items #17742

Merged
merged 2 commits into from
Nov 30, 2024

Conversation

holgerfriedrich
Copy link
Member

switch-r elements are typically mapped to Switch items.
With this PR, you can also map them to Contact items.
This is better suited for the read-only elements.

Additionally, I added the warning statement about DPT 1.009 to the README. (It is the same as for KNX, DPT1.009 should have been inverted. Implementing it correctly will break existing installations.)

Without this PR, Contact items are not compatible and will not be updated.

I am not sure about the approach (using DecimalType 0 and 1 instead of enum identifiers from OnOffType).

Further testing is recommended. I did a short developer test, Contact and Switch items are now being filled correctly when data arrives.

@holgerfriedrich holgerfriedrich added additional testing preferred The change works for the pull request author. A test from someone else is preferred though. enhancement An enhancement or new feature for an existing add-on labels Nov 12, 2024
@lsiepel
Copy link
Contributor

lsiepel commented Nov 17, 2024

Personally i like the idea to let the user choose the item they like to use. On the other hand a contact is not a read-only switch, there are more differences. The state On/Off vs Open/Close for instance. I remember this has been talked about before in different bindings, not sure how it ended and failed to find it again.

I think it would be best to create an issue at the main UI repo to ask for real read-only switch support. As currently the user is able to toggle the switch even if it is marked read-only.

Do you have an example where a contact is a better fit then a switch?

@holgerfriedrich
Copy link
Member Author

holgerfriedrich commented Nov 17, 2024

I use contact items for all read-only switch items. I use it with the Android apps and still the basic ui.
Most of my items are set by the KNX binding, which can handle both Switch and Contact.

As you said, this leads to some inconsistencies, open/close is obvious for doors and windows, but not for, e.g., a fire alarm. On is mapped to open. For KNX DPT 1.009 it should be opposite.
I defined a MAP to get useful text for my Contact items, as well as I copied icons from the classic icon set with the proper naming.
image
Works for me, but it is inconvenient for new users.
When I use switches, the switch symbol interferes with the item text. And I could accidentally click the switch from the UI.

I used the same approach for ism8, but the Contact items did not update. No warning in the logs. This is why I created this PR. "0" and "1" seems to work for Switch and Contact.

A read-only switch supported by all UIs would make this easier, but do you think this is a lot of work to do.... Do you think we should start this discussion?

@lolodomo
Copy link
Contributor

lolodomo commented Nov 17, 2024

For read-only switch, with sitemap UIs, you can simply use a Text element.
Edit: or even Default element which checks if the item is read-only.

Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich
Copy link
Member Author

For read-only switch, with sitemap UIs, you can simply use a Text element. Edit: or even Default element which checks if the item is read-only.

Yes, if the elements of the sitemap are listed explicitly. If you just include Groups to your sitemap and let OH generate the list of items OH will stick to the type of the single element....

@holgerfriedrich holgerfriedrich added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Nov 17, 2024
@holgerfriedrich holgerfriedrich removed the additional testing preferred The change works for the pull request author. A test from someone else is preferred though. label Nov 30, 2024
@holgerfriedrich
Copy link
Member Author

Additional testing done on live system to check if this breaks the code for normal switch items.
Works as expected, as far as I can say.

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.

Thanks, LGTM

@lsiepel lsiepel merged commit 4ed9474 into openhab:main Nov 30, 2024
5 checks passed
@lsiepel lsiepel added this to the 4.3 milestone Nov 30, 2024
@holgerfriedrich holgerfriedrich deleted the pr-ism8-contact branch November 30, 2024 21:41
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Dec 16, 2024
* [ism8] Allow linking switch-... to Contact items

Signed-off-by: Holger Friedrich <[email protected]>
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this pull request Jan 2, 2025
* [ism8] Allow linking switch-... to Contact items

Signed-off-by: Holger Friedrich <[email protected]>
Signed-off-by: Ciprian Pascu <[email protected]>
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