Code Monkey home page Code Monkey logo

docker-telegraf-netatmo's Introduction

Netatmo script for telegraf

This repository contains a script for retrieving data of a netatmo weather station for use with telegraf.

First obtain API keys from the Netatmo developmer website:

https://dev.netatmo.com/

Dependencies

The script requires ruby 2.0 or newer.

Usage

Usage: netatmo [options]
    -i, --initial-token=TOKEN        Refresh token to initialize authentication
    -c, --config=PATH                Path to configuration file

Example

Here is an example what data is read from the station (with one outdoor sensor):

{
  "station": {
    "Innenraum": {
      "wifi_status": 65,
      "Temperature": 21.9,
      "CO2": 1246,
      "Humidity": 62,
      "Noise": 37,
      "Pressure": 1010.2,
      "AbsolutePressure": 975.4,
      "AbsoluteHumidity": 11.96
    },
    "Aussenraum": {
      "battery_percent": 45,
      "rf_status": 74,
      "Temperature": 15.8,
      "Humidity": 100,
      "AbsoluteHumidity": 13.45
    }
  }
}

Or with include_station_name: false:

{
  "Innenraum": {
    "wifi_status": 66,
    "Temperature": 21.8,
    "CO2": 1242,
    "Humidity": 62,
    "Noise": 47,
    "Pressure": 1010,
    "AbsolutePressure": 975.2,
    "AbsoluteHumidity": 11.89
  },
  "Aussenraum": {
    "battery_percent": 45,
    "rf_status": 74,
    "Temperature": 15.6,
    "Humidity": 100,
    "AbsoluteHumidity": 13.29
  }
}

The AbsoluteHumidity values are calculated by the script.

Configuration

The script reads credentials from the configuration file:

---
client_id: <hex-value>
client_secret: <hex-value>
device_id: <station MAC>
# include_station_name: false # returns stations data on root level
token_path: /var/lib/netatmo/token.yml

Authentication

To access the Netatmo API an authentication token must be setup. The token will written to the token_path configured in the configuration file. This file must be writable by the script as the token will be renewed every 3h.

In the Netatmo "My Apps" page go to your applications settings and generate a token in the "Token generator" section.

The Refresh Token must be passed to the netatmo script with the -i option to initialize the authentication. The script will immediately refresh the token passed and write the new token to the token_path.

On all following invocations the script will use this token and refresh it whenever it expires.

Telegraf configuration

You need to configure a exec input in your telegraf.conf:

[[outputs.influxdb]]
  urls = ["http://influxdb:8086"]
  database = "telegraf"

[[inputs.exec]]
  commands = ["/usr/local/bin/netatmo"]
  interval = "10m"
  timeout = "15s"
  data_format = "json"
  name_suffix = "_netatmo"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.