netatmo

package
v0.0.0-...-b16572b Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package netatmo provides a client for the Netatmo weather API

Package netatmo provides a client for the Netatmo weather API

Package netatmo provides a client for the Netatmo weather API

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = http.DefaultClient

Functions

This section is empty.

Types

type Client

type Client struct {
	*Config
	*http.Client
	// contains filtered or unexported fields
}

Client is used to interact with Netatmo API

func NewClient

func NewClient(options map[string]any, storageCallback func(map[string]any) error) (*Client, error)

NewClient creates a new Netatmo API client from configuration If StationID is not provided, StationName is used to get it from the API If RainModuleID is not provided, RainModuleName is used to get it from the API For Authentication, AccessToken, RefreshToken, ClientID and ClientSecret are required

func (*Client) GetAverageHighTemperature

func (c *Client) GetAverageHighTemperature(ctx context.Context, since time.Duration) (*float32, error)

GetAverageHighTemperature returns the average daily high temperature between the given time and the end of yesterday (since daily high can be misleading if queried mid-day). If the API returns no data points, it returns (nil, nil) so callers can show N/A.

func (*Client) GetTotalRain

func (c *Client) GetTotalRain(ctx context.Context, since time.Duration) (*float32, error)

GetTotalRain returns the sum of all rainfall in millimeters in the given period. If the API returns no data points, it returns (nil, nil) so callers can show N/A.

type Config

type Config struct {
	StationID   string `json:"station_id,omitempty" yaml:"station_id,omitempty" mapstructure:"station_id,omitempty"`
	StationName string `json:"station_name,omitempty" yaml:"station_name,omitempty" mapstructure:"station_name,omitempty"`

	RainModuleID   string `json:"rain_module_id,omitempty" yaml:"rain_module_id,omitempty" mapstructure:"rain_module_id,omitempty"`
	RainModuleName string `json:"rain_module_name,omitempty" yaml:"rain_module_name,omitempty" mapstructure:"rain_module_name,omitempty"`

	OutdoorModuleID   string `json:"outdoor_module_id,omitempty" yaml:"outdoor_module_id,omitempty" mapstructure:"outdoor_module_id,omitempty"`
	OutdoorModuleName string `json:"outdoor_module_name,omitempty" yaml:"outdoor_module_name,omitempty" mapstructure:"outdoor_module_name,omitempty"`

	Authentication *TokenData `json:"authentication,omitempty" yaml:"authentication,omitempty" mapstructure:"authentication,omitempty"`
	ClientID       string     `json:"client_id,omitempty" yaml:"client_id,omitempty" mapstructure:"client_id,omitempty"`
	ClientSecret   string     `json:"client_secret,omitempty" yaml:"client_secret,omitempty" mapstructure:"client_secret,omitempty"` // nolint:gosec // config struct field
}

Config is specific to the Netatmo API and holds all of the necessary fields for interacting with the API. If StationID is not provided, StationName is used to get it from the API If RainModuleID is not provided, RainModuleName is used to get it from the API For Authentication, AccessToken, RefreshToken, ClientID and ClientSecret are required

type TokenData

type TokenData struct {
	AccessToken    string `json:"access_token,omitempty" yaml:"access_token,omitempty" mapstructure:"access_token,omitempty"`    // nolint:gosec // config struct field
	RefreshToken   string `json:"refresh_token,omitempty" yaml:"refresh_token,omitempty" mapstructure:"refresh_token,omitempty"` // nolint:gosec // config struct field
	ExpiresIn      int    `json:"expires_in,omitempty" yaml:"expires_in,omitempty" mapstructure:"expires_in,omitempty"`
	ExpirationDate string `json:"expiration_date,omitempty" yaml:"expiration_date,omitempty" mapstructure:"expiration_date,omitempty"`
}

TokenData contains information returned by Netatmo auth API

Jump to

Keyboard shortcuts

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