eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
861 stars 787 forks source link

[UoM] Unknown unit from pattern: MWh #6889

Closed alexf2015 closed 5 years ago

alexf2015 commented 5 years ago

As stated in title conversion to unit MWh is not supported:

2019-02-18 08:03:09.371 [DEBUG] [.e.s.core.types.util.UnitUtils:168  ] - Unknown unit from pattern: MWh

Corresponding item:

Number:Energy           SE_YEAR_PRODUCTION       "Ges. Produktion (Jahr) [%.2f MWh]"      <solarplant>                  (gSolarEdge_LT)                                                { channel="solaredge:generic:se2200:aggregate_year#production" }
alexf2015 commented 5 years ago

In addition if the binding already provides a value with unit MWh it also causes an error:

2018-12-23 18:23:08.844 [DEBUG] [nternal.handler.SolarEdgeBaseHandler] - Channel is to be updated: aggregate_year#consumption: 2.267 MWh
2018-12-23 18:23:08.862 [ERROR] [me.core.internal.events.EventHandler] - Creation of ESH-Event failed, because one of the registered event factories has thrown an exception: Error invoking #valueOf(String) on class 'org.eclipse.smarthome.core.library.types.QuantityType' with value '2.267 MWh'.
java.lang.IllegalStateException: Error invoking #valueOf(String) on class 'org.eclipse.smarthome.core.library.types.QuantityType' with value '2.267 MWh'.
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:190) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.parseType(ItemEventFactory.java:158) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:136) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createStateEvent(ItemEventFactory.java:116) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createEventByType(ItemEventFactory.java:80) ~[?:?]
        at org.eclipse.smarthome.core.events.AbstractEventFactory.createEvent(AbstractEventFactory.java:51) ~[?:?]
        at org.eclipse.smarthome.core.internal.events.EventHandler.createESHEvent(EventHandler.java:121) ~[?:?]
        at org.eclipse.smarthome.core.internal.events.EventHandler.handleEvent(EventHandler.java:95) ~[?:?]
        at org.eclipse.smarthome.core.internal.events.EventHandler.handleEvent(EventHandler.java:72) ~[?:?]
        at org.eclipse.smarthome.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) ~[?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:181) ~[?:?]
        ... 10 more
Caused by: java.lang.IllegalArgumentException: MWh not recognized (in 2.267 MWh at index 6)
        at tec.uom.se.quantity.Quantities.getQuantity(Quantities.java:80) ~[?:?]
        at org.eclipse.smarthome.core.library.types.QuantityType.<init>(QuantityType.java:96) ~[?:?]
        at org.eclipse.smarthome.core.library.types.QuantityType.valueOf(QuantityType.java:139) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.parseSimpleClassName(ItemEventFactory.java:181) ~[?:?]
        ... 10 more
clinique commented 5 years ago

Will push a PR in openhab-core for this

alexf2015 commented 5 years ago

Thanks. I am just a little bit confused why this class exists both in openhab-core and eclipse-smarthome. According to the package name I thought it came from eclipse-smarthome.

5iver commented 5 years ago

https://github.com/eclipse/smarthome/pull/6883

https://community.openhab.org/t/the-road-ahead-reintegrating-esh/64670

maggu2810 commented 5 years ago

See openhab/openhab-core#588