ambient

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 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
	Battin             json.Number
	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
	Batt_co2           json.Number
	Batt_lightning     json.Number
	Co2                float64
	Dailyrainin        float64
	Dewpoint           float64
	Dewpoint1          float64
	Dewpoint2          float64
	Dewpoint3          float64
	Dewpoint4          float64
	Dewpoint5          float64
	Dewpoint6          float64
	Dewpoint7          float64
	Dewpoint8          float64
	Dewpoint9          float64
	Dewpoint10         float64
	Dewpointin         float64
	Eventrainin        float64
	Feelslike          float64
	Feelslike1         float64
	Feelslike2         float64
	Feelslike3         float64
	Feelslike4         float64
	Feelslike5         float64
	Feelslike6         float64
	Feelslike7         float64
	Feelslike8         float64
	Feelslike9         float64
	Feelslike10        float64
	Feelslikein        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
	Lightning_day      int
	Lightning_distance float64
	Lightning_hour     int
	Lightning_time     time.Time
	Pm25               float64
	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
	Soiltemp1f         float64
	Soiltemp2f         float64
	Soiltemp3f         float64
	Soiltemp4f         float64
	Soiltemp5f         float64
	Soiltemp6f         float64
	Soiltemp7f         float64
	Soiltemp8f         float64
	Soiltemp9f         float64
	Soiltemp10f        float64
	Soilhum1           float64
	Soilhum2           float64
	Soilhum3           float64
	Soilhum4           float64
	Soilhum5           float64
	Soilhum6           float64
	Soilhum7           float64
	Soilhum8           float64
	Soilhum9           float64
	Soilhum10          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
	Aqi_pm25_in       int
	Aqi_pm25_in_24h   int
}

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