Categorygithub.com/rk295/bright-golang
modulepackage
0.0.10
Repository: https://github.com/rk295/bright-golang.git
Documentation: pkg.go.dev

# README

Go client library for the Bright API

Go Reference CI

Package bright-golang is a client for the Bright App energy monitoring API.

Not all the API endpoints are implemented, however there should be sufficient to at least get Electricity and Gas usage out. There are a few helper functions which attempt to figure out which resource holds the current usage (in Watts) for both gas and electricity, they are the simplest ways of using the package.

A username and password for the API is required, you can either pass those into NewClient() or you can have them read from the environment by calling NewClientFromEnv(). This uses the BRIGHT_USERNAME and BRIGHT_PASSWORD environment variables.

To quickly see your current electricity usage in Watts you could do somehting like:

package main
import (
	"fmt"
	"github.com/rk295/bright-golang"
)

func main() {
	c, _ := bright.NewClientFromEnv()
	electricityWatts, _ := c.GetElectricityCurrentWatts()
	fmt.Println(electricityWatts)
}

Ouput: 566

Indicating that 566W of electricity is being used now.

Sample apps

Simple CLI

In cmd/sample-client there is a simple sample application. Have a look at the README.md in there for more.

MQTT

In cmd/sample-mqtt there is a MQTT client which will connect to Bright via MQTT if they have enabled it for you. There is a README.md in there with more info.

Prometheus Exporter

in cmd/bright-exporter-api there is a Prometheus exporter which fetches data from the Bright API. Again have a look at the README.md in that directory.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewClient returns a bright.Client.
NewClientFromEnv returns a bright.Client drawing its configuration from the os environment.
NewTestClient returns a dummy client used by the tests.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Auth holds the authentication token and expiry time.
AuthRequest represents a request to the Bright API to authenticate ourselves.
AuthResponse holds the response from an authentication response.
Client represents a bright API client.
Config represents the configuration of the client.
DataSourceResourceTypeInfo holds the Unit and Type of the Data Source Resource returned by the API.
DataSourceUnitInfo holds Data Source unit info.
Devices represents a single device know to the API.
No description provided by the author
No description provided by the author
No description provided by the author
Query represents a query to the readings API.
Reading represents a single reading returned from the API.
Resource represents a resource as defined by the API.
Resourcecurrent represents the current (as in now) usage of the Resource.
ResourceType represents a single resource type.
No description provided by the author
No description provided by the author
No description provided by the author
VEResources represents the Resources returned as part of a VirtualEntity.
VirtualEntity represents a single Virtual Entity returned by the API.

# Type aliases

ClassfierField is the type applied for the classifier fields returned by the API.
Devices is a slice of Device.
ReadingUnitField represents all the possible units the API can return.
Resources is a slice of Resources.
ResourceTypes.
VirtualEntities is a slice of VirtualEntities.