I use this in a HomeyScript to get some JSON-data from a rooted Eneco Toon, for use in a flow:
var url = "http://192.168.1.30/happ_thermstat?action=getThermostatInfo";
(async () => {
const rawResponse = await fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
});
const content = await rawResponse.json();
//console.log(content);
if (content.currentTemp !== null && content.currentTemp != '') {
var currentTemp = content.currentTemp/100;
var setTemp = content.currentSetpoint/100;
var states = Array("Comfort", "Thuis", "Slapen", "Weg");
var state = states[content.activeState];
if (content.activeState == -1) {
state = "Not Set";
}
await setTagValue("toon_current", {type: "number", title: "Temperatuur op Toon®"}, currentTemp);
await setTagValue("toon_set", {type: "number", title: "Ingestelde temp. op Toon®"}, setTemp);
await setTagValue("toon_status", {type: "string", title: "Status op Toon®"}, state);
}
})();
return true;