[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!!

Hello guys,

I am trying to have my AIRZONE working with OpenHAB.

I have tried to follow the guide to figure out how to reach the actual temperatures but I am facing some issues.

Here is the script:


val String url = “http://X.X.X.X: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(PLAYROOM,transform("JSONPATH", "$.data[0].roomTemp", jsonString))
postUpdate(SOGGIORNO,transform("JSONPATH", "$.data[1].roomTemp", jsonString))
postUpdate(BABIES,transform("JSONPATH", "$.data[2].roomTemp", jsonString))
postUpdate(MATRIMONIAL,transform("JSONPATH", "$.data[3].roomTemp", jsonString))
postUpdate(CUCINA,transform("JSONPATH", "$.data[4].roomTemp", jsonString))

Here you can find the error log I am facing on OpenHAB console: 18:14:13.726 [WARN ] [ab.core.model.script.actions.BusEvent] - Cannot convert ' - Pastebin.com

Is there any addittional document to have AirZone / OpenHAB ?

Thanks,

This is the official manual https://drive.google.com/file/d/1-29U2hAiGy7frD3qWyPzat9fvEWT-815/view?usp=drivesdk

When searching the words “openhab airzone” in any search engine, this post is the first to come out, so I’m taking the liberty to mention that I have created an AirZone binding that allows easy integration into openHAB 3.4 and upper.
It is available in the community marketplace and described here

Hope this helps

1 Like

Good job!! Thank you