netatmo dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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