ambient

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2019 License: BSD-2-Clause Imports: 8 Imported by: 2

README

ambient

License GoDoc

AmbientWeather.net API Helper

Example program in https://github.com/lrosenman/ambient/tree/master/example

Official Doc:

https://ambientweather.docs.apiary.io/

Pull Requests, bug reports, code improvements, etc very much welcome.

package ambient // import "github.com/lrosenman/ambient"

Package ambient provides helper functions and Go types for accessing
ambientweather.net's API which is documented at

    https://ambientweather.docs.apiary.io/

const APIEP = "https://api.ambientweather.net/" + APIVer
const APIVer = "v1"
type APIDeviceMacResponse struct{ ... }
    func DeviceMac(key Key, macaddr string, endtime time.Time, limit int64) (APIDeviceMacResponse, error)
type APIDeviceResponse struct{ ... }
    func Device(key Key) (APIDeviceResponse, error)
type DeviceInfo struct{ ... }
type DeviceRecord struct{ ... }
type Key struct{ ... }
    func NewKey(applicationKey string, apiKey string) Key
type Record struct{ ... }

Documentation

Overview

Package ambient provides helper functions and Go types for accessing ambientweather.net's API which is documented at

https://ambientweather.docs.apiary.io/

Index

Constants

View Source
const APIEP = "https://api.ambientweather.net/" + APIVer

APIEP is the endpoint to be called.

View Source
const APIVer = "v1"

APIVer is the current version of the API.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIDeviceMacResponse

type APIDeviceMacResponse struct {
	Record           []Record
	RecordFields     []map[string]interface{}
	JSONResponse     []byte
	HTTPResponseCode int
	ResponseTime     time.Duration
}

APIDeviceMacResponse returns the data from /devices/macaddr API.

func DeviceMac

func DeviceMac(key Key, macaddr string, endtime time.Time, limit int64) (APIDeviceMacResponse, error)

DeviceMac issues a /devices/macaddr call.

type APIDeviceResponse

type APIDeviceResponse struct {
	DeviceRecord     []DeviceRecord
	JSONResponse     []byte
	HTTPResponseCode int
	ResponseTime     time.Duration
}

APIDeviceResponse returns the data from /devices API.

func Device

func Device(key Key) (APIDeviceResponse, error)

Device issues a /devices call.

type DeviceInfo

type DeviceInfo struct {
	Name     string
	Location string
}

DeviceInfo maps the info portion of the /devices API.

type DeviceRecord

type DeviceRecord struct {
	Macaddress     string
	Info           DeviceInfo
	LastData       Record
	LastDataFields map[string]interface{}
}

DeviceRecord maps one record of the /devices API.

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key holds the keys.

func NewKey

func NewKey(applicationKey string, apiKey string) Key

NewKey returns Key stucture to be used.

func (Key) APIKey

func (Key Key) APIKey() string

APIKey returns the currently set APIKey.

func (Key) ApplicationKey

func (Key Key) ApplicationKey() string

ApplicationKey returns the currently set ApplicationKey.

func (Key) SetAPIKey

func (Key Key) SetAPIKey(apiKey string)

SetAPIKey sets the APIKey

func (Key) SetApplicationKey

func (Key Key) SetApplicationKey(applicationKey string)

SetApplicationKey sets the applicationKey

type Record

type Record struct {
	Date           time.Time
	Baromabsin     float64
	Baromrelin     float64
	Battout        json.Number
	Batt1          json.Number
	Batt2          json.Number
	Batt3          json.Number
	Batt4          json.Number
	Batt5          json.Number
	Batt6          json.Number
	Batt7          json.Number
	Batt8          json.Number
	Batt9          json.Number
	Batt10         json.Number
	Co2            float64
	Dailyrainin    float64
	Dewpoint       float64
	Eventrainin    float64
	Feelslike      float64
	Hourlyrainin   float64
	Humidity       int
	Humidity1      int
	Humidity2      int
	Humidity3      int
	Humidity4      int
	Humidity5      int
	Humidity6      int
	Humidity7      int
	Humidity8      int
	Humidity9      int
	Humidity10     int
	Humidityin     int
	LastRain       time.Time
	Maxdailygust   float64
	Pm25           int
	Pm25_24h       float64
	Relay1         int
	Relay2         int
	Relay3         int
	Relay4         int
	Relay5         int
	Relay6         int
	Relay7         int
	Relay8         int
	Relay9         int
	Relay10        int
	Monthlyrainin  float64
	Solarradiation float64
	Tempf          float64
	Temp1f         float64
	Temp2f         float64
	Temp3f         float64
	Temp4f         float64
	Temp5f         float64
	Temp6f         float64
	Temp7f         float64
	Temp8f         float64
	Temp9f         float64
	Temp10f        float64
	Tempinf        float64
	Totalrainin    float64
	// BUG(lrosenman): Uv should be an int
	// but the WS-8478 device is reporting a float.
	// Per https://www.epa.gov/sunsafety/calculating-uv-index-0
	// it should be an int.
	// all consoles EXCEPT the WS-8478 return int, but we have to
	// accommodate the WS-8478.
	Uv                float64
	Weeklyrainin      float64
	Winddir           int
	Windgustmph       float64
	Windgustdir       int
	Windspeedmph      float64
	Winddir_avg2m     int
	Windspdmph_avg2m  float64
	Winddir_avg10m    int
	Windspdmph_avg10m float64
	Yearlyrainin      float64
	TZ                string
}

Record maps the data for a specific time as returned by the API.

Notes

Bugs

Directories

Path Synopsis
Example Program for the ambient package.
Example Program for the ambient package.

Jump to

Keyboard shortcuts

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