[SOLVED] Airzone API With Openhab

Hi i have installed on my home an aerothermal system for the heating and cooling of the home.
I have installed Airzone for the zone control of this system. Airzone recently published a API for capture information an modify configuration of the zones.

I need send a post request with a json body for capture the information and a put request for modify options.

You can see here: http://doc.airzone.es/producto/Gama_AZ6/Airzone/Comunes/Manuales/MI_AZ6_WSCLAPI_A4_ES.pdf

I need send a post request to a http://192.168.1.49:3000/api/v1/hvac
with somethin like that JSON body:
{
“systemid”: 1,
“zoneid”: 13
}

I recived a JSON like that:
{
“data”: [
{
“systemID”: 1,
“zoneID”: 13,
“on”: 1,
“maxTemp”: 30,
“minTemp”: 25,
“setpoint”: 26,
“roomTemp”: 25,
“speeds”: 3,
“speed”: 0,
“coldStages”: 3,
“coldStage”: 3,
“heatStages”: 3,
“heatStage”: 2,
“humidity”: 57,
“units”: 0,
“errors”: []
}
]
}

I see i can capture the diferent data with JSONPath Online Evaluator but i dont know how can i send the JSON body or send a Put request for modify the configuration.

I try to configure the post request with http binding but i dont know how to send the json body.
Could you help me please?

Use the HTTP Actions from Rules.

I use that:

rule "Airzone" 
when
    Time cron "0 0/2 * ? * * *" //Every 5 minutes
then
val String url	= "http://192.168.1.49:3000/api/v1/hvac"
val String typ	= "application/json"
val int timeout = 5000	// ms
val sen = '{
    "systemid": 1,
    "zon    eid": 13
    }'

        //url is incomplete in your link and 5 seconds time out
        var jsonString = sendHttpPostRequest(url,typ,sen,timeout)
        //TemperaturehG.sendCommand(transform("JSONPATH", "$.data[:1].roomTemp", jsonString)) 
    	postUpdate(TemperaturehG,transform("JSONPATH", "$.data[:1].roomTemp", jsonString))

    end

But the result is
2019-09-26 21:00:03.547 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.net.NoRouteToHostException: No existe ninguna ruta hasta el `host’
2019-09-26 21:00:03.548 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert ‘null’ to a state type which item ‘TemperaturehG’ accepts: [DecimalType, QuantityType, UnDefType].

The error is pretty self explanatory. Your OH machine cannot access 192.168.1.49 for some reason. Perhaps you have a firewall in place or something else blocking the traffic?

Works!!!

I Share with the comunity the config (It is only first try, it need perform a better code):

ITEM

 //////////////////////////
//AIRZONE////////////////
////////////////////////
Number Temperaturedos "Temperature [%.1f C]"  <temperature>  (RoomWeather) 
Number Temperaturetres "Temperature [%.1f C]"  <temperature>  (RoomWeather) 
Number Temperaturecuatro "Temperature [%.1f C]"  <temperature>  (RoomWeather) 
Number Temperaturecinco "Temperature [%.1f C]"  <temperature>  (RoomWeather) 
Number Temperatureseis "Temperature [%.1f C]"  <temperature>  (RoomWeather) 
Number Temperaturesiete "Temperature [%.1f C]"  <temperature>  (RoomWeather) 
Number Temperatureocho "Temperature [%.1f C]"  <temperature>  (RoomWeather) 

SITEMAP

Text label="Airzone" icon="temperature"
{
	Text item=Temperaturedos
    Text item=Temperaturetres
    Text item=Temperaturecuatro
    Text item=Temperaturecinco
    Text item=Temperatureseis
    Text item=Temperaturesiete
    Text item=Temperatureocho 
}

RULES

rule "Airzone" 
when
    Time cron "0 0/5 * ? * * *" //Every 5 minutes
then
val String url	= "http://192.168.1.49:3000/api/v1/hvac"
val String typ	= "application/json"
val int timeout = 5000	// ms
val sen = '{
    "systemid": 1,
    "zoneid": 0
}'

    //url is incomplete in your link and 5 seconds time out
    var jsonString = sendHttpPostRequest(url,typ,sen,timeout)
    //TemperaturehG.sendCommand(transform("JSONPATH", "$.data[:1].roomTemp", jsonString)) 
	postUpdate(Temperaturedos,transform("JSONPATH", "$.data[0].roomTemp", jsonString))
	postUpdate(Temperaturetres,transform("JSONPATH", "$.data[1].roomTemp", jsonString))
	postUpdate(Temperaturecuatro,transform("JSONPATH", "$.data[2].roomTemp", jsonString))
	postUpdate(Temperaturecinco,transform("JSONPATH", "$.data[3].roomTemp", jsonString))
	postUpdate(Temperatureseis,transform("JSONPATH", "$.data[4].roomTemp", jsonString))
	postUpdate(Temperaturesiete,transform("JSONPATH", "$.data[5].roomTemp", jsonString))
	postUpdate(Temperatureocho ,transform("JSONPATH", "$.data[6].roomTemp", jsonString))
end

yes jejeje, the Airzone web server was blocked

Thanks!!