-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Conversation
Signed-off-by: Gaël L'hopital <[email protected]>
This reverts commit cdfceb1.
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]>
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The {@link EnergyDensity} defines the dimension for prices | |
* The {@link EnergyDensity} defines the dimension for energy density |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see: #4346
There was a problem hiding this comment.
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 :-))
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
Signed-off-by: Gaël L'hopital <[email protected]>
This PR would also 'require' updates to other repo's:
|
@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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this comment
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 |
There was a problem hiding this 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?
@lsiepel should we delay this (i.e., shift to 5.0) because of further implications to other parts of OH? |
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. |
Signed-off-by: Gaël L'hopital <[email protected]>
Done |
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? |
There was a problem hiding this 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.
@florian-h05 @lsiepel Can you explain what is the required change to units.js mentioned above? Will you take care? |
Refs openhab/openhab-core#4467. Signed-off-by: Florian Hotze <[email protected]>
i have taken care: openhab/openhab-webui#2912 |
Refs openhab/openhab-core#4467. Signed-off-by: Florian Hotze <[email protected]>
Ping @magx2 for salus binding |
Thanks! |
Partially solves #4294 and #4143
Resolves #4307
Resolves #4346