velux

package
v0.0.0-...-2c72a02 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Bridge = "NXG"
View Source
const DepartureSwitch = "NXD"
View Source
const RollerShutter = "NXO"
View Source
const Sensor = "NXS"

Variables

View Source
var Endpoint = oauth2.Endpoint{
	AuthURL:   "https://app.velux-active.com/oauth2/token",
	TokenURL:  "https://app.velux-active.com/oauth2/token",
	AuthStyle: oauth2.AuthStyleInParams,
}

Functions

This section is empty.

Types

type AuthTransport

type AuthTransport struct {
	AppVersion string `json:"app_version"`
	UserPrefix string `json:"user_prefix"`
}

AuthTransport can be used to add the required custom fields for an OAuth2 client using golang.org/x/oauth2.

Example: hc := &http.Client{Transport: &AuthTransport{VG: *vg}} ctx := context.WithValue(context.Background(), oauth2.HTTPClient, hc)

func DefaultAuthTransport

func DefaultAuthTransport() *AuthTransport

func (*AuthTransport) RoundTrip

func (t *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string
	Verbose   bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Velux API client. If a nil httpClient is provided, a new http.Client will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).

func NewClientWithAuth

func NewClientWithAuth(username, password string) *Client

NewClientWithAuth returns a new Velux API client using the supplied credentials.

func (*Client) GetHomesData

func (c *Client) GetHomesData(request GetHomesDataRequest) (GetHomesDataResponse, error)

func (*Client) HomeStatus

func (c *Client) HomeStatus(request HomeStatusRequest) (HomeStatusResponse, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type GetHomesDataRequest

type GetHomesDataRequest struct {
	GatewayTypes []string `url:"gateway_types,omitempty"`
}

type GetHomesDataResponse

type GetHomesDataResponse struct {
	Body struct {
		Homes []struct {
			ID    string `json:"id"`
			Name  string `json:"name"`
			Rooms []struct {
				ID   string `json:"id"`
				Name string `json:"name"`
			} `json:"rooms"`
		} `json:"homes"`
	} `json:"body"`
}

type HomeStatusRequest

type HomeStatusRequest struct {
	HomeID      string   `url:"home_id"`
	DeviceTypes []string `url:"device_types"`
}

type HomeStatusResponse

type HomeStatusResponse struct {
	Body struct {
		Home struct {
			ID    string `json:"id"`
			Rooms []struct {
				AirQuality            int    `json:"air_quality"`
				AlgoScheduleStart     int    `json:"algo_schedule_start"`
				AlgoStatus            int    `json:"algo_status"`
				AutoCloseTS           int    `json:"auto_close_ts"`
				CO2                   int    `json:"co2"`
				Humidity              int    `json:"humidity"`
				ID                    string `json:"id"`
				Lux                   int    `json:"lux"`
				MaxComfortCO2         int    `json:"max_comfort_co2"`
				MaxComfortHumidity    int    `json:"max_comfort_humidity"`
				MaxComfortTemperature int    `json:"max_comfort_temperature"`
				MinComfortHumidity    int    `json:"min_comfort_humidity"`
				MinComfortTemperature int    `json:"min_comfort_temperature"`
				Temperature           int    `json:"temperature"`
			} `json:"rooms"`
		} `json:"home"`
	} `json:"body"`
}

Jump to

Keyboard shortcuts

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