npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

netatmo-api-client

v1.1.5

Published

Client for the Netatmo API

Downloads

448

Readme

netatmo-api-client npm version Downloads

This is a simple client for the Netatmo Weather API.

Getting started

  1. create an account on https://dev.netatmo.com
  2. create an app (information can be arbitrary)
    1. use the client ID and client secret of the created app
  3. request a token by using the token generator
    1. select scope read_station
    2. click Generate Token
    3. use the generated access and refresh tokens

Generate Token

Example usage

const netatmoClient = new NetatmoApiClient('<CLIENT_ID>', '<CLIENT_SECRET>');

// set tokens acquire from the token generator
netatmoClient.setTokens('<ACCESS_TOKEN>', '<REFRESH_TOKEN>');

// use the client
const stationData = await netatmoClient.getStationData();
const { modules, ...mainStationData } = stationData.devices[0];
console.log(mainStationData);
console.log('User: ', stationData.user);

for (const station of stationData.devices) {
  console.log('='.repeat(80));
  console.log(`${station.stationName} [${station.id}] has ${station.modules.length} modules`);

  for (const module of [station, ...station.modules]) {
    console.log('-'.repeat(80));
    console.log(`${module.moduleName} [${module.id}] has these capabilities: ${module.capabilities}`);

    const measureCount = 2;
    const measures = await netatmoClient.getMeasure(station.id, module, undefined, undefined, '5min', measureCount);

    console.log(`Latest ${measureCount} measures:`);
    console.log(measures);
  }

  console.log('-'.repeat(80));
  console.log('='.repeat(80) + '\n');
}

The above example should print something like this:

{
  id: "aa:bb:cc:dd:ee:ff",
  type: "MAIN_MODULE",
  moduleName: "A",
  stationName: "B (A)",
  firmware: 204,
  reachable: true,
  lastSetup: 2014-12-24T15:14:51.000Z,
  dateSetup: 2014-12-24T15:14:51.000Z,
  lastStatusUpdate: 2024-11-05T00:05:15.000Z,
  lastUpgrade: 2015-08-20T19:06:50.000Z,
  wifiStatus: 25,
  co2Calibrating: false,
  place: {
    altitude: 250,
    city: "Example Town",
    country: "DE",
    timezone: "Europe/Berlin",
    longitude: 42.0000000,
    latitude: 42.0000000,
  },
  capabilities: [ "TEMPERATURE", "CO2", "HUMIDITY", "NOISE", "PRESSURE" ],
  measureTime: 2024-11-05T00:04:28.000Z,
  readOnly: undefined,
  temperature: {
    current: 23.1,
    min: 22.8,
    max: 23.4,
    dateMin: 2024-11-04T23:03:57.000Z,
    dateMax: 2024-11-04T23:39:16.000Z,
    trend: "STABLE",
  },
  co2: 769,
  humidity: 58,
  noise: 37,
  pressure: {
    current: 1019.4,
    absolute: 982.5,
    trend: "STABLE",
  },
}
User:  {
  mail: "[email protected]",
  administrative: {
    country: "DE",
    locale: "de",
    regionalLocale: "de-DE",
    pressureUnit: "MBAR",
    systemOfMeasurement: "METRIC",
    windUnit: "KPH",
    feelLikeTemperatureAlgorithm: "HUMIDEX",
  },
}
================================================================================
Station Name [aa:bb:cc:dd:ee:ff] has 6 modules
--------------------------------------------------------------------------------
Module Name [aa:bb:cc:dd:ee:ff] has these capabilities: TEMPERATURE,CO2,HUMIDITY,NOISE,PRESSURE
Latest 2 measures:
{
  "1419433800": {
    temperature: 21.9,
    co2: null,
    humidity: 65,
    noise: null,
    pressure: 973,
  },
  "1419434400": {
    temperature: 22,
    co2: 0,
    humidity: 63,
    noise: 38,
    pressure: 972.9,
  },
}
--------------------------------------------------------------------------------
Module Name [aa:bb:cc:dd:ee:ff] has these capabilities: BATTERY,CO2,HUMIDITY,TEMPERATURE
Latest 2 measures:
{
  "1448400600": {
    co2: null,
    humidity: 47,
    temperature: 25.5,
  },
  "1448400900": {
    co2: 1344,
    humidity: 48,
    temperature: 25,
  },
}
--------------------------------------------------------------------------------
Module Name [aa:bb:cc:dd:ee:ff] has these capabilities: BATTERY,RAIN
Latest 2 measures:
{
  "1448402700": {
    rain: 0.273,
    sum_rain: 0.545308740978348,
  },
  "1448403000": {
    rain: 1.091,
    sum_rain: 1.090617481956696,
  },
}
--------------------------------------------------------------------------------
Module Name [aa:bb:cc:dd:ee:ff] has these capabilities: BATTERY,WIND
Latest 2 measures:
{
  "1605442800": {
    windstrength: 1,
    windangle: 147,
    guststrength: 2,
    gustangle: 90,
  },
  "1605443400": {
    windstrength: 2,
    windangle: 173,
    guststrength: 5,
    gustangle: 169,
  },
}
--------------------------------------------------------------------------------
Module Name [aa:bb:cc:dd:ee:ff] has these capabilities: BATTERY,HUMIDITY,TEMPERATURE
Latest 2 measures:
{
  "1668168000": {
    humidity: 95,
    temperature: 23.5,
  },
  "1668168300": {
    humidity: 86,
    temperature: 23.9,
  },
}
--------------------------------------------------------------------------------
================================================================================