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

Add some requested new units : J/m², gr/ft³,gr #4467

Merged
merged 16 commits into from
Dec 10, 2024

Conversation

clinique
Copy link
Contributor

@clinique clinique commented Dec 3, 2024

Partially solves #4294 and #4143
Resolves #4307
Resolves #4346

@clinique clinique requested a review from a team as a code owner December 3, 2024 10:20
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link EnergyDensity} defines the dimension for prices
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The {@link EnergyDensity} defines the dimension for prices
* The {@link EnergyDensity} defines the dimension for energy density

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -91,13 +92,15 @@ public final class Units extends CustomUnits {
public static final Unit<AmountOfSubstance> MOLE = addUnit(tech.units.indriya.unit.Units.MOLE);
public static final Unit<Volume> LITRE = addUnit(tech.units.indriya.unit.Units.LITRE);
@SuppressWarnings("unchecked")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this suppression still needed?

Copy link
Contributor Author

@clinique clinique Dec 4, 2024

Choose a reason for hiding this comment

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

Tried to get rid of them but tests fails then.

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link EnergyDensity} defines the dimension for prices
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a link could be added like for some of the other dimensions? E.g. https://en.wikipedia.org/wiki/Energy_density

Copy link
Contributor

Choose a reason for hiding this comment

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

Reading that, is this dimension correct for e.g. Wh/m²? That seems to be something like Wh/L, i.e. per volume:

Energy density refers to the quantity of energy in a material per unit of volume.

whereas Wh/m² is more like unit of energy in relation to surface area?

I don't know the answers yet, only the questions. 😄

Copy link
Contributor

@lsiepel lsiepel Dec 3, 2024

Choose a reason for hiding this comment

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

Please see: #4346

Copy link
Contributor Author

@clinique clinique Dec 4, 2024

Choose a reason for hiding this comment

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

