I am having an issue parsing my sensor data from an ESP8266. The documentation is not much help (or i’m looking in the wrong direction). So I’d love to hear your views. I made this config by using [SOLVED] MQTT item parsing as an example.
The JSON string published to MQTT looks like this, with the “esp8266_25” part being the MQTT topic:
esp8266_25 {"Humidity":37.70,"Temperature":26.30}
.items entry according to example:
String GreenhouseTemperatureSensor "Temperature: [%s]" (Greenhouses) {mqtt="<[mqtt:/esp8266_25:state:default:JSONPATH($.svalue1):.*\"Temperature:\".*]"}
.sitemap entry
Text item=GreenhouseTemperatureSensor label="[%s]" valuecolor=[>25="orange",>15="green",<=15="blue"]
but Openhab gives me the following error in the log:
ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'GreenhouseTemperatureSensor' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Configuration 'mqtt:/esp8266_25:state:default:JSONPATH($.Temperature):."Temperature:".' is not a valid inbound configuration: Configuration requires 4 or 5 parameters separated by ':'
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:50)[191:org.openhab.core.compat1x:2.1.0.201705081517]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:326)[124:org.eclipse.smarthome.model.item:0.9.0.201705081821]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:298)[124:org.eclipse.smarthome.model.item:0.9.0.201705081821]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:184)[124:org.eclipse.smarthome.model.item:0.9.0.201705081821]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:360)[124:org.eclipse.smarthome.model.item:0.9.0.201705081821]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:286)[123:org.eclipse.smarthome.model.core:0.9.0.201705081821]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:136)[123:org.eclipse.smarthome.model.core:0.9.0.201705081821]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:244)[123:org.eclipse.smarthome.model.core:0.9.0.201705081821]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:315)[123:org.eclipse.smarthome.model.core:0.9.0.201705081821]
at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:211)[99:org.eclipse.smarthome.core:0.9.0.201705081821]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]
It returns a string in my sitemap when I change the .items entry to
String GreenhouseTemperatureSensor "Temperature: [%s]" (Greenhouses) {mqtt="<[mqtt:/esp8266_25:state:default]"}
so which parameter am I missing?
Thanks in advance for your replies!
EDIT: Found out the default state should be replaced by the JSONPATH function, giving this
String GreenhouseTemperatureSensor "Temperature: [%s]" (Greenhouses) {mqtt="<[mqtt:/esp8266_25:state:JSONPATH($.Temperature)]"}
It now functions as it should