netatpi

A node.js module to use the Netatmo API


Keywords
netatmo, netatmo api, netatpi
License
CECILL-2.1
Install
npm install netatpi@0.1.1

Documentation

NETATPI

A node.js module to use the Netatmo API. See Netatmo API documentation.

Requirements

  1. A Netatmo account
  2. A Netatmo device set up.
  3. At least node LTS

Install

npm install netatpi

Use

Initialization

// Set your credentials
const credentials = {
    username: `[MY_NETATMO_USERNAME]`;
    password: `[MY_NETATMO_PASSWORD`;
    client_id: `[MY_NETATMO_CLIENT_ID]`;
    client_secret: `[MY_NETATMO_CLIENT_SECRET]`;
};

// Send credentials to netatpi's constructor.
// You cant restrict the scope by passing it in second argument (default all scopes)
// See: https://dev.netatmo.com/apidocumentation/oauth#scopes

const netatpi = new netatpi(credentials);

// Tip: You will be automaticatly authenticating by token (async)

Exemple 1: getstationsdata

https://dev.netatmo.com/apidocumentation/weather#getstationsdata

// The http method (get) will be automatically set
netatpi.call(
    // Call type: device.endpoint
    'weather.getstationsdata',
    // Parameters: {name: value}
    {
        device_id: `[MY_NETATMO_DEVICE_ID]`,
        get_favorites: false // See api doc
    },
    // Callback function called with the result
    handleApiCall,
    // Optional: Callback error function called with the error
    handleErrorApiCall
);

Exemple 2: setthermmode

https://dev.netatmo.com/apidocumentation/energy#setthermmode

// The http method (post) will be automatically set
netatpi.call(
    // Call type: device.endpoint
    'energy.setthermmode',
    // Parameters: {name: value}
    {
        home_id: `[MY_NETATMO_HOME_ID]`,
        mode: 'away' // See api doc
    },
    // Callback function called with the result
    handleApiCall,
    // Optional: Callback error function called with the error
    handleErrorApiCall
);

Informations

The token will be automatically renew. Don't worry about him.

Thanks

To the author of node.js module netatmo who inspired this one.

Licence

CeCILL © Christophe Deneuve