Yes, you're correct; it needs to be reworded. Made some more searches and it should be named Surface Energy (surprise :-))

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, both surface energy and radiant exposure can be expressed in unit J/m², but I'm wondering if https://en.wikipedia.org/wiki/Radiant_exposure is closer to the requested dimension in the linked issue? I guess it depends on the context. A quick ChatGTP session:

  • Radiant exposure (denoted as 𝐻) is the energy received per unit area of a surface from radiation over a given time period.
  • Surface energy (𝛾) is the amount of energy per unit area required to create a new surface. It quantifies the cohesive forces between molecules at a material's surface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agreed. These notions use the same measure and we can understand these are the two sides of the same coin. You're correct that in an home automation context, we're more likely to talk about radiant exposure than surface energy (even if yesterday I did even not know these :-P)

Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
@@ -433,6 +434,7 @@ public static Map<Class<? extends Quantity<?>>, Map<SystemOfUnits, Unit<? extend
addDefaultUnit(dimensionMap, Radioactivity.class, Units.BECQUEREL);
addDefaultUnit(dimensionMap, SolidAngle.class, Units.STERADIAN);
addDefaultUnit(dimensionMap, Speed.class, SIUnits.KILOMETRE_PER_HOUR, ImperialUnits.MILES_PER_HOUR);
addDefaultUnit(dimensionMap, SurfaceEnergy.class, Units.WATT_HOUR_PER_SQUARE_METRE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider if default unit should be J/m²? I'm not sure what is most common, but that seems to be the SI unit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct, the default unit should rather be J/m2. Added this one and changed accordingly.

Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
@lsiepel
Copy link
Contributor

lsiepel commented Dec 4, 2024

This PR would also 'require' updates to other repo's:

@holgerfriedrich holgerfriedrich added the enhancement An enhancement or new feature of the Core label Dec 4, 2024
@clinique
Copy link
Contributor Author

clinique commented Dec 5, 2024

@lsiepel : PR created for documentation

@@ -91,13 +92,15 @@ public final class Units extends CustomUnits {
public static final Unit<AmountOfSubstance> MOLE = addUnit(tech.units.indriya.unit.Units.MOLE);
public static final Unit<Volume> LITRE = addUnit(tech.units.indriya.unit.Units.LITRE);
@SuppressWarnings("unchecked")
public static final Unit<AmountOfSubstance> DEUTSCHE_HAERTE = addUnit(new TransformedUnit<>("°dH",
(Unit<AmountOfSubstance>) MetricPrefix.MILLI(Units.MOLE).divide(Units.LITRE), MultiplyConverter.of(5.6)));
public static final Unit<Dimensionless> DEUTSCHE_HAERTE = addUnit((Unit<Dimensionless>) new TransformedUnit<>("°dH",
Copy link
Contributor

@lsiepel lsiepel Dec 5, 2024

Choose a reason for hiding this comment

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

Might be perfectly sane, but wondering why is this changed to Dimensionless?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See this comment

@jimtng
Copy link
Contributor

jimtng commented Dec 6, 2024

Suggestion: make the PR title list all the new units added, or at least hint at what type of units were added. It would make for a much more informative release log

@clinique clinique changed the title Add some requested new units Add some requested new units : J/m², gr/ft³,gr Dec 6, 2024
@clinique
Copy link
Contributor Author

clinique commented Dec 6, 2024

Suggestion: make the PR title list all the new units added, or at least hint at what type of units were added. It would make for a much more informative release log

Done

Copy link
Member

@holgerfriedrich holgerfriedrich left a comment

Choose a reason for hiding this comment

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

Overall, LGTM.
Could you please cover JOULE_PER_SQUARE_METRE in the tests, or did I overlook it?

@holgerfriedrich
Copy link
Member

@lsiepel should we delay this (i.e., shift to 5.0) because of further implications to other parts of OH?
#4467 (comment)

@lsiepel
Copy link
Contributor

lsiepel commented Dec 8, 2024

@lsiepel should we delay this (i.e., shift to 5.0) because of further implications to other parts of OH? #4467 (comment)

My first thought was to merge it so future addons would be compatible with 4.3.x core api’s but as 5.0 would be breaking anyway (Java 21) there is no point.
So I guess it is better to merge after 4.3.0 release

Signed-off-by: Gaël L'hopital <[email protected]>
@clinique
Copy link
Contributor Author

clinique commented Dec 9, 2024

Overall, LGTM. Could you please cover JOULE_PER_SQUARE_METRE in the tests, or did I overlook it?

Done

@jlaur
Copy link
Contributor

jlaur commented Dec 9, 2024

So I guess it is better to merge after 4.3.0 release

Please note that openhab/openhab-docs#2420 was already merged, so if this PR is not merged, that PR should be reverted. If there is anything breaking in this PR (I don't see it?), perhaps the non-breaking changes could be extracted to a separate PR?

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.

In that case maybe @holgerfriedrich can merge this. Not much risk.

@holgerfriedrich holgerfriedrich merged commit 241e55f into openhab:main Dec 10, 2024
4 of 5 checks passed
@holgerfriedrich
Copy link
Member

@florian-h05 @lsiepel Can you explain what is the required change to units.js mentioned above? Will you take care?

@holgerfriedrich holgerfriedrich added this to the 4.3 milestone Dec 10, 2024
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Dec 11, 2024
@florian-h05
Copy link
Contributor

i have taken care: openhab/openhab-webui#2912
Those unit definitions are used for the Item editor to suggest dimensions and avalable units.

florian-h05 added a commit to openhab/openhab-webui that referenced this pull request Dec 11, 2024
@lsiepel
Copy link
Contributor

lsiepel commented Dec 11, 2024

Ping @magx2 for salus binding

@magx2
Copy link
Contributor

magx2 commented Dec 11, 2024

Ping @magx2 for salus binding

Thanks!

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 of the Core
Projects
None yet
7 participants