Unknown unit "m·m" after windspeed conversion

Good morning everybody!

I’m using WeeWx with my weatherstation which publishes the weather data to MQTT. As WeeWx publishes the windspeed using km/h and I want m/s I’v created a rule which does the conversion:

import org.eclipse.smarthome.model.script.ScriptServiceUtil

rule
  "Geschwindigkeit der Windöen von km/h in m/s umrechnen"
when
  Item I_RF_Weatherstation_Wind_Speed changed or
  Item I_RF_Weatherstation_Wind_Speed_Gust changed
then
  var Number SpeedKmh = Float::parseFloat( triggeringItem.state.toString.split( ' ' ).get( 0 ) )
  var MeterPerSecondItem = ScriptServiceUtil.getItemRegistry?.getItem( triggeringItem.name.toString + "_ms" ) as GenericItem
  var Number SpeedMs = SpeedKmh / 3.6

  postUpdate( MeterPerSecondItem, SpeedMs )
end

Sometimes I got this message in my /var/log/openhab2/openhab.log:

2020-05-26 08:25:42.247 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener 'G_RF_Weatherstation (Type=GroupItem, Members=20, State=NULL, Label=Wetterstation, Category=wind, Groups=[G_Roof])' about state update of item I_RF_Weatherstation_Wind_Speed_Gust_ms: Can not compare incompatible units.
java.lang.IllegalArgumentException: Can not compare incompatible units.
        at org.eclipse.smarthome.core.library.types.QuantityType.compareTo(QuantityType.java:174) ~[bundleFile:?]
        at org.eclipse.smarthome.core.library.types.QuantityType.equals(QuantityType.java:156) ~[bundleFile:?]
        at org.eclipse.smarthome.core.items.GenericItem$1.run(GenericItem.java:260) [bundleFile:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
2020-05-26 08:25:42.247 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener 'G_Persistence_MAPDB (Type=GroupItem, Members=57, State=NULL, Label=Persistenz via MAPDB, Category=text, Groups=[G_RMS14])' about state update of item I_RF_Weatherstation_Wind_Speed_Gust_ms: Can not compare incompatible units.
java.lang.IllegalArgumentException: Can not compare incompatible units.
        at org.eclipse.smarthome.core.library.types.QuantityType.compareTo(QuantityType.java:174) ~[bundleFile:?]
        at org.eclipse.smarthome.core.library.types.QuantityType.equals(QuantityType.java:156) ~[bundleFile:?]
        at org.eclipse.smarthome.core.items.GenericItem$1.run(GenericItem.java:260) [bundleFile:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]

Both items I_RF_Weatherstation_Wind_Speed_ms and I_RF_Weatherstation_Wind_Speed_Gust_ms aren’t used in any rule so the error occurs when storing the value / unit in MAPDB.

So I’ve created another rule to get knowledge about the incompatible units which can’t be compared:

rule
  "Debug Wetterstation"
when
  Item I_RF_Weatherstation_Wind_Speed_Gust_ms changed or
  Item I_RF_Weatherstation_Wind_Speed_ms changed or
  Item I_RF_Weatherstation_Wind_Speed_Gust changed or
  Item I_RF_Weatherstation_Wind_Speed changed
then
  logInfo( "dag", "debug: " + triggeringItem.name + ", " + triggeringItem.state )
end

So everytime one of theese items changed this change has been logged. The full log entry from the error message above is:

2020-05-26 08:25:42.237 [INFO ] [g.eclipse.smarthome.model.script.dag] - debug: I_RF_Weatherstation_Wind_Speed_Gust, 5.4717696 km/h
2020-05-26 08:25:42.243 [INFO ] [g.eclipse.smarthome.model.script.dag] - debug: I_RF_Weatherstation_Wind_Speed, 4.02336 km/h
2020-05-26 08:25:42.247 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener 'G_RF_Weatherstation (Type=GroupItem, Members=20, State=NULL, Label=Wetterstation, Category=wind, Groups=[G_Roof])' about state update of item I_RF_Weatherstation_Wind_Speed_Gust_ms: Can not compare incompatible units.
java.lang.IllegalArgumentException: Can not compare incompatible units.
        at org.eclipse.smarthome.core.library.types.QuantityType.compareTo(QuantityType.java:174) ~[bundleFile:?]
        at org.eclipse.smarthome.core.library.types.QuantityType.equals(QuantityType.java:156) ~[bundleFile:?]
        at org.eclipse.smarthome.core.items.GenericItem$1.run(GenericItem.java:260) [bundleFile:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
2020-05-26 08:25:42.247 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener 'G_Persistence_MAPDB (Type=GroupItem, Members=57, State=NULL, Label=Persistenz via MAPDB, Category=text, Groups=[G_RMS14])' about state update of item I_RF_Weatherstation_Wind_Speed_Gust_ms: Can not compare incompatible units.
java.lang.IllegalArgumentException: Can not compare incompatible units.
        at org.eclipse.smarthome.core.library.types.QuantityType.compareTo(QuantityType.java:174) ~[bundleFile:?]
        at org.eclipse.smarthome.core.library.types.QuantityType.equals(QuantityType.java:156) ~[bundleFile:?]
        at org.eclipse.smarthome.core.items.GenericItem$1.run(GenericItem.java:260) [bundleFile:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
2020-05-26 08:25:42.249 [INFO ] [g.eclipse.smarthome.model.script.dag] - debug: I_RF_Weatherstation_Wind_Speed_Gust_ms, 1.51993611 m·m
2020-05-26 08:25:42.250 [INFO ] [g.eclipse.smarthome.model.script.dag] - debug: I_RF_Weatherstation_Wind_Speed_ms, 1.1176 m/s

The unit of the item I_RF_Weatherstation_Wind_Speed_Gust_ms has been set to “m·m” but why? And what type of unit is this? It’s not listed here: https://www.openhab.org/docs/concepts/units-of-measurement.html

The conversion problem doesn’t occur regularly. Yesterday it happens in 100 of 3286 cases.

Thank you for your help and best regards,
Daniel

There is an underlaying bug that has been identified on this in openhab core IIRW, I think it has been addressed but not sure it will available in v 2.5.x

1 Like

If it is in the core unfortunately it will not be fixed in 2.x. They have frozen any core development for 2.x.

It should be only a nuisance level report

In your case, you can avoid the warning by removing your manual QuantityType conversion rule. There is no need to manually convert QuantityTypes, since they can be displayed in whatever compatible unit you’d like. Your wind speed Items are Number:Speed, so in your sitemap, just use something like…

Text item=I_RF_Weatherstation_Wind_Speed label="Wind speed [%.0f m/s]"
Text item=I_RF_Weatherstation_Wind_Speed_Gust label="Wind speed: Gust [%.0f m/s]"

Thanks to everybody!

@5iver: Is there also a way to store the item with unit m/s?

Thanks in advance and best regards,
Daniel

An Item that is defined as Number:Speed will hold it’s state as a QuantityType. You can request the value of the state using any compatible unit for use in rules or display in a UI. So, from the same Item, you can get km/h and m/s, depending on which unit you request. Similarly, Number:Temperature provides Celsius, Fahrenheit, Kelvin, etc. Does that make more sense?