Huge news!Announcing our $20M Series A led by Andreessen Horowitz.Learn more
Socket
Socket
Log inDemoInstall

github.com/alexhowarth/go-weatherlink

Package Overview
Dependencies
1
Maintainers
0
Issues
File Explorer

github.com/alexhowarth/go-weatherlink

Package weatherlink provides a client to the Davis Weatherlink weather station API

    v1.0.4

Version published
Maintainers
0

Readme

GoDoc Go Report Card

This package provides a Go library for the Davis WeatherLink v2 API.

Installation

go get github.com/alexhowarth/go-weatherlink

Usage

// configure
config := weatherlink.Config{
        Key:    "mykey",
        Secret: "mysecret",
}

// build a client
wl := config.NewClient()

// all weather stations associated with your key
st, err := wl.AllStations()
if err != nil {
        // handle error
}

// current conditions for a station
cu, err := wl.Current(123)
if err != nil {
        // handle error
}

// historic for a station
start := time.Now().Add(-time.Hour * 2)
end := time.Now()

h, err := wl.Historic(123, start, end)
if err != nil {
        // handle error
}

for _, v := range h.Sensors {
        for _, d := range v.Data {
                fmt.Printf("Time: %v Temp: %v\n", time.Unix(d.Ts, 0), d.TempOut)
	}
}

Command line tool

This package contains the command line tool weatherlink-cli. To install and use it:

$ go install weatherlink-cli
$ weatherlink-cli --help

To extract certain data from the output, you might use jq:

$ weatherlink-cli historic --key mykey --secret mysecret --station 2970 --start="2020-07-08T00:00:00Z" --end="2020-07-08T01:00:00Z"| jq -r '.sensors[].data[] | "timestamp: \(.ts) temp_out: \(.temp_out) bar: \(.bar)"'

timestamp: 1594167300 temp_out: 76.8 bar: 30.018
timestamp: 1594167600 temp_out: 76.8 bar: 30.014

TODO

The following are not currently implemented:

  • Nodes
  • SensorActivity

This is work in progress. Let me know if something breaks or if your sensor type is not supported.

API

Documentation for the API can be found at https://weatherlink.github.io/v2-api/

FAQs

Last updated on 15 Jul 2020

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install
SocketSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc