Controlling Air Conditioner (via a webserver)


I am quite new to OH and have been struggling to do something which is probably very difficult.

I have an airconditioner system which wirelessly with a cloud service (ninja).

There is a web service ( and the web server at displays the following:
{“result”:1,“error”:null,“id”:0,“data”:{“vid”:2,“did”:4,“device_type”:“airconditioner”,“default_name”:“Air Conditioner Settings”, “tags”:“aircon”, “is_sensor”:1, “is_actuator”:1, “is_silent”:0, “has_time_series”:0, “has_subdevice_count”:0, “has_state”:0, “gid”:“0”, “guid”:“xxx_0_2_4”, “node”:“xxx”, “meta”:{},“shortName”:"", “subDevices”:{}, “last_data”:{“DA”:{“amOn”:true,“tempTarget”:23,“mode”:1,“fanSpeed”:0,“enabledZones”:[1,1,0,0,0,0,0,0]},“timestamp”:1499413530689}}}

I have created an item:

Switch aconnect "Air Conditioner Power" (all) { autoupdate="true" }

and the sitemap is very simple

Switch item=aconnect

I have tried to modify sample rules which I researched online but firstly i am not even confident they are being triggered, let alone sending the the right data to the webserver.

Someone has done it using the Fibaro system so I know it is possible to communicate with the web server and issue commands - i just don’t know if it is possible to do so with OH and how to format the commands correctly. I tried with sendhttpgetrequest but again, I just don’t think I have used the correct code.

I have pasted the code below which was used by the other person

  local http = net.HTTPClient()

  jsonTable = {DA={amOn=true}}
  jsonString = json.encode(jsonTable)

  options = {
  method = "PUT",
  data = jsonString,
  headers =  {
            [ 'Content-Type' ]  =  'application/json'
   success = function(response) fibaro:debug( end,
   error = function(err) fibaro:debug("Error: " ..err) end

Any help would really be very much appreciated as I am tearing out what little hair I have and my wife misses her husband

You may be able to do what you want more easily via the HTTP Binding

Thanks for that. I did explore HTTP Binding but I just could not work it out as it relates to my setup.

I’m not even sure which section of the link to check and I have tried a few different types but I suspect that the JSON section is the one that applies the best. Is that right?

Can someone give me a hint or two to get me started?

I looked briefly and they do not provide a published API. This will require you to reverse engineer the API (i.e. the webcalls) in order to extract the information you want and make the commands you want to make.

The curl command is a good way to do this.

Once you figure out what command you need to make you will know the proper format and bodies of the HTTP calls you need to make. At this point you will either be able to use the HTTP binding, the HTTP Actions, or create a script that continues to use curl and the Exec binding to interface it with openHAB.

The “code I pasted in below” is not valid openHAB Rules code. It looks like it might be Python or Ruby but what ever it is it most decidely will not work in a rule.

Looking at the code there are pieces missing. You will need to:

  • figure out what jsonTable is supposed to contain because this is what you must send to the web site
  • use curl to experiment with making that HTTP PUT command and observe the results
  • use a rule and the sendHttpPutRequest to send that data to the web service and retrieve the result
  • use the JsonPath Transform in your rule to parse the data the web service sends back

Thank you so much for those suggestions.

I have spent the day investigating curl as you suggested and have tried many things using trial and error (mostly error).

I have come up with the following command which gives me the least amount of errors:

curl -g -v -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"DA":{"amOn":"true"}}' 

Looking at the data I inspected on the webserver it looks like this should trigger the device to switch off. However at this moment it seems that anything I put in the -d does not get through and in fact whether I specify data or not, I always get the same error message:

{"result":0,"error":"Unknown Request","id":400}* Connection #0 to host left intact

I have tried moving the various variables around in the command, I have tried with POST as well as GET, and have tried various combinations of quotes, escaping quotes, and using other command line variables.

I feel somewhat successful because at least I can sort of log into the webserver, but I just don’t think the data is getting through (maybe) and that’s more than I had before. I also wonder maybe whether the server is authenticating properly? I used the verbose command line and the log seems ok to me.

Are there any suggestions which could assist me to progress a bit more?

Any help is greatly appreciated


This seemed to do the trick:

curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X PUT -d '{"DA":{"amOn":"false"}}'

The successful message is:


I didn’t notice at first because I had been constantly failing. Now by changing the amOn to anything from the list in the first post changes the wall unit. I have been able to turn the AC on and off and change the temperature to a specific value so far. There is a delay of about 10 seconds because it has to go around the world to get to the wall unit.

The successful command is pretty much the same as in the post immediately prior to this one - I think the difference was that I was trying to issue the commands via a Windows machine however once I got onto Ubuntu I started to get positive messages.

I’ll have a play with it now and see if I can start linking the commands to switches.

Is it better to use curl or to try to use the sendHttpPutRequest?

I would try with the HTTP Actions first and if that is unable to send the PUT request as you need to then fall back to executeCommandLine to call curl.

Thanks for everyone’s help - not only in replying to my questions but replying to other’s questions and for those who posted their own examples. This help has been invaluable in me getting so far. I can now read specific bits of information from the device and issue commands to it. I have learnt a lot and clearly have only scratched the surface.

To send commands I put the following in a rule: (amOn refers to the power state).

sendHttpPutRequest("", "application/json", '{"DA":{"amOn":"true"}}',1000)

I can also read operational information from the webserver:

String  ActronFanSpeed     "Fan Speed is: [MAP(]"       {http="<[actron:5000:JSONPATH($.data.last_data.DA.fanSpeed)]"}

I have put together a simple site map and some rules and have been able to trigger the device to power on at 5:45am to warm up the house before we get up.

I am just a litte (ok A LOT) stuck with issuing PUT commands to change zones. The zones are at the end of the JSON below:

{"result":1,"error":null,"id":0,"data":{"vid":2,"did":4,"device_type":"airconditioner","default_name":"Air Conditioner Settings","tags":"aircon","is_sensor":1,"is_actuator":1,"is_silent":0,"has_time_series":0,"has_subdevice_count":0,"has_state":0,"gid":"0","guid":"xxxx","node":"yyyy","meta":{},"shortName":"","subDevices":{},"last_data":{"DA":{"amOn":true,"tempTarget":24,"mode":1,"fanSpeed":0,"enabledZones":[0,1,0,0,0,0,0,0]}**,"timestamp":1500367036948}}}

According to the data (at enabledZones), Zone 1 (position 0) is currently off (0) and Zone 2 (position1) is currently on (1). While I can GET this data using this item with a corresponding text item in the sitemap:

String  ActronZoneOne     "Zone One (Upstairs) is: [MAP(]"    {http="<[actron:5000:JSONPATH($.data.last_data.DA.enabledZones[0])]"}

For the life of me I cannot issue PUT command to deliver the data. I would have thought that the below would work:

sendHttpPutRequest("", "application/json", '{"DA":{"enabledZones[0]":1}}',2000)

However it does not work. I have gone back to my basics and tried to get the change to happen using curl, however nothing happens. This is what I think it should look like but so far have not been successful in this:

curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X PUT -d '{"DA":{"enabledZones[1]":0}}'

Are there any ideas on whether I am doing something wrong or whether what I am trying to do (eg change "enabledZones[0,0,0…] to "enabledZones[1,1,0,…) etc is not possible?

Any and all ideas are very welcome. Also if I have done anything funny in the examples I posted please let me know - always willing to improve my work.

1 Like

Hey @Lucas

I’ve just installed my Actron ESP+ system and am also just trying to integrate ActronConnect to OpenHAB2. Looking at what you have done, have you tried this to set the zones -

sendHttpPutRequest("", "application/json", '{"DA":{"enabledZones":[1,1,0,0,0,0,0,0]}}',1000)

That should turn on zones 1 & 2. I noticed that you will need to specify all 8 zones before it will accept the zone setting.



I didn’t have to do that.

Let me check when I get home and I’ll send you what I did

@Lucas thanks!

I can’t seem to be able to get my item to work. Trying to mimic what you have done, I have -

String  ActronFanSpeed  "Fan Speed is: [%s]"  {http="<[$.data.last_data.DA.fanSpeed)]"}

That doesn’t seem to work as all I’m getting is ‘NULL’. Did you have to specify the “_0_2_6” in your setup? I’ve tried with and without with no success. I am assuming that “xxx” is the mac address of the device and yyy is the token.


My command is this:

sendHttpPutRequest(“”, “application/json”, ‘{“DA”:{“enabledZones”:[1,1]}}’,2000)

The user token is actually a code which I discovered from inspecting the webserver with firefox inspector. It isn’t the MAC address. This might be the reason you are getting NULL

While I was doing this I also found that while sometimes I had the right commands, because of the trial-and-error nature of what I did, i would have to restart the openhab service on the Pi to get things to actually work

and yes the _0_2_6 or whatever applies to you goes in there as well - the whole string actually forms the URL which you can find by inspecting the webserver,

If you still can’t find the codes I can try and remember exactly what I did to get them and let you know

@Lucas thanks for that. I did get my send command to work to do things like turn on the unit, set temperature etc, so I got the xxx MAC & yyy access token right. My issue right now is I cannot read the info into an OpenHAB2 item/string. My example above doesn’t work, so I am wondering how you got yours to work.


@Lucas Woohoo… all working now. Just realised that I have actually not installed the HTTP Binding! Once I installed it everything works as expected.

I was just typing something up which included reference to the http binding

Well done.

This has been a huge learning experience for me as I am no coder or programmer

@Lucas Thanks for responding mate. This has certainly been a huge learning experience for me too. I’ve got some experience, but I’m more of a hardware person. Next step for me now is to incorporate all this into my habpanel setup.


No worries.

Just discovered habpanel and that opened up a whole can of worms and potentially sleepless nights, I am forcing myself to put a lid on that for now and focus on a couple of other things first, like removing the reliance on the actron/ninja webserver

Good luck to you

habpanel definitely changes the way you will use OpenHAB. I’ve got a couple of old tablets blu-tack’ed to the walls as control panels now.

Good luck to you too with your habpanel implementation.

I will need to look into this reliance on ninja as well sometime down the road, I’m not too happy about the security and also the delay in response when I change anything.


@Lucas How far have you progressed on removing the reliance on Actron/ninja cloud server? I’ve got my setup working now, minus turning on ESP mode which seems like can only be done via the panel. I’m keen to also not have that reliance as well so that I can have a self contained setup and hopefully not have that long delay from when I do any changes to actually seeing it happening.