Http binding mappings not working

I’m trying to setup http binding with outgoing tcp commands by using a map file. What works is the following in the .items file:

String YAMAHA_RXV675 "Yamaha RX-V675" { http=">[POWER_ON:POST:http://192.168.10.46/YamahaRemoteControl/ctrl:<YAMAHA_AV cmd=\"PUT\"><System><Power_Control><Power>On</Power></Power_Control></System></YAMAHA_AV>]" }

what doesn’t work is using a map file like so:

String YAMAHA_RXV675 "Yamaha RX-V675" { http=">[POWER_ON:POST:http://192.168.10.46/YamahaRemoteControl/ctrl:MAP(test.map)]" }

I first tried with a big map file which contains all those XMLs but the “test.map” file listed above contains just this line:
POWER_ON=hello_world

But no matter what .map file I try to use and how simple it is I always get this error in the log and the command is not sent:

2017-11-05 17:08:51.692 [ItemCommandEvent          ] - Item 'YAMAHA_RXV675' received command POWER_ON
2017-11-05 17:08:51.700 [ItemStateChangedEvent     ] - YAMAHA_RXV675 changed from NULL to POWER_ON
==> /var/log/openhab2/openhab.log <==
2017-11-05 17:08:51.706 [DEBUG] [org.openhab.io.net.http.HttpUtil    ] - About to execute 'http://192.168.10.46/YamahaRemoteControl/ctrl'
2017-11-05 17:08:56.719 [ERROR] [org.openhab.io.net.http.HttpUtil    ] - Fatal transport error: java.net.SocketTimeoutException: Read timed out

I google for this error and read somewhere that this “transport errors” normally occurs when nothing comes back, which also means nothing was sent (otherwise the device would answer) which also means the value of the command was not read from the MAP file.

I’m really pulling my hair out what I’m doing wrong with my map file and why I doesn’t work. Is this a known bug or something or what am I doing wrong? I’ven been trying for hours and hours now without any success, whenever I use a map file for http binding it just fails because it doesn’t read the value from the map file. The file itself is placed in the transform directory and I have other .map files for other bindings (like the iTach one) that are working, I just don’t get whats wrong here.

Using MAP file will not do the trick. Try javascript

item file
String YAMAHA_RXV675 “Yamaha RX-V675” { http=">[*:POST:http://192.168.210.70/YamahaRemoteControl/ctrl:JS(yamaha.js)]" }

js file (yamaha.js)
(function(i) {
var power_on = “<YAMAHA_AV cmd=“PUT”><Power_Control>On</Power_Control></YAMAHA_AV>”;
var power_off = “<YAMAHA_AV cmd=“PUT”><Power_Control>Standby</Power_Control></YAMAHA_AV>”;
if (i == “power_on”) {
return power_on;
}
if (i == “power_off”) {
return power_off;
}
})(input)

Also don’t forget to install Javascript Transformation ( Addons / Transformation / Javascript Transformation )

For full functions you need to parse the xml

Thanks for the idea but why does documentation of the bindings say otherwise:
http://docs.openhab.org/addons/bindings/http1/readme.html

has examples like this:
Switch MyItem3 { http=">[*:POST:http://sample.com/myitem3:MAP(onoff.map)]" }

So it should work with map file, why do you think it doesn’t?

And using javascript here is not really helpful as I don’t need just 2 commands, i need about 30-40 functions and another 20-30 for a second network device to control home theatre through remote control via sitemap, dashboard or maybe I’m even going to use an external MQTT triggering of the commands

Question: Does the Yamaha Receiver Binding not work with your current AVR?
I am using it with a RX-V581 Receiver and it works very well for a long time now.
This could maybe simplify some work for you.


About the Javascript:
If it works with 2 commands it will work with 30 or 40 too.
You can replace the “if” statement with an switch statement.
This will be about 10 to 15 lines longer than the map file would be.

About the docs:
Maybe the http binding docs refer to a special situation, but i think the example is a bad one in general.
Just a switch with a map and no context how to use it.
Maybe we can find some better examples for the http binding in this case.

Hi Confectrician,

Yes the Yamaha Receiver Binding works, but as I said as I want to build a remote control, the few limited commands on the Yamaha Receiver Binding don’t fulfill my needs at all, I was hoping first that I could use it but was hugely disappointed by the items it supplies.

As for the Javascript: I’m really no pro in Javascript although I used a little but as I don’t know the switch statement you can see how limited my knowledge is, but it surely would work. But it would take me some time to make a javascript out of my map file.

Unfortunately I couldn’t dig up some good examples for the http binding with POST data and a map file, also not with JS but I will try that. If it works, would be great to at least have a backup. But of course I still wonder if the http binding is broken in terms of the MAP feature.

Building up a complete (?!) Remote for your devices sounds like an edge case for me.

Did you read over the yamaha binding readme yet?
The binding is currently under some changes and there where new channels introduced.

Maybe you can tell us some more about your ecosystem and the things you want to archive in the end.

For automating a home theatre there are maybe some different or additional approaches.
30-40 or even more actions for one device is a huge amount.

Sorry for digging deeper here without having a simple solution. :smile:
But I am very interested in your plans, according on your explanation.

About the http:
That’s the problem with this example.
Since there is now documentation aside of how it should work with map transformations, it is very difficult to say “this is a bug” or “the binding can’t do that”.

I will browse the OpenHab 1.x wiki tommorow to see if there’s some more documentation available which should maybe be transferred then into the current docs.

Hi Confectrian,

I’m perfectly fine to tell you my plans. I was using the product iRule (which was a designable Home Theatre remote control solution with an Android and an iOS app). Unfortunately they have decided to shutdown their web based designer and servers end of 2018 so the remote will stop working once they do.

So I’m looking for a replacement for that basically. I just have 2 prerequisites. It must run on Android tablets/phones and I also have lots of “GlobalCache” devices like IR multiplliers, boosters, sensors which need to continue to work. This already limits your choice of available HomeControl solutions drastically.

In the end I came across openhab which could control most of the devices I have (supposedly) and as I had a Pine64 lying around doing nothing I decided to start using it. Soon the globalcache stuff was working but the sitemaps didn’t offer me the flexbility I wanted in design.

So I went on searching and came across the product “Home Remote” which has a windows designer and you can upload the files to your phone/tablet and it was able to control all my stuff as far as I could tell.

So in the end I had to decide to either only use “Home Remote” without openHAB redoing my Home Remote. Or I could use “Home Remote” and just misuse it as MQTT Client with a nice UI. As I didn’t want to be dependent on Home Remote again (as I’m currently with iRule) I went the MQTT way.

So I installed mosquitto and I can now use Home Remote to send MQTT commands which are then processed by OpenHAB by MQTT Event bus. As I’m a linux geek and I also have other linux systems running 24/7 like FreePBX, Exim4 Mail Server and other stuff it also greatly integrates into my eco system and for example let’s me do stuff with SONOS and other stuff I can’t do with HomeRemote like start sonos when I arrive home by using the android app “tasker” with MQTT plugin and much more.

So OpenHAB is definitly not mainly designed to be a Home Theatre control system. But with MQTT it can be used like this and this offers a lot of features like decoupling of UI and backend system which really controls the devices among other stuff.

Finally I have some update on the binding. It seems it’s a bug see here.

It’s fixed but not released as the plugin is still on version 1.10 but I need 1.11-SNAPSHOT. How can I do this when I using PaperUI to configure my addons? should I uninstall it and place the jar of the snapshot version in the config section of OpenHAB or is there some console command to accomplish this more nicely and cleanly without placing local jar files? Note that I’m currently using OpenHAB stable version.

Hi,

First:
This is ofc an edge case and i think you will have to dig into many things by yourself.
But as i can see you are on the right way and as a linux geek you possibly have enough experience in digging into stuff. :smiley:

See:
http://docs.openhab.org/installation/linux.html#file-locations

You should uninstall the current http binding version through paper ui and then place the snapshot jar file in the folder for additional addons.
It should be useable then.

@marcelser

Interesting idea. Whenever everything i want currently works, i may go this route as well.
This would be an interesting tutorial in my opinion. :smiley:

If you are not only using Power On for testing purposes, you can also easily mix items of several bindings. Use the basic commands from the yamaha binding and just create the missing operations with the http binding.

1 Like

Hello marceler,

Like you I was a big iRule user and I am now playing with both HomeRemote and OpenHab.

I feel that HomeRemote provides a decent UI tool with enough flexibility for most of my AV control needs and that OpenHab is more powerful to handle complex automation and gives controls over more devices.

Mixing the two together could be very interesting and i was wondering if you are happy with that approach

Hi regissg,

Yes I’m perfectly fine with this approach was using this for quite some time now with MQTT protocol. So basically all devices in HomeRemote just send/receive MQTT commands to/from OpenHAB which in turn sends the correct command to any device in OpenHAB and publishes the result back to MQTT. With this approach the different devices become totally transparent as you don’t need to worry if HomeRemote can do it or not as long as the device can be included in OpenHAB.

Technically you need mosquitto as MQTT broker and I was using the MQTT eventbus system which they recently retired in new MQTT plugin of OpenHAB. So now I’m using some custom rules that receive and send mqtt commands which work similar.

But it has been a long ago since I setup all of this and I have transitioned through various version of OpenHAB and it works perfectly fine until they updated the MQTT plugin which needed a bit of googling in the OpenHAB forum on how to recreate that functionality using rules.

I can recommend the approach as MQTT is a very lightweight and fast protocol and you only have to configure everything once in OpenHAB. Then you can use it with any MQTT capable App, I can even use Alexa or IFTT with various plugins.

Jsut don’t ask me any specifics on how to set this all up anymore, it’s too long ago.But I will keep using it.