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

[mqtt] Treat incoming empty string as NULL for enum #16641

Merged
merged 1 commit into from
Apr 28, 2024

Conversation

ccutrer
Copy link
Contributor

@ccutrer ccutrer commented Apr 11, 2024

Since #16307, everything except TextValue would treat an empty string as NULL. TextValue was excluded because empty string could be a valid value. Instead it had a config option added to match for a NULL value if you wanted. BUT, if a TextValue has specific valid states configured (such as from Homie or Home Assistant bindings), then empty string is no longer a valid value, and should receive the same treatment of setting the state to NULL when encountered.

Since openhab#16307, everything except TextValue would treat an empty
string as NULL. TextValue was excluded because empty string
could be a valid value. Instead it had a config option added
to match for a NULL value if you wanted. BUT, if a TextValue
has specific valid states configured (such as from Homie or
Home Assistant bindings), then empty string is no longer a
valid value, and should receive the same treatment of setting
the state to NULL when encountered.

Signed-off-by: Cody Cutrer <[email protected]>
@lsiepel lsiepel added the enhancement An enhancement or new feature for an existing add-on label Apr 11, 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. One question to double check: as the behaviour is slightly different, do you expect issues in existing installations regarding rules ? If so we might consider to add a warning in the distro upgrade. That might also be a bit overdone, wdyt?

@lsiepel
Copy link
Contributor

lsiepel commented Apr 28, 2024

ping @ccutrer

@ccutrer
Copy link
Contributor Author

ccutrer commented Apr 28, 2024

Sorry, I didn't see your comment, just your approval message. I was wondering why it didn't get merged with the approval!

Anyhow, no, I don't expect any issues with existing installations. If the valid enum values includes empty string, it will still allow it. So this only changes someone that is not generally expecting an empty string on a topic, it treats it as NULL instead of logging a warning, and doing nothing. This typically means the topics were cleared, either because the device is re-initializing (and likely to re-set to valid value soon), or whatever owns the device is deleting it - both cases that you would expect the state to go to NULL in openHAB. As was mentioned, this is essentially analogous to the prior change for non-text values (which we didn't put a warning in the distro upgrade docs), and I've only heard positive feedback about that change.

@lsiepel lsiepel merged commit 836581e into openhab:main Apr 28, 2024
3 checks passed
@lsiepel lsiepel added this to the 4.2 milestone Apr 28, 2024
lo92fr pushed a commit to lo92fr/openhab-addons that referenced this pull request Apr 30, 2024
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[email protected]>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Jun 15, 2024
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[email protected]>
Signed-off-by: Paul Smedley <[email protected]>
@ccutrer ccutrer deleted the mqtt-null-enum branch July 23, 2024 21:45
pgfeller pushed a commit to pgfeller/openhab-addons that referenced this pull request Sep 29, 2024
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
joni1993 pushed a commit to joni1993/openhab-addons that referenced this pull request Oct 15, 2024
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[email protected]>
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Oct 18, 2024
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[email protected]>
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this pull request Jan 2, 2025
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[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.

2 participants