enelogic

package
v0.0.0-...-ebd6d4f Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Day = time.Hour * 24
)

Variables

View Source
var (
	ErrNoData        = errors.New("no data from enelogic")
	ErrInvalidPeriod = errors.New("invalid period")
)

Functions

func Download

func Download(ctx context.Context, token string, startPeriod time.Time, endPeriod time.Time) ([]measurement.Measurement, error)

Download downloads the data from enelogic. A slice of measurements is returned, which can be saved to the database.

StartPeriod is the start of the period from which data should be downloaded. EndPeriod is the end of the period from which data should be downloaded. If EndPeriod is the zero value, the current time is used.

Types

type DataPoint

type DataPoint struct {
	Quantity Quantity     `json:"quantity"`
	Rate     Rate         `json:"rate"`
	Date     EnelogicTime `json:"date"`
	Datetime EnelogicTime `json:"datetime"`
}

func (DataPoint) Parse

func (d DataPoint) Parse(unit UnitType) measurement.Measurement

type DatapointsResponse

type DatapointsResponse []DataPoint

type EnelogicTime

type EnelogicTime struct {
	time.Time
	LocationName *string
}

EnelogicTime is a custom time type for enelogic. It is used to parse the time format used by enelogic.

func (EnelogicTime) MarshalJSON

func (t EnelogicTime) MarshalJSON() ([]byte, error)

func (EnelogicTime) String

func (t EnelogicTime) String() string

func (*EnelogicTime) UnmarshalJSON

func (t *EnelogicTime) UnmarshalJSON(b []byte) error

type MeasuringPoint

type MeasuringPoint struct {
	Timezone string   `json:"timezone"`
	ID       int      `json:"id"`
	UnitType UnitType `json:"unitType"`
}

type MeasuringsPointsResponse

type MeasuringsPointsResponse []MeasuringPoint

type Quantity

type Quantity float64

func (*Quantity) UnmarshalJSON

func (q *Quantity) UnmarshalJSON(b []byte) error

type Rate

type Rate int

Rate is the type of the Rate, as defined by enelogic.

const (
	RateUsageTotal  Rate = 180
	RateUsageLow    Rate = 181
	RateUsageHigh   Rate = 182
	RateReturnTotal Rate = 280
	RateReturnLow   Rate = 281
	RateReturnHigh  Rate = 282
)

Rate constants as defined by enelogic. See https://enelogic.com/nl/blog/slimme-meter-data-exporteren for more information.

func (Rate) Parse

func (r Rate) Parse(unit UnitType) string

type RequestArgs

type RequestArgs struct {
	MeasuringPointID int
	From             RequestTime
	To               RequestTime
}

type RequestTime

type RequestTime struct {
	time.Time
}

func (RequestTime) String

func (t RequestTime) String() string

type UnitType

type UnitType int

UnitType is the type of the unit. 0 = electricity. 1 = gas.

const (
	UnitTypeElectricity UnitType = 0
	UnitTypeGas         UnitType = 1
)

func (UnitType) String

func (u UnitType) String() string

Jump to

Keyboard shortcuts

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