fvdm / nodejs-toonapp

Eneco Toon module for node.js
https://www.npmjs.com/package/toonapp
The Unlicense
6 stars 0 forks source link

Get complete list of available states #13

Open DutchmanNL opened 6 years ago

DutchmanNL commented 6 years ago

Hi, thank you for this NPM package !

How is it possible to return all available states which toon can provide ?

Following code only provide feedback "javascript.1 script.js.Test_Omgeving.Toon_Binding: null"

// Set your Eneco account details
var toon = require ('toonapp') ({
  username: 'xxxx',
  password: 'xxxxx'
});

// Set preset to Home
toon.setPreset (1, function (err, data) {
  if (err) {
    console.log (err);
    return;
  }

  // OK, now get full status
  toon.getState (console.log);
});

When adding the the example "data.powerUsage" in my code i get the current value which is nice ! But now i would like to understand which states i can request by this NPM package to include in my scripting.

// Set your Eneco account details
var toon = require ('toonapp') ({
  username: 'xxxx',
  password: 'xxxx'
});

// Set preset to Home
toon.setPreset (1, function (err, data) {
  if (err) {
    console.log (err);
    return;
  }

  // OK, now get full status
  toon.getState (console.log);

    toon.getState (function (err, data) {
    if (err) { return console.log (err); }
    // Current Watt/h from smart meter
    if (data.powerUsage) {
        console.log (data.powerUsage.value);
    }

    });
});
fvdm commented 6 years ago

First, I see you already edited out your credentials. I recommend to change your password as soon as possible, because services that are connected to this repo also received your details! It can end up anywhere now.


To get the full set of data from your Toon you need to run getState() multiple times. I don’t know why that is. In my experience the 1st in a certain timeframe often fails, the 2nd request usually includes the basic thermostatInfo, the 3rd gives powerUsage and the huge monthData stats.

What is reported back can vary a lot; the inclusion of one set of data does not promise another set is included as well. I have seen these so far, but there can be more:

I doubt this will ever become stable. They have released an official API for Toon which doesn’t require network snooping to figure out how it works.. My other package toonapi is focused on the API, but I still need to complete it.