netatmo

package module
v0.0.0-...-1f48884 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 6 Imported by: 0

README

netatmo-api-go

Simple API to access Netatmo weather station data written in Go.

Quickstart

  • Create a new netatmo app
  • Edit test/sample.confwith your credentials
  • run go run test/netatmo-api-test.go -f test/sample.conf
  • Output shall look like :
Station : Home               
        Module : Chambre Elsa                              
                BatteryPercent : 47 (updated 323s ago)     
                RFStatus : 68 (updated 323s ago)           
                Temperature : 22.8 (updated 323s ago)      
                Humidity : 53 (updated 323s ago)           
                CO2 : 446 (updated 323s ago)               
        Module : Chambre parents                           
                BatteryPercent : 50 (updated 323s ago)     
                RFStatus : 71 (updated 323s ago)           
                Temperature : 19.9 (updated 323s ago)      
                Humidity : 61 (updated 323s ago)           
                CO2 : 428 (updated 323s ago)               
        Module : Chambre Jules                             
                BatteryPercent : 46 (updated 323s ago)     
                RFStatus : 60 (updated 323s ago)           
                CO2 : 396 (updated 323s ago)               
                Temperature : 22 (updated 323s ago)        
                Humidity : 54 (updated 323s ago)           
        Module : Exterieur   
                BatteryPercent : 37 (updated 323s ago)     
                RFStatus : 66 (updated 323s ago)           
                Temperature : 23.4 (updated 323s ago)      
                Humidity : 52 (updated 323s ago)           
        Module : Pluie       
                BatteryPercent : 72 (updated 9684499s ago)
                RFStatus : 54 (updated 9684499s ago)       
                Rain : 0.101 (updated 9684499s ago)        
        Module : Living      
                WifiStatus : 37 (updated 278s ago)         
                Temperature : 24 (updated 278s ago)        
                Humidity : 49 (updated 278s ago)           
                CO2 : 733 (updated 278s ago)               
                Noise : 50 (updated 278s ago)              
                Pressure : 1028.1 (updated 278s ago)       
                AbsolutePressure : 1008.4 (updated 278s ago)

Tips

  • Only Read() method actually do an API call and refresh all data at once
  • Main station is handle as a module, it means that Modules() method returns list of additional modules and station itself.
  • Data() returns sensors values (such as temperature) whereas Info() returns module status (such as battery level)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Dc *DeviceCollection
	// contains filtered or unexported fields
}

Client use to make request to Netatmo API

func NewClient

func NewClient(config Config) (*Client, error)

NewClient create a handle authentication to Netamo API

func (*Client) Read

func (c *Client) Read() (*DeviceCollection, error)

GetStations returns the list of stations owned by the user, and their modules

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	Username     string
	Password     string
}

Config is used to specify credential to Netatmo API ClientID : Client ID from netatmo app registration at http://dev.netatmo.com/dev/listapps ClientSecret : Client app secret Username : Your netatmo account username Password : Your netatmo account password

type DashboardData

type DashboardData struct {
	Temperature      *float32 `json:"Temperature,omitempty"` // use pointer to detect ommitted field by json mapping
	Humidity         *int32   `json:"Humidity,omitempty"`
	CO2              *int32   `json:"CO2,omitempty"`
	Noise            *int32   `json:"Noise,omitempty"`
	Pressure         *float32 `json:"Pressure,omitempty"`
	AbsolutePressure *float32 `json:"AbsolutePressure,omitempty"`
	Rain             *float32 `json:"Rain,omitempty"`
	Rain1Hour        *float32 `json:"sum_rain_1,omitempty"`
	Rain1Day         *float32 `json:"sum_rain_24,omitempty"`
	WindAngle        *int32   `json:"WindAngle,omitempty"`
	WindStrength     *int32   `json:"WindStrength,omitempty"`
	GustAngle        *int32   `json:"GustAngle,omitempty"`
	GustStrength     *int32   `json:"GustStrength,omitempty"`
	LastMeasure      *int64   `json:"time_utc"`
}

DashboardData is used to store sensor values Temperature : Last temperature measure @ LastMeasure (in °C) Humidity : Last humidity measured @ LastMeasure (in %) CO2 : Last Co2 measured @ time_utc (in ppm) Noise : Last noise measured @ LastMeasure (in db) Pressure : Last Sea level pressure measured @ LastMeasure (in mb) AbsolutePressure : Real measured pressure @ LastMeasure (in mb) Rain : Last rain measured (in mm) Rain1Hour : Amount of rain in last hour Rain1Day : Amount of rain today WindAngle : Current 5 min average wind direction @ LastMeasure (in °) WindStrength : Current 5 min average wind speed @ LastMeasure (in km/h) GustAngle : Direction of the last 5 min highest gust wind @ LastMeasure (in °) GustStrength : Speed of the last 5 min highest gust wind @ LastMeasure (in km/h) LastMeasure : Contains timestamp of last data received

type Device

type Device struct {
	ID             string `json:"_id"`
	StationName    string `json:"station_name"`
	ModuleName     string `json:"module_name"`
	BatteryPercent *int32 `json:"battery_percent,omitempty"`
	WifiStatus     *int32 `json:"wifi_status,omitempty"`
	RFStatus       *int32 `json:"rf_status,omitempty"`
	Type           string
	DashboardData  DashboardData `json:"dashboard_data"`
	//DataType      []string      `json:"data_type"`
	LinkedModules []*Device `json:"modules"`
}

Device is a station or a module ID : Mac address StationName : Station name (only for station) ModuleName : Module name BatteryPercent : Percentage of battery remaining WifiStatus : Wifi status per Base station RFStatus : Current radio status per module Type : Module type :

"NAMain" : for the base station
"NAModule1" : for the outdoor module
"NAModule4" : for the additionnal indoor module
"NAModule3" : for the rain gauge module
"NAModule2" : for the wind gauge module

DashboardData : Data collection from device sensors DataType : List of available datas LinkedModules : Associated modules (only for station)

func (*Device) Data

func (d *Device) Data() (int64, map[string]interface{})

Data returns timestamp and the list of sensor value for this module

func (*Device) Info

func (d *Device) Info() (int64, map[string]interface{})

Info returns timestamp and the list of info value for this module

func (*Device) Modules

func (d *Device) Modules() []*Device

Modules returns associated device module

type DeviceCollection

type DeviceCollection struct {
	Body struct {
		Devices []*Device `json:"devices"`
	}
}

DeviceCollection hold all devices from netatmo account

func (*DeviceCollection) Devices

func (dc *DeviceCollection) Devices() []*Device

Devices returns the list of devices

func (*DeviceCollection) Stations

func (dc *DeviceCollection) Stations() []*Device

Stations is an alias of Devices

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL