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

Unit °dH could not be parsed to a known unit for Item Number:AmountOfSubstance #4307

Open
syntacrsc opened this issue Jul 11, 2024 · 4 comments
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@syntacrsc
Copy link

syntacrsc commented Jul 11, 2024

When configuring an item of type Number:AmountOfSubstance and specifying to use unit °dH (by adding unit="°dH" in channel-linkage) openHab keeps using unit "mol" and issues a warning message to the log such as:

2024-07-08 11:28:33.129 [WARN ] [penhab.core.library.items.NumberItem] - **Unit '°dH' could not be parsed to a known unit. Keeping old unit 'mol' for item** 'gruenbeckRawWater'.

Also See:
https://community.openhab.org/t/problem-with-unit-dh-for-item-of-type-number-amountofsubstance-using-mol-instead-of-dh/157079

Expected Behavior

The system should use the specified unit °dH as per current documentation in chapter “SI (base unit symbols)”
of https://www.openhab.org/docs/concepts/units-of-measurement.html

Current Behavior

openHab issues a warning message and keeps using the default(?) unit mol

Possible Solution

no clue since I'm by far to novice of a developer to say ;-)

Steps to Reproduce (for Bugs)

setup an item such as:
Number:AmountOfSubstance gruenbeckRawWater "Wasserhärte Rohwasser [%.2f %unit%]" {channel="mqtt:topic:MQTTMosquittoBridge:gruenbeckSoftliqSd21:rawWater", unit="°dH"}
and link it to any channel providing a pure number value

Context

Encountered the issue while creating a widget for my water softener
for context details: see https://community.openhab.org/t/gruenbeck-water-softener-widget/157104

Your Environment

openHab 4.2.0 release build
Raspberry pi 5b 8GB
Debian GNU/Linux 12 (bookworm)
OpenJDK 64-Bit Server VM (build 17.0.11+9-Debian-1deb12u1, mixed mode

@syntacrsc syntacrsc added the bug An unexpected problem or unintended behavior of the Core label Jul 11, 2024
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/gruenbeck-water-softener-widget/157104/5

@jlaur
Copy link
Contributor

jlaur commented Jul 13, 2024

I think there is a bug here:

public static final Unit<AmountOfSubstance> DEUTSCHE_HAERTE = addUnit(new TransformedUnit<>("°dH",
(Unit<AmountOfSubstance>) MetricPrefix.MILLI(Units.MOLE).divide(Units.LITRE), MultiplyConverter.of(5.6)));

the type-cast looks suspicious and I think this is part of the explanation. You cannot convert mol to °dH, but you can convert mol/l to °dH. I think the problem is that mole is a unit for the amount of substance:

public static final Unit<AmountOfSubstance> MOLE = addUnit(tech.units.indriya.unit.Units.MOLE);

but moles per liter is a unit of concentration, indicating the number of moles of substance per liter of solution. So the type-cast is forcing DEUTSCHE_HAERTE into a wrong dimension.

I don't think we currently have a dimension for concentration, but this could be added.

@J-N-K might have some more insights/domain knowledge, I have really just been googling this topic without any prior knowledge, so might be complete nonsense. 😉

@jlaur
Copy link
Contributor

jlaur commented Jul 13, 2024

@J-N-K
Copy link
Member

J-N-K commented Jul 13, 2024

So it should be dimensionless (like ppm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

No branches or pull requests

4 participants