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