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

[knx] Refactoring of KnxCoreTypeMapper and UOM Support #14534

Merged
merged 25 commits into from
Mar 17, 2023

Conversation

holgerfriedrich
Copy link
Member

@holgerfriedrich holgerfriedrich commented Mar 4, 2023

This is a merge of smarthome/j code to current code base.
It will include several PRs from smarthome/j related to UOM and refactoring of KnxCoreTypeMapper.

Carryover from
smarthomej/addons#107
smarthomej/addons#114
smarthomej/addons#203
smarthomej/addons#206
smarthomej/addons#208
smarthomej/addons#219
smarthomej/addons#226
smarthomej/addons#230
smarthomej/addons#279
smarthomej/addons#299
smarthomej/addons#330
smarthomej/addons#349

Also-by: Jan N. Klug [email protected]

Refs: #14502

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.

I didn't check in detail if everything is ok, just a comment while scrolling though the code. But I did not see anything obviously wrong.

@holgerfriedrich holgerfriedrich added enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels Mar 4, 2023
@holgerfriedrich
Copy link
Member Author

@J-N-K I am just integrating smarthomej/addons/#208 which requires ColorUtil. How should I proceed with it? For now add it to the KNX binding, unchanged or stripped to a minimum?

@jlaur
Copy link
Contributor

jlaur commented Mar 6, 2023

@J-N-K I am just integrating smarthomej/addons/#208 which requires ColorUtil. How should I proceed with it? For now add it to the KNX binding, unchanged or stripped to a minimum?

See also comment about ColorUtil here: #14124 (comment)

@holgerfriedrich
Copy link
Member Author

Thanks, @jlaur. It looks like HSBType from core could cover 2 of the 3 occurrences (though the implementation might be different), but it is lacking support for xyY color format used by DPT_Colour_xyY 242.600.

@jlaur
Copy link
Contributor

jlaur commented Mar 6, 2023

It looks like HSBType from core could cover 2 of the 3 occurrences (though the implementation might be different), but it is lacking support for xyY color format used by DPT_Colour_xyY 242.600.

I didn't analyze it further since I was busy with something else at the time, so just took note. Maybe it would be worth adding the missing format to the core HSBType implementation? My initial thought was to compare unit test coverage in the two implementations and possibly detect any differences by new coverage, or have proof that the implementations indeed produce same results.

@J-N-K
Copy link
Member

J-N-K commented Mar 6, 2023

They don‘t provide the same results, otherwise I wouldn’t have implemented it in another way :-)

I would suggest to adjust core to the implementation on SmartHome/J (including the tests).

@J-N-K
Copy link
Member

J-N-K commented Mar 7, 2023

Regarding color: see openhab/openhab-core#3434

Preparation for refactoring KnxCoreTypeMapper.
Carryover from smarthomej/addons#107.
Merge UOM implementations.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
DPT strings for QuantityType now strip off a tailing .0 when decimals
are converted.

Signed-off-by: Holger Friedrich <[email protected]>
Use pattern matching with instanceof operator (new Java17 feature).

Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich holgerfriedrich added the additional testing preferred The change works for the pull request author. A test from someone else is preferred though. label Mar 10, 2023
@holgerfriedrich
Copy link
Member Author

@J-N-K this PR has become quite huge, as it includes the complete restructuring of KNXCoreTypeMapper and the introduction of UoM. Functionally, it seems complete. The other carryover tasks can be handled separately.

I have kept the work split into several commits to match the changes in smarthome/j and added additional commits to fix the unit tests for UoM we had added in this repo only.

One open point is HSB color transform with (x,y,Y) - this is currently failing until we have ColorUtil in the core.

I did not have time yet to check it with my KNX installation.

Introduce KNXChannel class.
Carryover from smarthomej/addons#114.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Configuring incompatible DPT/channel combinations (e.g. DPT 1.005 (alarm) on Contact channels
or DPT 1.019 (windows/door) on Switch channels) is not allowed but was silently ignored.
This PR adds a warning in case incompatible configurations are detected.

Carryover from smarthomej/addons#203.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Replace UoM handling with the implementation from smarthome/j.
Carryover from smarthomej/addons#206.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Carryover from smarthomej/addons#208.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Carryover from smarthomej/addons#219.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Carryover from smarthomej/addons#226.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Carryover from smarthomej/addons#230.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Carryover from smarthomej/addons#279.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Carryover from smarthomej/addons#349.

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
PR openhab#12995 was lost during merge and is now re-added.

