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

[systeminfo] QuantityTypes and state descriptions cleanup #13804

Merged
merged 7 commits into from
Dec 10, 2022

Conversation

mherwege
Copy link
Contributor

Signed-off-by: Mark Herwege mark.herwege@telenet.be

Changes in core UOM handling make the system uptime channel interpret the minutes as seconds when linking an Number:Time item to the channel. This is because the state description has a wrong UOM. See core issue #3183.
This PR does a cleanup of descriptions and default state descriptions to avoid this issue.

Closes #3183.

Another issue has been discovered #13709 with unit conversions in relation to this binding. I don't see an immediate reason for this in the binding. If you have ideas, please suggest and I will include in this PR.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege mherwege requested review from J-N-K and lolodomo November 29, 2022 08:44
@mherwege mherwege requested a review from svilenvul as a code owner November 29, 2022 08:44
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege mherwege changed the title [systeminfo] State descriptions cleanup [systeminfo] QuantityTypes and state descriptions cleanup Dec 4, 2022
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege mherwege added the work in progress A PR that is not yet ready to be merged label Dec 4, 2022
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege mherwege removed the work in progress A PR that is not yet ready to be merged label Dec 10, 2022
@mherwege
Copy link
Contributor Author

Test fail because DataAmount unit conversions do not work properly, see #3207.
The code is complete from my perspective. If unit conversions for DataAmount are fixed, this can be reviewed and merged.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@lolodomo lolodomo added enhancement An enhancement or new feature for an existing add-on (potentially) not backward compatible labels Dec 10, 2022
@lolodomo
Copy link
Contributor

This a breaking change as users will have to change their item types.

@lolodomo
Copy link
Contributor

Test fail because DataAmount unit conversions do not work properly, see #3207.
The code is complete from my perspective. If unit conversions for DataAmount are fixed, this can be reviewed and merged.

What are we doing ?
Can you comment the failing integration until the conversion is fixed in core framework ? In that case, I could merge your changes.
Or should we wait for a fix in core framework ?

@lolodomo
Copy link
Contributor

Code is good for me, I am just waiting for a successful compilation.

@lolodomo
Copy link
Contributor

lolodomo commented Dec 10, 2022

DataAmount unit conversions do not work properly, see openhab/openhab-core#3207.

Maybe (just an idea) the problem could be that we are using a unit defined by the OH core framework (Units.MEBIBYTE), not an official unit ?

Edit: I see that @J-N-K just proposed a fix in core framework.

@J-N-K
Copy link
Member

J-N-K commented Dec 10, 2022

DataAmount unit conversions do not work properly, see openhab/openhab-core#3207.

Maybe (just an idea) the problem could be that we are using a unit defined by the OH core framework (Units.MEBIBYTE), not an official unit ?

This will also fail. The fix is in openhab/openhab-core#3208. But it should be checked if the binding really delivers kB (1000 B) or kiB (1024 B), same for MB/MiB and GB/GiB and also the data transfer rates. This is quite confusing but hard to change now without breaking existing installations.

@lolodomo
Copy link
Contributor

This will also fail. The fix is in openhab/openhab-core#3208. But it should be checked if the binding really delivers kB (1000 B) or kiB (1024 B), same for MB/MiB and GB/GiB and also the data transfer rates.

Good remark. Hoping @mherwege can retrieve this information.

This is quite confusing but hard to change now without breaking existing installations.

Of course, users will have to change their item types. But as this PR improve something (ability for the users to choose their displayed units), this is acceptable, no ?
By the way, @mherwege already broke something for this binding in OH3.4 so this is just something additional to clearly mentioned in the release notes.
Is it ok for you @J-N-K ?

@J-N-K
Copy link
Member

J-N-K commented Dec 10, 2022

The binding should return the correct value (probably MiB and not MB). My comment was regarding changing 1 MB to 1024 kB in core. Even if I doubt that someone really expects the 1000 instead of 1024 when using these units…

@lolodomo
Copy link
Contributor

lolodomo commented Dec 10, 2022

The binding should return the correct value (probably MiB and not MB). My comment was regarding changing 1 MB to 1024 kB in core. Even if I doubt that someone really expects the 1000 instead of 1024 when using these units…

Understood.
Hopefully, this was not too much used until now in bindings.
But your remark means @mherwege should also think if the best channel pattern should use MB or MiB.

For the 2 other bindings, I hope there is no mismatch between MB and MiB.

@mherwege
Copy link
Contributor Author

mherwege commented Dec 10, 2022

So far, the binding always returned MiB (so 1024 x 1024 bytes), but the state description was MB. I kept the state description, but the methods return MiB (there is even a method in the binding (getSizeInMB) that actually returns MiB, rather than MB. All methods returning data amounts rely on this method. So the calculation is correct.
I opted to keep the default state description, but this will lead to slight changes in value. As an alternative, I could change the default state descriptions to MiB, this will then keep the values constant. I can live with whatever choice.

@mherwege
Copy link
Contributor Author

This a breaking change as users will have to change their item types.

I think you should still be able to just keep a Number item without dimension linked to the channels with dimension. So I am not sure this makes it a breaking change.
The MB vs MiB issue is however breaking, whatever choice we make.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege
Copy link
Contributor Author

The binding should return the correct value (probably MiB and not MB).

Makes sense, so went for that in the last commit.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo
Copy link
Contributor

Can I merge or should I wait for the fix in core framework?

Can you prepare something for the release notes?

@mherwege
Copy link
Contributor Author

@lolodomo Yes, I will prepare something for the release notes. It should work now as long as one does not do unit conversions on DataAmount and sticks with MiB. That is no worse then it was before, and will get better ones the core change is done.
I now also adjusted the README. Should I still push a commit in this PR, or create a separate one for this?

@lolodomo
Copy link
Contributor

I now also adjusted the README. Should I still push a commit in this PR, or create a separate one for this?

Please do it here. I will wait.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@mherwege
Copy link
Contributor Author

Where do I have to push the content for the release notes?

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@lolodomo lolodomo merged commit d068125 into openhab:main Dec 10, 2022
@lolodomo lolodomo added this to the 3.4 milestone Dec 10, 2022
@lolodomo
Copy link
Contributor

Where do I have to push the content for the release notes?

Your PR in openhab-distro is fine and should be sufficient.
I don't know if Kai will ask for help when he will write the 3.4 release notes.

@mherwege mherwege deleted the systeminfo_statedesc branch December 11, 2022 11:45
morph166955 pushed a commit to morph166955/openhab-addons that referenced this pull request Dec 18, 2022
)

* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Ben Rosenblum <rosenblumb@gmail.com>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Dec 24, 2022
)

* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
borazslo pushed a commit to borazslo/openhab-mideaac-addon that referenced this pull request Jan 8, 2023
)

* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
)

* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
)

* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Jan 6, 2024
)

* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
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 (potentially) not backward compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linking item with unit to channel without unit gives different result with 3.4M5
3 participants