[SOLVED] Get http request

Hi,

I have the following item:
String e2_chambre_rue_Hue “E2 Chambre rue Hue group” { http="<[http://192.168.0.111/api/ZzSuumxSfih6j7-mzAAxcX5xO1BsFiA4dvyp8LTY/groups/4/]" }

When I save it, I get the following error:
14:41:50.457 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type ‘http’ of item ‘e2_chambre_rue_Hue’ could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig ‘http://192.168.0.111/api/ZzSuumxSfih6j7-mzAAxcX5xO1BsFiA4dvyp8LTY/groups/4/’ doesn’t represent a valid in-binding-configuration. A valid configuration is matched by the RegExp ‘(.?)({.})?:(?!//)(\d*):(.*)’
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:50)[182:org.openhab.core.compat1x:2.1.0]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:325)[123:org.eclipse.smarthome.model.item:0.9.0.b5]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:297)[123:org.eclipse.smarthome.model.item:0.9.0.b5]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:182)[123:org.eclipse.smarthome.model.item:0.9.0.b5]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:367)[123:org.eclipse.smarthome.model.item:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:286)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:136)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:234)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:297)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:206)[98:org.eclipse.smarthome.core:0.9.0.b5]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]

I don’t understand because this url is working in a browser and this is a standard url…

According to the docs an incoming HTTP config has the following format:

http="<[<url>:<refreshintervalinmilliseconds>:<transformationrule>]"

You are missing the refresh interval and transformation rule.

I get the same error. What I miss is the transformation rule to use when obtaining a single number from the url. How can I parse the value retrieved from url “http://x.x.x.x/now” that deliver an integer?

Post your item.
Post the FULL http response and highlight the number that you want

Hello,

Writing “http://192.168.1.201/now” in my browser returns realtime power usage as an integer wattage, for instance “4732”. This number I would like to present in a gauge, powerNow.

This is the entry in my items.items file:

Number powerNow “Power [%.2f °kW]” { http=“<[http://192.168.1.201/now:10000:javascript(getValue.javascript)]” }

I have also defined a thing:

Thing hanmodul “Power [%.2f °kW]” { http=“<[http://192.168.1.201/now:10000:javascript(getValue.javascript)]” }

In my /etc/openhab2/services/http.cfg i have included (not needed in 2.0?):

timeout=500
granularity=10000
hanmodul.url=“http://192.168.1.201/now
hanmodul.updateInterval=10000

I am certain this is inciorrect, but cant figure out how to correct it.

You don’t need to define a thing. Delete it.

Your item should be:

Number powerNow "Power [%.2f °kW]" { http="<[hanmodul:10000:JS(getValue.js)]" }

Note that I have also changed the javascript bits.
If the HTTP ONLY return this number then you don’t even need the transformation:

Number powerNow "Power [%.2f °kW]" { http="<[http://192.168.1.201/now:10000:REGEX((.*))]" }
1 Like

@vzorgub: Thanks a lot :smiley: This was very helpful, I will try right away

@vzorglub: The value is now read as shown in the log :slight_smile:

2018-10-30 12:58:42.545 [vent.ItemStateChangedEvent] - powerNow changed from 9152 to 9408

However, how may I show that value in my UI?

@vzorglub::smiley: Thanks, success !

Please mark the thread as solved, thanks

@vzorglub: Sorry, but I asked my question in an open issue, I didnt start it :frowning: How can I close it?

Don’t worry about it