openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[fmiweather] Cannot add discovered things from inbox in OH3 / cannot create things manually #8971

Closed ssalonen closed 3 years ago

ssalonen commented 3 years ago

OK## Expected Behavior

Current Behavior

When trying to add discovered FMI weather thing, it fails with an error in the logs:

23:56:11.518 [INFO ] [ig.discovery.internal.PersistentInbox] - Added new thing 'fmiweather:observation:station_100996_Helsinki_Harmaja' to inbox.
23:56:11.518 [INFO ] [smarthome.event.InboxAddedEvent      ] - Discovery Result with UID 'fmiweather:observation:station_100997_Kirkkonummi_Makiluoto' has been added.
23:56:11.518 [INFO ] [ig.discovery.internal.PersistentInbox] - Added new thing 'fmiweather:observation:station_100997_Kirkkonummi_Makiluoto' to inbox.
23:56:32.782 [ERROR] [enhab.core.thing.binding.ThingFactory] - Thing factory (class org.openhab.binding.fmiweather.internal.HandlerFactory) returned null on create thing when it reports to support the thing type (fmiweather:forecast).
23:56:32.782 [WARN ] [ig.discovery.internal.PersistentInbox] - Cannot create thing. No binding found that supports creating a thing of type fmiweather:forecast.

In addition, it is not possible to create the things using MainUI

image

Steps to Reproduce (for Bugs)

  1. Settings -> Things -> Inbox -> select any FMI weather thing -> Add as thing. OK to accept suggested thing name
  2. Error appears

Context

FMI weather unusable in openHAB3

Tried with fresh manual install of openHAB 2.5.10, work flawlessly there so it appears to be regression in OH3.

Your Environment

Fedora linux

openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment 18.9 (build 11.0.9+11)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11, mixed mode, sharing)

openHAB 3.0 M2, manual runtime installation, with openhab-addons-3.0.0.M2.kar in addons. Only FMI weather binding installed

ssalonen commented 3 years ago

After creating things manually using examples in docs, the things do get added as ONLINE but values are NULL according to http://localhost:8080/#!/settings/items/

Logs seem to indicate these manually created things work as they should though

09:13:13.430 [TRACE] [ing.fmiweather.internal.client.Client] - Found value wawa=0.0 @ time=1604733000 for location 101004
09:13:13.430 [TRACE] [ing.fmiweather.internal.client.Client] - Found value wawa=null @ time=1604733600 for location 101004
09:13:13.431 [DEBUG] [ing.fmiweather.internal.client.Client] - Request org.openhab.binding.fmiweather.internal.client.ObservationRequest@188b1634 translated to url https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::multipointcoverage&starttime=2020-11-07T06:40:00Z&endtime=2020-11-07T07:20:00Z&timestep=10&fmisid=101004&parameters=t2m,rh,wd_10min,ws_10min,wg_10min,p_sea,r_1h,snow_aws,vis,n_man,wawa. Response: FMIResponse({Location(name="Helsinki Kumpula", id="101004", latitude=60.20307, longitude=24.96131)={wg_10min=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[6.4, 6.1, 5.4, 5.9, null]), wd_10min=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[244.0, 233.0, 238.0, 239.0, null]), vis=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[50000.0, 50000.0, 50000.0, 50000.0, null]), r_1h=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[null, null, 0.0, null, null]), wawa=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[0.0, 0.0, 0.0, 0.0, null]), n_man=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[0.0, 0.0, 0.0, 0.0, null]), rh=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[90.0, 90.0, 89.0, 88.0, null]), p_sea=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[1019.7, 1019.7, 1019.6, 1019.6, null]), snow_aws=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[0.0, 0.0, 0.0, 0.0, null]), ws_10min=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[4.3, 4.4, 4.1, 4.1, null]), t2m=ResponseDataValues(timestampsEpochSecs=[1604731200, 1604731800, 1604732400, 1604733000, 1604733600], values=[6.4, 6.4, 6.7, 6.9, null])}})
cweitkamp commented 3 years ago

The discovery indeed does not support a forecast thing type - even if they are added as discovery results later in the code:

https://github.com/openhab/openhab-addons/blob/39cb4fcaa3cd2d8ecdbb652da597c4faa24b7d64/bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/discovery/FMIWeatherDiscoveryService.java#L61

https://github.com/openhab/openhab-addons/blob/39cb4fcaa3cd2d8ecdbb652da597c4faa24b7d64/bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/discovery/FMIWeatherDiscoveryService.java#L141

ssalonen commented 3 years ago

@cweitkamp oddly I get the same error with both thing types, observation and forecast:

09:52:39.648 [ERROR] [enhab.core.thing.binding.ThingFactory] - Thing factory (class org.openhab.binding.fmiweather.internal.HandlerFactory) returned null on create thing when it reports to support the thing type (fmiweather:forecast).
09:52:39.648 [WARN ] [ig.discovery.internal.PersistentInbox] - Cannot create thing. No binding found that supports creating a thing of type fmiweather:forecast.
09:52:45.209 [ERROR] [enhab.core.thing.binding.ThingFactory] - Thing factory (class org.openhab.binding.fmiweather.internal.HandlerFactory) returned null on create thing when it reports to support the thing type (fmiweather:observation).
09:52:45.210 [WARN ] [ig.discovery.internal.PersistentInbox] - Cannot create thing. No binding found that supports creating a thing of type fmiweather:observation.
cweitkamp commented 3 years ago

We found the reason. See https://github.com/openhab/openhab-core/commit/aae207bfe95da3b0b7eaaf08e4beda546a1c228d#r43959474

Thanks to @J-N-K for fixing it.

ssalonen commented 3 years ago

Pheew, that was advanced, thank you very much!

@cweitkamp is your comment on "The discovery indeed does not support a forecast thing type" still relevant?

cweitkamp commented 3 years ago

The list of supported thing types is used in the DiscoveryServiceRegistry to create a global list. But I am afraid it currently will not be used further.

To be safe I would recommend to add the missing thing type for the bindings discovery service.

ssalonen commented 3 years ago

@cweitkamp I have hard time reading the core commit. Would it explain the null items as well?

cweitkamp commented 3 years ago

@ssalonen Sry, I currently have no idea. But it might be related because the fix commited by @J-N-K prevents this exception during XML parsing:

2020-11-07 12:31:53.540 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/OH-INF/thing/thing-types.xml' in module 'org.openhab.binding.fmiweather' could not be parsed: The attribute 'advanced' of the node 'channel-group-type' is not supported or exists multiple times!
---- Debugging information ----
message             : The attribute 'advanced' of the node 'channel-group-type' is not supported or exists multiple times!
class               : org.openhab.core.thing.xml.internal.ChannelGroupTypeXmlResult
required-type       : org.openhab.core.thing.xml.internal.ChannelGroupTypeXmlResult
converter-type      : org.openhab.core.thing.xml.internal.ChannelGroupTypeConverter
path                : /thing-descriptions/channel-group-type[3]
line number         : 282
class[1]            : java.util.ArrayList
required-type[1]    : java.util.ArrayList
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[2]            : org.openhab.core.thing.xml.internal.ThingDescriptionList
required-type[2]    : org.openhab.core.thing.xml.internal.ThingDescriptionList
converter-type[2]   : org.openhab.core.thing.xml.internal.ThingDescriptionConverter
version             : 1.4.13
-------------------------------
com.thoughtworks.xstream.converters.ConversionException: The attribute 'advanced' of the node 'channel-group-type' is not supported or exists multiple times!
---- Debugging information ----
message             : The attribute 'advanced' of the node 'channel-group-type' is not supported or exists multiple times!
class               : org.openhab.core.thing.xml.internal.ChannelGroupTypeXmlResult
required-type       : org.openhab.core.thing.xml.internal.ChannelGroupTypeXmlResult
converter-type      : org.openhab.core.thing.xml.internal.ChannelGroupTypeConverter
path                : /thing-descriptions/channel-group-type[3]
line number         : 282
class[1]            : java.util.ArrayList
required-type[1]    : java.util.ArrayList
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[2]            : org.openhab.core.thing.xml.internal.ThingDescriptionList
required-type[2]    : org.openhab.core.thing.xml.internal.ThingDescriptionList
converter-type[2]   : org.openhab.core.thing.xml.internal.ThingDescriptionConverter
version             : 1.4.13
-------------------------------
    at org.openhab.core.config.xml.util.ConverterAttributeMapValidator.readValidatedAttributes(ConverterAttributeMapValidator.java:117) ~[?:?]
    at org.openhab.core.config.xml.util.ConverterAttributeMapValidator.readValidatedAttributes(ConverterAttributeMapValidator.java:82) ~[?:?]
    at org.openhab.core.thing.xml.internal.AbstractDescriptionTypeConverter.unmarshal(AbstractDescriptionTypeConverter.java:184) ~[?:?]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:117) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50) ~[bundleFile:1.4.13]
    at org.openhab.core.thing.xml.internal.ThingDescriptionConverter.unmarshal(ThingDescriptionConverter.java:53) ~[?:?]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1404) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1383) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1334) ~[bundleFile:1.4.13]
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1288) ~[bundleFile:1.4.13]
    at org.openhab.core.config.xml.util.XmlDocumentReader.readFromXML(XmlDocumentReader.java:106) ~[bundleFile:?]
    at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:396) [bundleFile:?]
    at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:382) [bundleFile:?]
    at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:347) [bundleFile:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
    at java.lang.Thread.run(Unknown Source) [?:?]