Signed-off-by: Holger Friedrich <[email protected]>
@jlaur
Copy link
Contributor

jlaur commented Mar 16, 2023

@holgerfriedrich - LGTM except for #14534 (comment). FYI, @kaikreuzer has reviewed and merged openhab/openhab-core#3434 less than an hour ago, so can be completed now. 🙂

Note that this requires openHAB core >4.0.0.M1.

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

@jlaur I just pushed then new version which uses ColorUtil. I think it will only build after the next core snapshot is built tomorrow morning.

@holgerfriedrich holgerfriedrich added additional testing preferred The change works for the pull request author. A test from someone else is preferred though. and removed additional testing preferred The change works for the pull request author. A test from someone else is preferred though. labels Mar 16, 2023
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.

LGTM

@holgerfriedrich
Copy link
Member Author

Ok, then let's wait for tomorrow. I will rebuild.

Regarding the squash merge of this PR, please take care of the references to the original PRs, please keep @J-N-K in the joint sign-off.
I thought of a rebase commit (as long as we had ~10 commits from the carryover PRs). but with the additional intermediate commits it is too much for the history and probably should be squashed during merge. The single commits can still be found in this ticket.

@holgerfriedrich holgerfriedrich added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Mar 17, 2023
@jlaur jlaur merged commit aae63e9 into openhab:main Mar 17, 2023
@jlaur jlaur added this to the 4.0 milestone Mar 17, 2023
kaikreuzer pushed a commit to openhab/openhab-distro that referenced this pull request Mar 17, 2023
@florian-h05
Copy link
Contributor

@holgerfriedrich & @J-N-K
Huge thanks for your work on the KNX binding, so far works great on my production system. I have checked my (few) -control channels, they still work.

One thing that I noted was that I had a few DPTs wrongly set in my knx.things file, I corrected them and the log said Loading model knx.things (as usual), but it seems that the thing was not updated. If I check inside MainUI, the old DPT is still displayed.

I am not sure whether that‘s a core or a KNX binding problem, but when I change my yamaha.things file, the Yamaha devices go OFFLINE and then ONLINE, my KNX devices don‘t (and they did in the past).

@J-N-K
Copy link
Member

J-N-K commented Mar 19, 2023

Interesting that this error is back, I'm pretty sure I fixed that one. I'll have a look but I have some other things I'm working on before.

renescherer pushed a commit to renescherer/openhab-addons that referenced this pull request Mar 23, 2023
* [knx] Refactoring, add basic support for UOM

Preparation for refactoring KnxCoreTypeMapper.
Carryover from smarthomej/addons#107.
Merge UOM implementations.

* [knx] Adapt tests

DPT strings for QuantityType now strip off a tailing .0 when decimals
are converted.

* [knx] Refactoring

Use pattern matching with instanceof operator (new Java17 feature).

* [knx] Refactoring, performance improvements

Introduce KNXChannel class.
Carryover from smarthomej/addons#114.

* [knx] Add warning for incompatible DPT type

Configuring incompatible DPT/channel combinations (e.g. DPT 1.005 (alarm) on Contact channels
or DPT 1.019 (windows/door) on Switch channels) is not allowed but was silently ignored.
This PR adds a warning in case incompatible configurations are detected.

Carryover from smarthomej/addons#203.

* [knx] Add full support for UoM

Replace UoM handling with the implementation from smarthome/j.
Carryover from smarthomej/addons#206.

* [knx] Refactor KNXCoreTypeMapper, add RGBW and xyY

Carryover from smarthomej/addons#208.

* [knx] Fix RGB conversion

Carryover from smarthomej/addons#219.

* [knx] Remove workarounds obsoleted by Calimero 2.5

Carryover from smarthomej/addons#226.

* [knx] Add parameter for disabling incoming UoM

Carryover from smarthomej/addons#230.

* [knx] Fix fallback to DecimalType in number conversion

Carryover from smarthomej/addons#279.

* [knx] Fix DPT 251.600 decoding

Carryover from smarthomej/addons#349.

* [knx] Fix UoM handling for special types
* [knx] Add test for KNXChannelFactory
* [knx] Update CODEOWNERS for knx
* [knx] Default conversion for DPT 5.001 and 6.001
* [knx] Fix write blocked forever after read from bus

Carryover from smarthomej/addons#299 and smarthomej/addons#330.

