tibber

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 8 Imported by: 0

README

tibber-go

Go developer module for tibber

Roadmap

Wokring Features
- Getting homes with GetHomes func
- Getting Price information for specific home with GetPriceInfo func
- Subscribing to real time consumption websocket using the newer graphql-transport-ws protocol
    - *homeId passed into method needs to correspond with a home with property: features.realTimeConsumptionEnabled*

Planned Features

- *Tibber*
    - Getting specific home
    - Mutations
- *This module*
    - Implement unit tests

Usage

TODO :D

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Address    string `json:"address1"`
	PostalCode string `json:"postalCode"`
	City       string `json:"city"`
	Country    string `json:"country"`
	Latitude   string `json:"latitude"`
	Longitude  string `json:"longitude"`
}

type CurrentSubscription

type CurrentSubscription struct {
	Id        string    `json:"id"`
	ValidFrom time.Time `json:"validFrom"`
	ValidTo   time.Time `json:"validTo"`
	PriceInfo PriceInfo `json:"priceInfo"`
}

type Features

type Features struct {
	RealTimeConsumptionEnabled bool `json:"realTimeConsumptionEnabled"`
}

Features - tibber pulse connected

type Home

type Home struct {
	ID                   string              `json:"id"`
	AppNickname          string              `json:"appNickname"`
	MeteringPointData    MeteringPointData   `json:"meteringPointData"`
	Features             Features            `json:"features"`
	Address              Address             `json:"address"`
	Size                 int                 `json:"size"`
	MainFuseSize         int                 `json:"mainFuseSize"`
	NumberOfResidents    int                 `json:"numberOfResidents"`
	PrimaryHeatingSource string              `json:"primaryHeatingSource"`
	HasVentilationSystem bool                `json:"hasVentilationSystem"`
	CurrentSubscription  CurrentSubscription `json:"currentSubscription"`
	PreviousMeterData    PreviousMeterData   `json:"previousMeterData"`
}

Home structure

type LiveMeasurement

type LiveMeasurement struct {
	HomeId                         string    `json:"homeId"`
	Timestamp                      time.Time `json:"timestamp"`
	Power                          float64   `json:"power"`
	MinPower                       float64   `json:"minPower"`
	AveragePower                   float64   `json:"averagePower"`
	MaxPower                       float64   `json:"maxPower"`
	LastMeterConsumption           float64   `json:"lastMeterConsumption"`
	LastMeterProduction            float64   `json:"lastMeterProduction"`
	AccumulatedConsumption         float64   `json:"accumulatedConsumption"`
	AccumulatedProduction          float64   `json:"accumulatedProduction"`
	AccumulatedCost                float64   `json:"accumulatedCost"`
	AccumulatedConsumptionLastHour float64   `json:"accumulatedConsumptionLastHour"`
	AccumulatedProductionLastHour  float64   `json:"accumulatedProductionLastHour"`
	Currency                       string    `json:"currency"`
}

type MeteringPointData

type MeteringPointData struct {
	ConsumptionEan string `json:"consumptionEan"`
}

MeteringPointData - meter number

type PreviousMeterData

type PreviousMeterData struct {
	Power           float64 `json:"power"`
	PowerProduction float64 `json:"powerProduction"`
}

type Price

type Price struct {
	Level    string    `json:"level"`
	Total    float64   `json:"total"`
	Energy   float64   `json:"energy"`
	Tax      float64   `json:"tax"`
	Currency string    `json:"currency"`
	StartsAt time.Time `json:"startsAt"`
}

type PriceInfo

type PriceInfo struct {
	Current  Price   `json:"current"`
	Today    []Price `json:"today"`
	Tomorrow []Price `json:"tomorrow"`
}

type QueryResponse

type QueryResponse struct {
	Viewer Viewer
}

type TibberClient

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

func CreateTibberClient

func CreateTibberClient(token string, agent string) *TibberClient

func (*TibberClient) Close

func (ctx *TibberClient) Close()

func (*TibberClient) GetHomes

func (ctx *TibberClient) GetHomes() (QueryResponse, error)

func (*TibberClient) GetPriceInfo

func (ctx *TibberClient) GetPriceInfo(homeId string) (CurrentSubscription, error)

func (*TibberClient) StartSubscription

func (ctx *TibberClient) StartSubscription(homeId string, outputChannel chan<- LiveMeasurement) error

type Viewer

type Viewer struct {
	Name   string `json:"name"`
	UserId string `json:"userId"`
	Homes  []Home `json:"homes"`
	Home   Home   `json:"home"`
}

Jump to

Keyboard shortcuts

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