OH3 HTTP Binding, GUI Configuration

I’ve been using OH2 for a 2-3 years now and I have accomplished quite a bit with it, using various bindings, including the HTTP binding. I’ve configured it to control a motor which is connected to Olimex’s PIC-WEB board, running Microchip’s TCP/IP stack.

I have recently installed OH3 and working my way through the new interface…much different than OH2, but very impressive. I’m struggling a bit trying to configure the HTTP binding to send commands to the PIC-WEB, like I did in OH2. At the moment, I’m trying to start simple, by just turning the on-board LED on and off. The commands do that are;

http://192.168.2.70/forms.htm?led1=0 to turn the LED on
http://192.168.2.70/forms.htm?led1=1 to turn the LED off

I have been able to configure the toggle switch, create the item, and configure the channel, for the most part, but I can’t seem to get the LED to turn off and on. I’ve tried all kinds of variations for the Base URL and set the On Value to 0 and the Off Value to 1, but no luck so far.

If I check the log, it shows the item receiving the commands;

Item ‘LED1’ received command ON
Item ‘LED1’ predicted to become ON

but I’m getting the following error messages;

Item ‘LED1’ changed from UNDEF to ON

Splitting header ‘’ failed. No ‘=’ was found. Ignoring

I’ve read several threads about configuring the HTTP binding and tried several of the suggestions, but still no luck.

I’m sure I’m missing something simple. As I mentioned, create a text based items file in OH2, to control the LED’s and other variables as well. For example, a slider variable to control the speed of the motor using Pulse Width Modulation. I would like to do the same in OH3, so I thought I would try starting with the LED’s first.

If anyone has any ideas, or can point me in the right direction, it would be greatly appreciated.

Thanks!!

[Update]

I managed to get the LED to turn on and off by doing the following;

Base URL: http://192.168.2.70/
Command URL Extension: forms.htm?led1=%2$s
On Value: 0
Off Value: 1

The trick was the ‘%2$s’. I know it has to do with formatting, but not quite sure why I need to use it for the on/off state in OH3. I didn’t have to use it in OH2. I had to use it in the following commands in OH2, to control the PWM function I mentioned;

POST:http://192.168.2.70/sliders.cgi?slider1=%2$s

I’m still getting the following message in the log though;

Splitting header ‘’ failed. No ‘=’ was found. Ignoring

I also noticed the timestamp in the log is not correct. I do have the timezone set properly.

Thanks.

That %2$s is how you represent the state of the Item in the URL. The On Value will convert the Items ON state to 0 and the OFF to 1 for you. Without that string there is no way to issue a different request based on the command sent to the Item. Exec binding and others work the same way.

You didn’t have to use it with the OH 1.x binding because the 1.x binding didn’t have a unified concept of Things. Instead each URL for ON and OFF were separately and independently defined and configured.

I suspect a POST expects there to be some headers included as part of the HTTP request and you’ve not defined any. It’s not an error since the command continues and the request is made.

You’ll have to open another issue for the timestamp but search the forum first. There have been dozens of similar posts over the years.

Thank you very much for the reply and explanations. I will certainly search for the timestamp issue.

Since my post, I’ve managed to get the dimmer card (I believe that is the correct OH3 terminology) working as a variable speed control. No I am struggling a bit with the syntax for using XPATH. In OH2, I used the following syntax;

Number slider1 “Slider1”{http="<[http://192.168.2.70/status.xml:1000:XPATH(/response/slider1)]"}

First thing I learned, is that you don’t have to load an additional binding, like in OH2. I’ve been searching the forum for a similar example and have come to the conclusion that it’s done using the State Transformation field in the GUI. Just not quite sure yet what the correct syntax is.

When you create the Channel you have a State Channel Transformation and Command Channel Transformation.

Put the XPATH transform there. State is for incoming data transformation and Command is for transforming an Item’s state before sending the message to the end device. You want to use State.

You do need to install the XPATH addon.

Thanks again! I will give it a try right now.

Right…it’s not a binding add-on, it’s transformation add-on! Been a while since I installed it OH2. :grinning:

At least I got it to display something! lol

[Edit]
Used a profile and it worked!

But I’m getting this warning.

Could not transform state ‘52’ with function ‘name()=‘slider1’’ and format ‘%s’

Duty Cycle sounds like something that should be a Number:Time Item, right? Or did you assign it to a DateTime Item? If you did use a DateTime Item switch to a Number:Time.

Then for the Item, set the State Description metadata and set the Pattern using the same state transformation and formatting string you’d use for a DateTime Item. Or since this looks like it will be in the seconds range anyway just use %d s and it will show the number of seconds. I use the following State Description Metadata on the runtime for my UPS.

value: " "
config:
  pattern: "%1$tH:%1$tM:%1$tS"

But the Item itself holds

That’s the magic of Units of Measurement.

I changed it to a string. I’ll try number.

The Duty Cycle just represents a speed percentage. I use the PIC-WEB, connected to an H-Bridge circuit to control a DC motor. I use the Timer modules on the PIC MC, to control the enable pin on the H-Bridge using a PWM waveform. The code on the PIC-WEB is written in C and the TCP/IP stack uses callback functions to store the value in an XML file.

In OH2, I can even control the motor using Google Home and voice commands. Here’s a demo.

If it’s a percentage then either a Dimmer or a Number:Dimensionless would be the best choices for Item type.

Didn’t even see those options! Dimensionless works and seems to have eliminated the warnings. Thanks again!!!

Now to learn how to make the interface look like some of the wonderful examples I’ve seen.