Dimmer with http binding

Hi all,

I have tried all options like “CHANGED:GET”, “CHANGED:POST” and “INCREASE:GET” in http binding to do dimmer. But I couldn’t able to make it work.

Can you give any suggestion how to dimming with http.

the binding code in items
on/off

Switch  test1 "test" (GF_Living) { http=">[ON:GET:http://127.0.0.1/cgi-bin/test.cgi?on] >[OFF:GET:http://127.0.0.1/cgi-bin/test.cgi?off]" }

dimming

Dimmer Intensity "Intensity[%d]" <slider> (GF_Living) { http=">[INCREASE:GET:http://127.0.0.1/cgi-bin/test.cgi?on] }

For testing I have passed on in http://127.0.0.1/cgi-bin/test.cgi?on . But actually I have to pass slider value instead of on. Is it possible? If possible how can I do it?

please help asap!

I’m just in the middle of doing the same thing. This is how I have set up the bindings and they are working:

[*:GET:http://user:password@192.168.32.102/api/callAction?deviceID=402&name=setValue&arg1=%2$s] <[http://user:password@192.168.32.102/api/devices/402:10000:JSONPATH($.properties.value)]

As you can see I’m doing both, writing and reading to get feedback as well, as I’m controlling the dimmers from Fibaro HC2 as well.

I’m still working on getting the feedback actually update the slider information in OpenHAB though

Ok .Thank you.

I will try.

Hi,
How can I enable slider button .I have tried to create slider button. But I am able to get only 10% and 100% and i am not remaining values. That means if I click increase button it increase to 10% and if click again it goes to 100%. Same with decrease button. How can i get other values.

that depends on the lights you are using. Example in my setup I use the hue lux bulbs and my dimmers look like this.

Dimmer Light_LivRoom_Steps_Dim “Steps Dimmer” (LivRoom, Lights, LivRoom_AllLights, gDashboard) {hue=“1;brightness;40”}

The particule part is brightness;40, what this is doing is setting the value of the light state between 0 - 255. so weather I hit up or down its going by 40. Note thie is on the openhab html page. This is not however a percentage value. As far as sending you could do it very simply by doing this

http://192.168.1.10:8080/CMD?Light_LivRoom_Steps_Dim=50

This will send a PERCENTAGE VALUE to be sent to the light bulb.

Again I’m not sure which light bulbs you are using but this is how I do it with the Hue lux bulbs and the hue binding.

Ok Thanks for suggestion.

Its ok but I want like this if I press increase button in slider it should increase gradually like 10%,20%,etc so on upto 100%. How can I achieve this?

The lights that you are using, the binding might actually need a percentage value. The other suggestion I have would be creating a rule. Heres a “dummy” switch I have created that controls 2 lights within my living room.

Dimmer Light_LivRoom_AllLights_Dim  	<hue>	(LivRoom_AllLights, gDashboard)

Here is the rule I have.

rule "Living Room Dimmer"
	when
		Item Light_LivRoom_AllLights_Dim received command
	then
		var Number bVal = 0
		if(Light_LivRoom_AllLights_Dim.state instanceof PercentType) bVal = Light_LivRoom_AllLights_Dim.state as PercentType 
			
		if(receivedCommand==INCREASE) bVal = bVal + 25
		if(receivedCommand==DECREASE) bVal = bVal - 25

		if(bVal<0)   bVal = 0
		if(bVal>100) bVal = 100
		
		sendCommand(Light_LivRoom_Steps_Dim, bVal)
		sendCommand(Light_LivRoom_Candles_Dim, bVal)
		
		if(bVal>0) postUpdate(Light_LivRoom_AllLights_Sw, ON)
		if(bVal==0) postUpdate(Light_LivRoom_AllLights_Sw, OFF)
end

As you can see everytime I am hitting down i am diming the lights by 25%. The value is set as a PercentType. I hope this helps.

Hello,I want to get the value of the Dimmer and send it via TCP Bindings.But it does not work.Could you give some help?Thanks very much.Following is the Bindings code:

Hey Robert,

how am I suppose to write the http binding for it??

Kindly note that I am using open hab as a client which sends the http requests to my esp 8266 server.

Hi Robert,

I am very new to Openhab2 and was trying to use the slider for my led using esp8266 but not able to pass the slider value into the URL.
When I am using static URL it is working.
Dimmer MyDimmer “Dimmer [%d %%]” { http=">[CHANGED:GET:http://10.0.0.10:8010/led?led1=50]" }
But this is not working
Dimmer MyDimmer “Dimmer [%d %%]” { http=">[CHANGED:GET:http://10.0.0.10:8010/led?led1=%2$d]" }

Please let me know where I am making the mistake.

It is working now after enabling the HTTP binding Format option to true from Paper UI.

1 Like

very strange… in openhab 2.2.0-SNAPSHOT when I enabled HTTP Binding Format in the binding settings for http, I got in a loop the following error:

2017-12-19 21:14:21.060 [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]

after editing my http.cfg loop with errors stops. and binding format works!

hi robert,

did you get this working? i am running in to same problem