Dimmer HTTP Binding plus setting

Tags: #<Tag:0x00007f616d902df8> #<Tag:0x00007f616d902c90>


I want to have to my Dimmer with an slider and percentuage shown on my gui, next to an lamp.

Dimmer Dimmer_EG_EZNord "Esszimmer Nord: [%d %%]" (EG) { http="<[beckhoff:2000:JSONPATH($.DimmEZNord)]" }


Frame label="Etagen" {
        Group item=EG label="Erdgeschoß" icon="groundfloor"

it works. shows me the actual Dimmer value and the percentuage:

I want: possibility to change the dimmer value with the slider!
I wrote an webservice for accessing and dimming the percentuage:
beckhoffURL/write?value=40 (for example to set dimmer to value 40).
how can that be done?

You did only define the receiving (inbound, <) of messages, but not the transmitting (outbound, >)
So try something like this:

Dimmer Dimmer_EG_EZNord "Esszimmer Nord: [%d %%]" (EG) { http="<[beckhoff:2000:JSONPATH($.DimmEZNord)] >[*:PUT:beckhoffURL/write?value=%2$s]" }

Not sure about %2$s, it’s maybe %1$s…

sorry does not work…
receiving the following in apache log: - admin [18/Dec/2017:20:23:29 +0100] "POST /write?value=%2$s HTTP/1.1" 200 1754 "-" "Jakarta Commons-HttpClient/3.1"

tested with PUT and POST and %1$s and %2$s

POST will use another definition:

Dimmer Dimmer_EG_EZNord "Esszimmer Nord: [%d %%]" (EG) { http="<[beckhoff:2000:JSONPATH($.DimmEZNord)] >[*:POST:beckhoffURL/write:default]" }

I’m not sure if this will work either. Take a look at http://docs.openhab.org/addons/bindings/http1/readme.html

thanks for your help. I just got it working with GET:

Dimmer Dimmer_EG_EZNord "Esszimmer Nord: [%d %%]" (EG) { http="<[beckhoff:2000:JSONPATH($.DimmerEZNord)] >[*:GET:https://write.php?dimmer_ez_nord=%2$s{Authorization=Basic xyz}]" }

only problem: I had to enable format in paper UI http settings. After doing this, I got an error in loop:

2017-12-19 21:14:20.043 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.lang.NullPointerException: null
        at java.util.regex.Matcher.getTextLength(Matcher.java:1283) [?:?]
        at java.util.regex.Matcher.reset(Matcher.java:309) [?:?]
        at java.util.regex.Matcher.<init>(Matcher.java:229) [?:?]
        at java.util.regex.Pattern.matcher(Pattern.java:1093) [?:?]
        at org.openhab.io.net.http.HttpUtil.extractCredentials(HttpUtil.java:278) [219:org.openhab.core.compat1x:2.2.0]
        at org.openhab.io.net.http.HttpUtil.executeUrl(HttpUtil.java:181) [219:org.openhab.core.compat1x:2.2.0]
        at org.openhab.io.net.http.HttpUtil.executeUrl(HttpUtil.java:130) [219:org.openhab.core.compat1x:2.2.0]
        at org.openhab.binding.http.internal.HttpBinding.getCacheData(HttpBinding.java:423) [215:org.openhab.binding.http:1.11.0]
        at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:169) [215:org.openhab.binding.http:1.11.0]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [219:org.openhab.core.compat1x:2.2.0]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [219:org.openhab.core.compat1x:2.2.0]
2017-12-19 21:14:21.060 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service

editing http.cfg (comment out format= ) all worked.

http is an OH1 binding, there is no Paper UI setting for this binding?!?

Took a look at Paper UI, in fact there is a configuration option for http.

Just a guess… I think you can only use the paper UI option if leaveing the http.cfg untouched at all (and as you defined a http cache…)

that could be the answer! since changing paper UI http settings, I get errors when saving http.cfg (Showing 5000.0 NumberFormatException but I did not configure any value with 5000.

solved, solution here: HTTP Binding http.cfg error

hi i am trying to get a dimmer working with http binding and an running in to similar issues:

I have included the urls below which i know work. I cant seem to figure out the syntax for the items. The switch (ON /OFF) is working correctly but i am not sure what syntax to use for dimmer.

Thanks in advance. I looked through several topics on the forum on this but its not still not clear to me.

Below are the Urls and items i created in the items files. I kow the urls are correct because when i use them in a browser, they perform the action correctly.

Following item works:
Switch DiningRoomLight “DiningRoom Light” { http=">[ON:POST:] >[OFF:POST:]" }

This one does not:
Dimmer DinningRoomLightValue “DiningRoom Light Value” { http=">[*:GET:]" }

Also what should be the syntax for getting the Staus of the switch and dimmer. The urls are as follows:
Switch status:”,

Dimmer value:

also tried the following but no luck:
Dimmer DinningRoomLightValue “Dinning Room Dim: [%d %%]” {http=">[*:GET:$s] <[]"}

i have some logs attached on this other thread. any guidance will be greatly appreciated

How can I delete the http binding settings in PaperUI.
There are old and unused entries in it

I cleared cache and tmp, but the entried in PaperUIs http config are still there

You can’t. HTTP is a version 1.x binding configured from http.cfg

Most 1.x bindings will have a cached version http.config hanging around as well. Stop openhab, delete the xxx.config file, restart.

That’s what I thought as well:
What what about this then:

Does it do the delete you want?

No, unfortunately not.
I can delete single entries and “safe”.
But after opening it again, they are still there.

Okay, so you can’t use PaperUI

No, but I also never used PaperUI for setting up http config.

In fact, afaik you can use Paper UI for configuration if you never configured http through text file.

Thanks for your reply.
But in the PaperUI config there are several old and obsolete configurations (e.g. with old passwords).

Is there any way to get rid of these and use the http.cfg only?

I can see all the http entries from PaperUI when I run this in the karaf console:
config:list |grep http

But how to get rid f these?

:slight_smile: As a first step, you have to comment out old parameters (or delete them…)

After openHAB has reread http.cfg, you have to use the karaf console:

openhab-cli console

and after logged in to karaf:

openhab> config:edit org.openhab.http
openhab> config:property-list
   parameter_to_delete.updateInterval = <some_value>
   parameter_to_delete.url =  <some_other_value>
openhab> config:property-delete parameter_to_delete.updateInterval 
openhab> config:property-delete parameter_to_delete.url
openhab> config:update

after that step, the parameters should have disappeared :slight_smile: