Documentation ¶
Index ¶
- Constants
- Variables
- func Download(ctx context.Context, token string, startPeriod time.Time, endPeriod time.Time) ([]measurement.Measurement, error)
- type DataPoint
- type DatapointsResponse
- type EnelogicTime
- type MeasuringPoint
- type MeasuringsPointsResponse
- type Quantity
- type Rate
- type RequestArgs
- type RequestTime
- type UnitType
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 ¶
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 MeasuringsPointsResponse ¶
type MeasuringsPointsResponse []MeasuringPoint
type Rate ¶
type Rate int
Rate is the type of the Rate, as defined by enelogic.
type RequestArgs ¶
type RequestArgs struct { MeasuringPointID int From RequestTime To RequestTime }
type RequestTime ¶
func (RequestTime) String ¶
func (t RequestTime) String() string
Click to show internal directories.
Click to hide internal directories.