Visitar URL original
[nobohub] Fix ignored keepaliveInterval setting by MaxFreedomPollard · Pull Request #21613 · openhab/openhab-addons · GitHub
Skip to content

[nobohub] Fix ignored keepaliveInterval setting - #21613

Merged
lsiepel merged 1 commit into
openhab:mainfrom
MaxFreedomPollard:nobohub-keepalive-interval-config
Sep 6, 2026
Merged

lsiepel merged 1 commit into
openhab:mainfrom
MaxFreedomPollard:nobohub-keepalive-interval-config

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

Bugfix. The Nobo Hub bridge has a "Polling interval" setting that has never done anything.

bundles/org.openhab.binding.nobohub/src/main/resources/OH-INF/thing/bridge.xml declares the parameter as keepaliveInterval (minimum 5, default 14), and both nobohub.properties and nobohub_fr.properties translate it under that name. NoboHubBridgeConfiguration called the matching field pollingInterval.

openHAB binds a thing configuration to a configuration class by field name. ConfigParser#constructClass in openhab-core does properties.get(fieldName) and skips the field when the configuration has no entry under that exact name. So the value a user sets never reached the field, it stayed at 0, the config.pollingInterval > 0 guard at NoboHubBridgeHandler.java:161 was never true, and the timeout passed to HubCommunicationThread was always RECOMMENDED_KEEPALIVE_INTERVAL, 14 seconds, no matter what was configured. The two names have differed since the initial contribution in bc9cf8e (#12937).

The fix renames the field to keepaliveInterval. I renamed the field rather than the parameter so that thing configurations people already have keep working and both i18n files stay correct.

NoboHubBridgeConfigurationTest is new. It reads the parameter names out of bridge.xml and asserts each one has a matching field on the configuration class, and it round-trips a keepaliveInterval of 30 through org.openhab.core.config.core.Configuration#as. Against unmodified main both tests fail, with Parameter 'keepaliveInterval' declared in src/main/resources/OH-INF/thing/bridge.xml has no matching field in NoboHubBridgeConfiguration and NoSuchFieldException: keepaliveInterval. With the change they pass.

The README gained three lines for the parameter, since it now has an effect.

Testing: mvn clean verify -am -amd -pl :org.openhab.binding.nobohub plus the three BOM index modules, the way .github/scripts/maven-build invokes it for a single changed add-on, on Temurin 21.0.12.1. BUILD SUCCESS, Tests run: 61, Failures: 0, Errors: 0, Skipped: 0. That run includes spotless:check and the static analysis for the module; the six SAT findings it reports for nobohub are all priority 3 and all in files this PR does not touch. mvn spotless:apply -pl :org.openhab.binding.nobohub produced no changes, and npx markdownlint-cli2 --config .github/markdownlint.yaml bundles/org.openhab.binding.nobohub/README.md reports 0 issues.

The bridge thing type declares a keepaliveInterval configuration
parameter, but NoboHubBridgeConfiguration named the matching field
pollingInterval. openHAB binds a thing configuration to a configuration
class by field name: ConfigParser#constructClass in openhab-core reads
properties.get(fieldName) and skips the field when there is no entry
under that exact name. The configured value therefore never reached the
field, it stayed at 0, the "config.pollingInterval > 0" guard in
NoboHubBridgeHandler#initialize was never true, and the timeout given to
HubCommunicationThread was always RECOMMENDED_KEEPALIVE_INTERVAL, 14
seconds, whatever the user had set. The two names have differed since
the initial contribution in bc9cf8e.

Rename the field to keepaliveInterval. Renaming the field rather than
the parameter keeps the parameter name that existing thing
configurations already use and that both i18n property files translate.

Add NoboHubBridgeConfigurationTest, which reads the parameter names out
of bridge.xml and asserts each one has a matching field, and document
the parameter in the README now that it takes effect.

Signed-off-by: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com>
@lsiepel lsiepel added the bug An unexpected problem or unintended behavior of an add-on label Sep 6, 2026
@lsiepel
lsiepel merged commit ca01326 into openhab:main Sep 6, 2026
3 checks passed

@lsiepel lsiepel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM

@lsiepel lsiepel added this to the 5.3 milestone Sep 6, 2026
lsiepel pushed a commit that referenced this pull request Sep 26, 2026
The bridge thing type declares a keepaliveInterval configuration
parameter, but NoboHubBridgeConfiguration named the matching field
pollingInterval. openHAB binds a thing configuration to a configuration
class by field name: ConfigParser#constructClass in openhab-core reads
properties.get(fieldName) and skips the field when there is no entry
under that exact name. The configured value therefore never reached the
field, it stayed at 0, the "config.pollingInterval > 0" guard in
NoboHubBridgeHandler#initialize was never true, and the timeout given to
HubCommunicationThread was always RECOMMENDED_KEEPALIVE_INTERVAL, 14
seconds, whatever the user had set. The two names have differed since
the initial contribution in bc9cf8e.

Rename the field to keepaliveInterval. Renaming the field rather than
the parameter keeps the parameter name that existing thing
configurations already use and that both i18n property files translate.

Add NoboHubBridgeConfigurationTest, which reads the parameter names out
of bridge.xml and asserts each one has a matching field, and document
the parameter in the README now that it takes effect.

Signed-off-by: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com>
@lsiepel lsiepel added the backported A PR that has been cherry-picked to a patch release branch label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported A PR that has been cherry-picked to a patch release branch bug An unexpected problem or unintended behavior of an add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants