openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

[HTTP binding] Errors in Groups since OH 2.5 #5923

Closed Markkuuss closed 4 years ago

Markkuuss commented 4 years ago

Since the update to OH 2.5 there are errors in HTTP binding in regard to groups and units of measurements.

What worked in OH 2.4 now results in the following errors:

2019-12-25 00:05:46.588 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener 'org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl@10be966' about state update of item Test_Rainrate: 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_222]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2019-12-25 00:05:46.588 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener 'Test_Weather (Type=GroupItem, Members=6, State=NULL, Label=Weather Data, Category=sun_clouds)' about state update of item Test_Rainrate: 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_222]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2019-12-25 00:05:46.588 [ERROR] [me.core.internal.events.EventHandler] - Dispatching/filtering event for subscriber 'org.eclipse.smarthome.core.events.EventSubscriber' failed: 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) ~[?:?]
    at org.eclipse.smarthome.core.library.types.QuantityType.equals(QuantityType.java:156) ~[?:?]
    at org.eclipse.smarthome.core.items.GenericItem.applyState(GenericItem.java:234) ~[?:?]
    at org.eclipse.smarthome.core.items.GenericItem.setState(GenericItem.java:219) ~[?:?]
    at org.eclipse.smarthome.core.library.items.NumberItem.setState(NumberItem.java:121) ~[?:?]
    at org.eclipse.smarthome.core.internal.items.ItemUpdater.receiveUpdate(ItemUpdater.java:75) ~[?:?]
    at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:52) ~[?:?]
    at org.eclipse.smarthome.core.internal.events.EventHandler.lambda$0(EventHandler.java:155) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

With the following item definition my error can be reproduced very well. For this, the REGEX transformation is required in addition to HTTP binding.

If you run the code for a while, the errors listed above will appear sporadically one after the other.

Group           Test_Weather        "Weather Data"          <sun_clouds>                    
Number:Temperature  Test_Temperature    "Temperatur [%.1f °C]"      <temperature>   (Test_Weather)  { http="<[https://www.random.org/decimal-fractions/?num=1&dec=1&col=1&format=html&rnd=new:3000:REGEX(.*numbers:.*?\\s*(\\d+.\\d+)\\s*.*)]" }
Number:Dimensionless    Test_Humidity       "Humidity [%d %%]"      <humidity>  (Test_Weather)  { http="<[https://www.random.org/decimal-fractions/?num=1&dec=1&col=1&format=html&rnd=new:3000:REGEX(.*numbers:.*?\\s*(\\d+.\\d+)\\s*.*)]" }
Number:Pressure     Test_Airpressure    "Air Pressure [%.1f hPa]"   <pressure>  (Test_Weather)  { http="<[https://www.random.org/decimal-fractions/?num=1&dec=1&col=1&format=html&rnd=new:3000:REGEX(.*numbers:.*?\\s*(\\d+.\\d+)\\s*.*)]" }
Number:Speed        Test_Rainrate       "Rain Rate [%.1f mm/h]"     <rain>      (Test_Weather)  { http="<[https://www.random.org/decimal-fractions/?num=1&dec=1&col=1&format=html&rnd=new:3000:REGEX(.*numbers:.*?\\s*(\\d+.\\d+)\\s*.*)]" }
Number:Speed        Test_Wind       "Wind [%.1f km/h]"      <wind>      (Test_Weather)  { http="<[https://www.random.org/decimal-fractions/?num=1&dec=1&col=1&format=html&rnd=new:3000:REGEX(.*numbers:.*?\\s*(\\d+.\\d+)\\s*.*)]" }
Number:Intensity    Test_Solarradiation "Solar Radiation [%d W/m²]" <solarplant>    (Test_Weather)  { http="<[https://www.random.org/decimal-fractions/?num=1&dec=1&col=1&format=html&rnd=new:3000:REGEX(.*numbers:.*?\\s*(\\d+.\\d+)\\s*.*)]" }

In my opinion this is due to a bug in the HTTP binding. There is a short discussion about this in the forum, which has not yet helped to solve the problem. https://community.openhab.org/t/uom-errors-in-groups-since-oh-2-5/88430/23

9037568 commented 4 years ago

OH1 bindings don't do UoM.

Markkuuss commented 4 years ago

What a pity, it's amazing that it worked perfectly with version 2.4.

Maybe it should be included in the documentation.