Skip to content

Add RadiationDoseRate dimension#5418

Merged
holgerfriedrich merged 3 commits intoopenhab:mainfrom
weymann:radiation-ambient-dose-unit
Mar 15, 2026
Merged

Add RadiationDoseRate dimension#5418
holgerfriedrich merged 3 commits intoopenhab:mainfrom
weymann:radiation-ambient-dose-unit

Conversation

@weymann
Copy link
Copy Markdown
Member

@weymann weymann commented Mar 13, 2026

SensorCommunity addon provides a radiation sensor which measures μSv/h values. There's no direct Dimension which can be referred in code / thing-types.xml. To provide this in a clean way I added Dimension and Unit to the core component.

If there's a more sophisticated name than than RadiationAmbientDose I'm happy to change it.

When building addon code analysis fails.
I assume this check doesn't know this Dimension yet and it should be fine after integration

[INFO] --- sat:0.18.0:report (sat-all) @ org.openhab.binding.sensorcommunity ---
[INFO] Individual report appended to summary report.
[ERROR] Code Analysis Tool has found:
 1 error(s)!
 0 warning(s)
 1 info(s)
[ERROR] org.openhab.binding.sensorcommunity/src/main/resources/OH-INF/thing/thing-types.xml:[195]
Wert Number:RadiationAmbientDose ist nicht Facet-gültig in Bezug auf Enumeration [Call, Color, Contact, DateTime, Dimmer, Group, Image, Location, Number, Number:Acceleration, Number:AmountOfSubstance, Number:Angle, Number:Area, Number:ArealDensity, Number:CatalyticActivity, Number:Currency, Number:DataAmount, Number:DataTransferRate, Number:Density, Number:Dimensionless, Number:ElectricCapacitance, Number:ElectricCharge, Number:ElectricConductance, Number:ElectricConductivity, Number:ElectricCurrent, Number:ElectricInductance, Number:ElectricPotential, Number:ElectricResistance, Number:EmissionIntensity, Number:Energy, Number:EnergyPrice, Number:Force, Number:Frequency, Number:Illuminance, Number:Intensity, Number:Length, Number:LuminousFlux, Number:LuminousIntensity, Number:MagneticFlux, Number:MagneticFluxDensity, Number:Mass, Number:Power, Number:Pressure, Number:RadiationDoseAbsorbed, Number:RadiationDoseEffective, Number:RadiationSpecificActivity, Number:RadioactiveActivity, Number:SolidAngle, Number:Speed, Number:Temperature, Number:Time, Number:Volume, Number:VolumePrice, Number:VolumetricFlowRate, Player, Rollershutter, String, Switch]. Er muss ein Wert aus der Enumeration sein.

Tested with preliminary versions.
Conversion for different units (Sv/h, μSv/s) works seemless.
image

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

add RadiationAirDose unit

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

add RadiationAmbientDose unit

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Copy link
Copy Markdown
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.

I would suggest RadiationDoseRate as that seems slightly better. And what about the default unit fo µSv/h ?
Otherwise looks good.

Could you also create a PR against the docs repo, to add this to the UoM table with default units ? Maybe better to wait and see if this gets merged.

@jlaur
Copy link
Copy Markdown
Contributor

jlaur commented Mar 13, 2026

I would suggest RadiationDoseRate as that seems slightly better.

That would also align it with RadiationDoseAbsorbed and RadiationDoseEffective.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new quantity dimension and default unit to openHAB Core so addons (e.g., SensorCommunity) can model radiation readings in µSv/h as a proper Number:<Dimension> item type.

Changes:

  • Introduce a new RadiationAmbientDose quantity dimension in core.
  • Add a corresponding derived unit (SIEVERT_PER_HOUR) to the central Units registry.
  • Register RadiationAmbientDose with the default unit provider (i18n/unit mapping) so formatting/conversion can work out of the box.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java Adds SIEVERT_PER_HOUR unit constant for the new radiation quantity.
bundles/org.openhab.core/src/main/java/org/openhab/core/library/dimension/RadiationAmbientDose.java Introduces the new Quantity interface for the dimension.
bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java Registers the default unit mapping for the new dimension.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
@weymann
Copy link
Copy Markdown
Member Author

weymann commented Mar 13, 2026

Thx for your valuable comments. To sum it up:

  • Agreed Dimension name is RadiationDoseRate
  • itemTypeName added to /org.openhab.core.thing/schema/thing/thing-description-1.0.0.xsd
  • after integration I'll adapt openhab-docs\concepts\units-of-measurement.md with new Dimension
  • finally addon can use it

@holgerfriedrich
Copy link
Copy Markdown
Member

Hi @weymann, so far the addition looks good to me.
Two remarks:

  • Could you please submit a PR in the website repo, updating .vuepress/public/schemas/thing-description-1.0.0.xsd? (this should allow the SAT check to succeed once merged)
  • Do you mind to add a small test in UnitsTests.java?

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
@weymann weymann changed the title Add RadiationAmbientDose unit Add RadiationDoseRate dimension Mar 15, 2026
@weymann
Copy link
Copy Markdown
Member Author

weymann commented Mar 15, 2026

Hi @weymann, so far the addition looks good to me. Two remarks:

  • Could you please submit a PR in the website repo, updating .vuepress/public/schemas/thing-description-1.0.0.xsd? (this should allow the SAT check to succeed once merged)
  • Do you mind to add a small test in UnitsTests.java?

Both done.
The error occuring in CI build Java 21 seems not related to this PR, or am I missing something?

Copy link
Copy Markdown
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.

LGTM, thanks!

@holgerfriedrich holgerfriedrich merged commit b7a48af into openhab:main Mar 15, 2026
8 of 9 checks passed
@holgerfriedrich holgerfriedrich added the enhancement An enhancement or new feature of the Core label Mar 15, 2026
@holgerfriedrich holgerfriedrich added this to the 5.2 milestone Mar 15, 2026
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

Development

Successfully merging this pull request may close these issues.

6 participants