update doc

This commit is contained in:
Nicolas Leclercq 2016-11-14 13:48:34 +01:00
parent 9900516e0f
commit 688dd7bf76
1 changed files with 53 additions and 48 deletions

101
README.md
View File

@ -1,7 +1,7 @@
# netatmo-api-go # netatmo-api-go
Simple API to access Netatmo weather station data written in Go. Simple API to access Netatmo weather station data written in Go.
Currently tested only with one weather station, outdoor and indoor modules. Let me know if it works with rain or wind gaude. Currently tested only with one weather station, outdoor and indoor modules and rain gauge. Let me know if it works with wind gauge.
## Quickstart ## Quickstart
@ -11,72 +11,77 @@ Currently tested only with one weather station, outdoor and indoor modules. Let
## Example ## Example
```go ```
import ( go
"fmt" package main
"os"
"github.com/exzz/netatmo-api-go" import (
"fmt"
"os"
netatmo "github.com/exzz/netatmo-api-go"
) )
func main() { func main() {
n, err := netatmo.NewClient(netatmo.Config{ n, err := netatmo.NewClient(netatmo.Config{
ClientID: "YOUR_APP_ID", ClientID: "YOUR_APP_ID",
ClientSecret: "YOUR_APP_SECRET", ClientSecret: "YOUR_APP_SECRET",
Username: "YOUR_CREDENTIAL", Username: "YOUR_CREDENTIAL",
Password: "YOUR_PASSWORD", Password: "YOUR_PASSWORD",
}) })
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }
dc, err := n.Read() dc, err := n.Read()
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }
for _, station := range dc.Stations() { for _, station := range dc.Stations() {
fmt.Printf("Station : %s\n", station.StationName) fmt.Printf("Station : %s\n", station.StationName)
for _, module := range station.Modules() { for _, module := range station.Modules() {
fmt.Printf("\tModule : %s\n", module.ModuleName) fmt.Printf("\tModule : %s\n", module.ModuleName)
ts, data := module.Data() ts, data := module.Data()
for dataType, value := range data { for dataType, value := range data {
fmt.Printf("\t\t%s : %s (%d)\n", dataType, value, ts) fmt.Printf("\t\t%s : %s (%d)\n", dataType, value, ts)
} }
} }
} }
} }
``` ```
Output should look like this : Output should look like this :
``` ```
Station : Home Station : Home
Module : Outside Module : Chambre Enfant
Temperature : %!s(float32=20.2) (1440302379) Temperature : %!s(float32=18.4) (1479127223)
Humidity : %!s(int32=86) (1440302379) CO2 : %!s(int32=567) (1479127223)
Module : Bedroom 1 Humidity : %!s(int32=65) (1479127223)
CO2 : %!s(int32=500) (1441981664) Module : Chambre
Humidity : %!s(int32=69) (1441981664) Temperature : %!s(float32=18.1) (1479127230)
Temperature : %!s(float32=21.2) (1441981664) CO2 : %!s(int32=494) (1479127230)
Module : Bedroom 2 Humidity : %!s(int32=65) (1479127230)
Temperature : %!s(float32=21) (1441981632) Module : Salon
CO2 : %!s(int32=508) (1441981632) Temperature : %!s(float32=18.3) (1479127217)
Humidity : %!s(int32=68) (1441981632) CO2 : %!s(int32=434) (1479127217)
Module : Living room Humidity : %!s(int32=63) (1479127217)
Temperature : %!s(float32=22.1) (1441981633) Module : Exterieur
CO2 : %!s(int32=516) (1441981633) Temperature : %!s(float32=11.9) (1479127243)
Humidity : %!s(int32=67) (1441981633) Humidity : %!s(int32=81) (1479127243)
Module : Dining room Module : Pluie
Humidity : %!s(int32=75) (1441982895) Rain : %!s(float32=0) (1479127249)
Noise : %!s(int32=36) (1441982895) Module : Salle à manger
Pressure : %!s(float32=1015.9) (1441982895) Temperature : %!s(float32=17.8) (1479127255)
Temperature : %!s(float32=21.5) (1441982895) CO2 : %!s(int32=473) (1479127255)
CO2 : %!s(int32=582) (1441982895) Humidity : %!s(int32=68) (1479127255)
Noise : %!s(int32=36) (1479127255)
Pressure : %!s(float32=1033.3) (1479127255)
``` ```
## Tips ## Tips