[SOLVED] Issue with HTTP command not being sent on item change

I’m trying to implement volume control via a dimmer (and thus slider in UI).
Setting volume on device is controlled by a HTTP get:

http://192.168.88.189/httpapi.asp?command=setPlayerCmd:vol:100

Validated this call in Postman and works like a charm. Put this into an item configuration (Dimmer with HTTP binding):

Dimmer ieast_volume2 {http=">[*:GET:http://192.168.88.189/httpapi.asp?command=setPlayerCmd:vol:50]"}

Unfortunately this doesn’t work. (I know I have a static volume of 50 set, just to eliminate anything that could go wrong)
When looking at the log file, after I change the value of the dimmer, I see:

10:57:04.333 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'ieast_volume2' received command 68
10:57:04.350 [INFO ] [smarthome.event.ItemStateChangedEvent] - ieast_volume2 changed from 0 to 68

But the volume isn’t changed on the actual device. This did happen when I did the manual call, so method of checking seems fine. I did use the HTTP binding earlier without issues, but this was on a switch item instead of a dimmer.

Hoping for some valuable input! Thanks


When I started trying to implement volume control, I combined both the command and state into a single item:

Dimmer ieast_volume2 { http=">[*:GET:http://192.168.88.189/httpapi.asp?command=setPlayerCmd:vol:%2$s] <[ieast_player_status:5000:JSONPATH($.vol)]"}

The dimmer got updated properly via the cache item. However, when I ran into issue, I removed the state part to trim down on things that could go wrong/conflict (looping…right?)

I dug some further and guess that the issue lies in the colon’s being used in the command.
When raising log level to debug for the http binding I see:

11:29:16.885 [DEBUG] [hab.binding.http.internal.HttpBinding] - Executing url 'http://192.168.88.189/httpapi.asp?command=setPlayerCmd' via method GET

Seems like the part behind the colon is being skipped.
When I try to URL encode the colon (%3A) I get a completely new kind of error:

11:33:38.683 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'ieast_volume2' received command 79
11:33:38.685 [WARN ] [org.apache.karaf.services.eventadmin ] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/ieast_volume2] {item=ieast_volume2, bridgemarker=true, command=79, timestamp=1564652018675} | {org.osgi.service.cm.ManagedService, org.osgi.service.event.EventHandler}={service.id=342, service.bundleid=241, service.scope=bundle, event.topics=openhab/*, service.pid=org.openhab.http, component.name=org.openhab.binding.http, component.id=19} | Bundle(org.openhab.binding.http_1.13.0 [241])]
java.util.IllegalFormatConversionException: a != java.util.Date
	at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302) ~[?:?]
	at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2806) ~[?:?]
	at java.util.Formatter$FormatSpecifier.print(Formatter.java:2753) ~[?:?]
	at java.util.Formatter.format(Formatter.java:2520) ~[?:?]
	at java.util.Formatter.format(Formatter.java:2455) ~[?:?]
	at java.lang.String.format(String.java:2940) ~[?:?]
	at org.openhab.binding.http.internal.HttpBinding.formatAndExecute(HttpBinding.java:267) ~[?:?]
	at org.openhab.binding.http.internal.HttpBinding.internalReceiveCommand(HttpBinding.java:130) ~[?:?]
	at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:94) ~[?:?]
	at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:45) ~[?:?]
	at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:82) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:166) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
11:33:38.705 [INFO ] [smarthome.event.ItemStateChangedEvent] - ieast_volume2 changed from 49 to 79

You don’t risk a loop, because the binding only sends out commands. Incoming data is made into a state update, no direct link to command. But smart to set that aside until command is working.

I’m pretty certain the issue is the colons in your HTTP URL. The binding uses those to delimit fields - as you can see in the *:GET:… part - but also after the URL for timeout and transformation parameters etc.
You’re going to have to escape or encode them.

If I recall, you should encode : as %3A character. But then you need to escape the % because the binding uses that too. So %%3A

Try

{http=">[*:GET:http://192.168.88.189/httpapi.asp?command=setPlayerCmd%%3Avol%%3A50]"}
1 Like

Solved!

rossko57, thanks a lot! In the meanwhile I found the following link that states that you need to escape the escape character as you mentioned!

Tried it and worked like a charm! Many thanks!