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

[hdpowerview] Remove unnecessary init checks and fix Thing status detail #12331

Merged
merged 2 commits into from
Feb 28, 2022

Conversation

fwolter
Copy link
Member

@fwolter fwolter commented Feb 20, 2022

This PR is based on #12330.

@jlaur @andrewfg I made the following changes:

  • Change the Thing status detail of the bridge to COMMUNICATION_ERROR. It was BRIDGE_OFFLINE, which is only intended for child Things showing they cannot go online, because their bridge is offline.
  • Remove the configuration validation. This is done also for textual configuration from OH 3.3.0 on by using the XML constraints.
  • Remove the check in the Things' initialize() if the Bridge type is correct. The UI doesn't let you configure a wrong type and the syntax of the .things file doesn't let you specify a wrong type either, because you can't even configure the binding ID for child Things. For example, use a Bridge of the LCN binding and configure a shade. The child Thing definition is ignored by the framework:
Bridge lcn:pckGateway:myPCHK [ hostname="serial-raspi", port=4114, username="lcn", password="p", mode="native200" ] {
    Thing shade s50150 "Living Room Shade" @ "Living Room" [id="501"]
}
  • Set the Thing status detail to CONFIGURATION_ERROR, when the user didn't configure a bridge.

@jlaur
Copy link
Contributor

jlaur commented Feb 20, 2022

@fwolter, thanks for these improvements. Especially with this change, everything seems to be falling into place:

Remove the configuration validation. This is done also for textual configuration from OH 3.3.0 on by using the XML constraints.

When recently doing 271d027, this kind of validation by the framework is exactly what I was missing.

@fwolter fwolter added awaiting other PR Depends on another PR enhancement An enhancement or new feature for an existing add-on labels Feb 20, 2022
@jlaur jlaur removed the awaiting other PR Depends on another PR label Feb 23, 2022
@jlaur
Copy link
Contributor

jlaur commented Feb 23, 2022

@fwolter - I tested with core 3.3 (latest snapshot, build 2764) and this configuration:

Bridge hdpowerview:hub:hub [host="192.168.0.239"] {
    Thing shade blind1 [id="38196"]
    Thing shade blind2 [id="0"]
    Thing shade blind3 [id="-1"]
    Thing shade blind4 [id="1"]
}

blind1 correctly came ONLINE as configured with a valid ID. blind4 was correctly marked as GONE as ID doesn't exist. But blind2 and blind3 were left with status UNKNOWN while they should probably have been marked as OFFLINE with configuration error?

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Please see comments.

@fwolter
Copy link
Member Author

fwolter commented Feb 27, 2022

But blind2 and blind3 were left with status UNKNOWN while they should probably have been marked as OFFLINE with configuration error?

I would agree. Sounds like a bug in the core.

@fwolter fwolter force-pushed the hdpowerview-validation branch from 25ccad5 to 6dbd5d7 Compare February 27, 2022 16:11
@jlaur
Copy link
Contributor

jlaur commented Feb 27, 2022

I would agree. Sounds like a bug in the core.

So maybe we should park this PR until core is fixed, since right now the validation within the binding is actually needed?

@fwolter
Copy link
Member Author

fwolter commented Feb 27, 2022

Yeah, do you open an issue?

@jlaur
Copy link
Contributor

jlaur commented Feb 28, 2022

Yeah, do you open an issue?

Yes, I can. Seems it will be related to openhab/openhab-core#2682.

@jlaur
Copy link
Contributor

jlaur commented Feb 28, 2022

I would agree. Sounds like a bug in the core.

Getting prepared to create issue - were you able to reproduce the problem also?

@fwolter
Copy link
Member Author

fwolter commented Feb 28, 2022

No, I didn't test it.

@jlaur
Copy link
Contributor

jlaur commented Feb 28, 2022

@fwolter - I did one more test, latest 3.3-snapshot (build 2774) and this time from a clean installation. Now with different result - same config:

Bridge hdpowerview:hub:hub [host="192.168.0.239"] {
    Thing shade blind1 [id="38196"]
    Thing shade blind2 [id="0"]
    Thing shade blind3 [id="-1"]
    Thing shade blind4 [id="1"]
}
  • blind1: ONLINE
  • blind2: UNINITIALIZED, HANDLER_CONFIGURATION_PENDING, "Missing or invalid configuration."
  • blind3: UNINITIALIZED, HANDLER_CONFIGURATION_PENDING, "Missing or invalid configuration."
  • blind4: OFFLINE, GONE, "Shade is unknown to Hub"

I then tried reverting #12364 from your branch to see if config-description vs. config-description-ref would make any difference, but it didn't. I then tried editing the things file in multiple steps to see if dumping a new file would be handled differently than reloading the file after editing, but still everything works correctly.

So I'm sorry, I don't know why my previous test failed. Perhaps my test installation had some left-overs after simply overwriting all files with new snapshot.

Conclusion: No issue to be created and I think this PR is ready to be merged.

@fwolter
Copy link
Member Author

fwolter commented Feb 28, 2022

I think that's the best outcome we can get!

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Thanks for this improvement!

@jlaur jlaur merged commit d35e96a into openhab:main Feb 28, 2022
@jlaur jlaur added this to the 3.3 milestone Feb 28, 2022
@fwolter fwolter deleted the hdpowerview-validation branch February 28, 2022 21:57
NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Apr 27, 2022
…ail (openhab#12331)

* [hdpowerview] Remove unnecessary init checks and fix Thing status detail

Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Nick Waterton <[email protected]>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…ail (openhab#12331)

* [hdpowerview] Remove unnecessary init checks and fix Thing status detail

Signed-off-by: Fabian Wolter <[email protected]>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
…ail (openhab#12331)

* [hdpowerview] Remove unnecessary init checks and fix Thing status detail

Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Andras Uhrin <[email protected]>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
…ail (openhab#12331)

* [hdpowerview] Remove unnecessary init checks and fix Thing status detail

Signed-off-by: Fabian Wolter <[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