* [knx] Use new class ColorUtil from core for HSB conversion

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich holgerfriedrich deleted the pr-knx-smarthomej107ff branch March 28, 2023 19:36
jimtng pushed a commit to jimtng/openhab-distro that referenced this pull request Apr 2, 2023
jimtng pushed a commit to jimtng/openhab-distro that referenced this pull request Apr 2, 2023
@florian-h05
Copy link
Contributor

@J-N-K Any progress regarding this issue?

@J-N-K
Copy link
Member

J-N-K commented Apr 5, 2023

Totally forgot about it. Do you still see it with latest snapshot? There was an issue with the file watcher some time ago that could have caused that problem, but it's fixed now.

@florian-h05
Copy link
Contributor

florian-h05 commented Apr 5, 2023

Unfortunately, this issue persists. The file change was noticed all the time and is still noticed ([el.core.internal.ModelRepositoryImpl] - Loading model 'knx.things'), but the KNX devices/Things don't update.

I am not also encountering another weird behaviour: my -control channels have stopped working, the handleCommand method of DeviceThingHandler is not called for control channels. I have just checked, with SNAPSHOT 3390 from 31th of March, they work.

@J-N-K
Copy link
Member

J-N-K commented Apr 5, 2023

I don't normally use things files. I tried and it works for me when I change the channel-name, but not the configuration or the channel label. Can you confirm that this is specific to the KNX binding? I'm asking because when I only change the label, the updated method in the thing registry is not called and that should affect all bindings, not only KNX.

@florian-h05
Copy link
Contributor

You are right, changing channel name works, but neither channel label nor configuration change work for KNX and MQTT, so it must be unspecific to the KNX binding. And it seems that you already found the cause.

@florian-h05
Copy link
Contributor

Stays just the other problem: My -control channels have stopped working, they worked with this PR. I have just checked, with SNAPSHOT 3390 from 31.03.2023 5AM they work. So this PR can‘t be the cause, but there were two PRs since then. I will try to find out which of those caused that regression.

@J-N-K
Copy link
Member

J-N-K commented Apr 5, 2023

I have no idea what causes this behavior. But it’s a core issue, not an addons-issue. Please open a bug report there.

FordPrfkt pushed a commit to FordPrfkt/openhab-addons that referenced this pull request Apr 20, 2023
* [knx] Refactoring, add basic support for UOM

Preparation for refactoring KnxCoreTypeMapper.
Carryover from smarthomej/addons#107.
Merge UOM implementations.

* [knx] Adapt tests

DPT strings for QuantityType now strip off a tailing .0 when decimals
are converted.

* [knx] Refactoring

Use pattern matching with instanceof operator (new Java17 feature).

* [knx] Refactoring, performance improvements

Introduce KNXChannel class.
Carryover from smarthomej/addons#114.

* [knx] Add warning for incompatible DPT type

Configuring incompatible DPT/channel combinations (e.g. DPT 1.005 (alarm) on Contact channels
or DPT 1.019 (windows/door) on Switch channels) is not allowed but was silently ignored.
This PR adds a warning in case incompatible configurations are detected.

Carryover from smarthomej/addons#203.

* [knx] Add full support for UoM

Replace UoM handling with the implementation from smarthome/j.
Carryover from smarthomej/addons#206.

* [knx] Refactor KNXCoreTypeMapper, add RGBW and xyY

Carryover from smarthomej/addons#208.

* [knx] Fix RGB conversion

Carryover from smarthomej/addons#219.

* [knx] Remove workarounds obsoleted by Calimero 2.5

Carryover from smarthomej/addons#226.

* [knx] Add parameter for disabling incoming UoM

Carryover from smarthomej/addons#230.

* [knx] Fix fallback to DecimalType in number conversion

Carryover from smarthomej/addons#279.

* [knx] Fix DPT 251.600 decoding

Carryover from smarthomej/addons#349.

* [knx] Fix UoM handling for special types
* [knx] Add test for KNXChannelFactory
* [knx] Update CODEOWNERS for knx
* [knx] Default conversion for DPT 5.001 and 6.001
* [knx] Fix write blocked forever after read from bus

Carryover from smarthomej/addons#299 and smarthomej/addons#330.

* [knx] Use new class ColorUtil from core for HSB conversion

Also-by: Jan N. Klug <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[knx] Dimmer Control does not stop after latest 4.0.0.M1 update
5 participants