abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 
Beantwortet! Gehe zur Lösung.

Returns from an API request change order.

I'm using the (new) API for a couple of days now with such a request:


"https://api.viessmann.com/iot/v1/equipment/installations/"+ installationID +"/gateways/" +gatewaySerial + "/devices/0/features?regex=heating.(sensors.temperature.outside%7Cdhw.(oneTimeCharge%7Csensors.temperature.hotWaterStorage%7Cpumps.circulation))%7Cventilation.operating.programs.active"

 

Why does the order of data entries in the return change? ( That happened this morning July 2nd between 03:00 and 11:00  UTC +2).

The sequence in the returned string was and still is not inline with the request, also the number of data entries is 5 instead of 4.

1 AKZEPTIERTE LÖSUNG

Akzeptierte Lösungen

@JueBag for completeness: There is no defined order in the features within the response. So you need to evaluate the arrays in the JSON like you already are doing.

Lösung in ursprünglichem Beitrag anzeigen

3 ANTWORTEN 3

Hi @JueBag,

 

could you please share the response that you receive from the request?

 

In general, my first assumption is that the feature request is not accounting for the order of the features. To have a more robust implementation, I would recommend anaylsing feature names instead of the order of the features.

 

However, I will check with the development teams to make sure, how the device features is ordered within the response.

@MichaelHanna  Thanks for the reply.

 

My actually used request in JavaScript is.

 

var headers = [];
headers["Authorization"] = "Bearer "+ token;
var url ="https://api.viessmann.com/iot/v1/equipment/installations/"+ installationID +"/gateways/" +gatewaySerial + "/devices/0/features?regex=heating.(sensors.temperature.outside%7Cdhw.(oneTimeCharge%7Csensors.temperature.hotWaterStorage%7Cpumps.circulation))%7Cventilation.operating.(programs.active)";
var returnvalue = HTTP.sendHttpGetRequest(url, headers, 10*1000);

returnvalue = JSON.parse(returnvalue);

 

Yes, that is a request for 5 data-points, so the number is and was correct.

I would have expected the order:

  1. Outside Temperature
  2. OneTimeCharge
  3. HotWaterStorageTemp
  4. HotWaterCirculationPump
  5. VentilationProgtramsActive

The return I'm getting actually is:

 

( see attached file API Return.pdf).

The order in there is 

  1. Outside Temperature
  2. HotWaterStarageTemp
  3. HotWaterCirculationPump
  4. VentilationProgtramsActive
  5. OneTimeCharge

As for the actual usage, I changed my code in order to evaluate each JSON array element by feature.  

 

 

 

@JueBag for completeness: There is no defined order in the features within the response. So you need to evaluate the arrays in the JSON like you already are doing.

Top-Lösungsautoren