purpleair

package module
v0.0.0-...-5a00818 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pointer

func Pointer[T any](d T) *T

Types

type Client

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

func New

func New(key string) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) Keys

func (c *Client) Keys(ctx context.Context) (*KeysResponse, error)

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

func (*Client) SensorData

func (c *Client) SensorData(ctx context.Context, sensorIndex int, opts *SensorDataRequestOptions) (*SensorDataResponse, error)

func (*Client) SensorHistory

func (c *Client) SensorHistory(ctx context.Context, sensorIndex int, opts *SensorHistoryRequestOptions) (*SensorDataResponse, error)

type KeysResponse

type KeysResponse struct {
	ApiVersion string `json:"api_version"`
	TimeStamp  int64  `json:"time_stamp"`
	ApiKeyType string `json:"api_key_type"`
	// contains filtered or unexported fields
}

func (*KeysResponse) Body

func (kr *KeysResponse) Body() []byte

func (*KeysResponse) HttpResponse

func (kr *KeysResponse) HttpResponse() *http.Response

type ResponseError

type ResponseError struct {
	ApiVersion  string `json:"api_version"`
	TimeStamp   int64  `json:"time_stamp"`
	ErrorX      string `json:"error"`
	Description string `json:"description"`
}

func (*ResponseError) Error

func (r *ResponseError) Error() string

type Sensor

type Sensor struct {
	SensorIndex     int64   `json:"sensor_index"`
	LastModified    *int64  `json:"last_modified"`
	DateCreated     *int64  `json:"date_created"`
	LastSeen        *int64  `json:"last_seen"`
	Private         *uint8  `json:"private"`
	IsOwner         *uint8  `json:"is_owner"`
	Name            *string `json:"name"`
	LocationType    *uint8  `json:"location_type"`
	Model           *string `json:"model"`
	Hardware        *string `json:"hardware"`
	LedBrightness   *uint8  `json:"led_brightness"`
	FirmwareVersion *string `json:"firmware_version"`
	Rssi            *int64  `json:"rssi"`
	Uptime          *uint64 `json:"uptime"`

	Humidity     *uint8   `json:"humidity"`
	HumidityA    *uint8   `json:"humidity_a"`
	HumidityB    *uint8   `json:"humidity_b"`
	Temperature  *uint8   `json:"temperature"`
	TemperatureA *uint8   `json:"temperature_a"`
	TemperatureB *uint8   `json:"temperature_b"`
	Pressure     *float64 `json:"pressure"`
	PressureA    *float64 `json:"pressure_a"`
	PressureB    *float64 `json:"pressure_b"`
	Voc          *float64 `json:"voc"`
	VocA         *float64 `json:"voc_a"`
	VocB         *float64 `json:"voc_b"`
	AnalogInput  *float64 `json:"analog_input"`
	Pm10         *float64 `json:"pm1.0"`
	Pm10A        *float64 `json:"pm1.0_a"`
	Pm10B        *float64 `json:"pm1.0_b"`
	Pm25         *float64 `json:"pm2.5"`
	Pm25A        *float64 `json:"pm2.5_a"`
	Pm25B        *float64 `json:"pm2.5_b"`
	Pm25Alt      *float64 `json:"pm2.5_alt"`
	Pm25AltA     *float64 `json:"pm2.5_alt_a"`
	Pm25AltB     *float64 `json:"pm2.5_alt_b"`
	Pm100        *float64 `json:"pm10.0"`
	Pm100A       *float64 `json:"pm10.0_a"`
	Pm100B       *float64 `json:"pm10.0_b"`

	PrimaryIdA    *int64  `json:"primary_id_a"`
	PrimaryKeyA   *string `json:"primary_key_a"`
	PrimaryIdB    *int64  `json:"primary_id_b"`
	PrimaryKeyB   *string `json:"primary_key_b"`
	SecondaryIdA  *int64  `json:"secondary_id_a"`
	SecondaryKeyA *string `json:"secondary_key_a"`
	SecondaryIdB  *int64  `json:"secondary_id_b"`
	SecondaryKeyB *string `json:"secondary_key_b"`

	Stats  *SensorStats `json:"stats"`
	StatsA *SensorStats `json:"stats_a"`
	StatsB *SensorStats `json:"stats_b"`
}

type SensorDataRequestOptions

type SensorDataRequestOptions struct {
	Fields   []string
	ReadKeys []string
}

func (*SensorDataRequestOptions) Encode

func (o *SensorDataRequestOptions) Encode() string

type SensorDataResponse

type SensorDataResponse struct {
	ApiVersion    string  `json:"api_version"`
	TimeStamp     int64   `json:"time_stamp"`
	DataTimeStamp int64   `json:"data_time_stamp"`
	Sensor        *Sensor `json:"sensor"`
	// contains filtered or unexported fields
}

func (*SensorDataResponse) Body

func (r *SensorDataResponse) Body() []byte

func (*SensorDataResponse) HttpResponse

func (r *SensorDataResponse) HttpResponse() *http.Response

type SensorHistoryRequestOptions

type SensorHistoryRequestOptions struct {
	Fields   []string
	ReadKeys []string

	StartTimestamp *uint64
	EndTimestamp   *uint64
	Average        *uint16
}

func (*SensorHistoryRequestOptions) Encode

func (o *SensorHistoryRequestOptions) Encode() string

type SensorStats

type SensorStats struct {
	TimeStamp     int64   `json:"time_stamp"`
	Pm25          float64 `json:"pm2.5"`
	Pm25_10Minute float64 `json:"pm2.5_10minute"`
	Pm25_30Minute float64 `json:"pm2.5_30minute"`
	Pm25_60Minute float64 `json:"pm2.5_60minute"`
	Pm25_6Hour    float64 `json:"pm2.5_6hour"`
	Pm25_24Hour   float64 `json:"pm2.5_24hour"`
	Pm25_1Week    float64 `json:"pm2.5_1week"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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