Skip to content

Instantly share code, notes, and snippets.

@jlwin
Last active January 23, 2018 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlwin/da44c309bc5f0ef6dd1d43c46807fcdf to your computer and use it in GitHub Desktop.
Save jlwin/da44c309bc5f0ef6dd1d43c46807fcdf to your computer and use it in GitHub Desktop.
netatmo dashboard
// requirements for netatmo
const express = require('express');
const netatmo = require('netatmo');
const port = 3000;
app.get('/netatmo-data', (req, res) => {
var auth = {
"client_id": "insert-id-here",
"client_secret": "insert-client-secret-here",
"username": "insert-username-email-here",
"password": "insert-password-here",
};
var api = new netatmo(auth);
api.on("error", (error) => {
// When the "error" event is emitted, this is called
console.error(`Netatmo threw an error: ${error}`);
});
api.on("warning", (error) => {
// When the "warning" event is emitted, this is called
console.log(`Netatmo threw a warning: ${error}`);
});
// Get Stations Data
// See docs: https://dev.netatmo.com/dev/resources/technical/reference/weatherstation/getstationsdata
api.getStationsData((err, devices) => {
res.status(200);
res.type('application/json');
res.send(devices);
});
});
// port
app.listen(port, () => {
console.log(`server is up on port ${port}`);
});
@jlwin
Copy link
Author

jlwin commented Jan 23, 2018

Deploy the Node.JS Code to a Digital Ocean Droplet, install "express" and "netatmo" using npm:

npm install express, netatmo

run the script and access your Droplets IP adress in your browser followed by the port (in this case 3000):
http://your.ip.address:3000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment