Http binding not transforming sent command in url


I’m using http binding to send out all commands to item Z9S but the commands need to bet transformed and be part of the url, so I added the item like this:
String Z9S “Zidoo Z9S” (MQTT_GROUP) { http=">[*:GET:$s:MAP(]" }

I’ve enabled debug logging and this basically works fine except that the transformation for %2$s is not happening, so the value appended there is the Command Name not it’s transformed value.

I know that map transformation add on is installed and working as I’m using it for example with http post item and also in rules.

How do I solve this problem? I could of course make a rule that catches all commands and use SendHttpGetRequest function but isn’t this the standard use case and the whole purpose of http binding? How hard can it be to add a transformed value somewhere as part of the url?

Thanks for any help on this

No transform on HTTP GET outward bound

The %2 substitution is working as intended. You’d need to perform your transform on the command string before issuing it to your Item.

Thanks for the hint. But instead of using proxy item I already used a rule. It’s so much simpler then proxying which also needs some way to update the proxy with transformed value. The rule is more or less 4 lines of code. The only shortcoming is that definition of endpoint is somehwat hidden in the rule.

And as a professional web developer for 10+ years I have to say that this is a HUGE shortcoming of http binding by whoever created it and not forseeing this usecase. I can think of so many GET URLs that just operate on get parameters it’s not even funny.

I really hope this gets implemented soon. It shouldn’t be too hard to transform the outgoing value before replacing %2$s with it or before using whatever api is used to make the replacement. Unfortunately I’m no java developer and can not provide a patch for this.

Hope you’re not planning to hold your breath for it. Not likely to ever happen.

As I said. I used a rule for now and that works perfectly it just doesn’t feel the right way of doing it. I know that openhab2 is open source but still I don’t get why a basic operation like mapping a command to a get-parameter is not supported and is probably not ever going to make it.

The HTTP binding is legacy version 1.x. I agree, outbound GET transform would be very useful, and in any case the whole binding needs overhauling to a version 2 standard (things/channels).

There exists a workaround, which may explain why people with the skills and enthusiasm who are capable of doing that are engaged on other work.

Assuming that, like me, you don’t have the skill/time to take this on yourself, you can create a formal enhancement request as an issue in Github. (That’s an adventure of itself if you’ve not done it before). Good Ideas in postings here are not often taken up without that, the appropriate developers may never see them.

Even if the work/benefit balance ends with no action for 1.x, and even no new 2.x binding with OH2 end now in sight, the idea is recorded to be taken into account for an eventual 3.x version. In reality I suspect the developing “profiles” feature will take care of this kind of thing for all.

Whinge or do.