price

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApagaLuzAPIUrl       = "https://raw.githubusercontent.com/jorgeatgu/apaga-luz/main/public/data/today_price.json"
	ApagaLuzCanaryAPIUrl = "https://raw.githubusercontent.com/jorgeatgu/apaga-luz/main/public/data/canary_price.json"

	// Location of retrieved data from ApagaLuz
	ApagaLuzApiTimeLocation       = "Europe/Madrid"
	ApagaLuzCanaryApiTimeLocation = "Atlantic/Canary"

	//
	ActiveHoursOutOfRangeErrorMessage = "config.device.activeHours field must be a number between 1 and 24"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HourData

type HourData struct {
	Day   string  `json:"day"`
	Hour  int     `json:"hour"`
	Price float64 `json:"price"`
	Zone  string  `json:"zone"`
}

HourData represents each of the individual items in the response retrieved from ApagaLuz API

type HourDataList

type HourDataList []HourData

HourDataList represents the entire response retrieved from ApagaLuz API

func GetApiData

func GetApiData(ctx *v1alpha1.Context) (response *HourDataList, err error)

GetApiData TODO

func GetApiDataByPrice

func GetApiDataByPrice(ctx *v1alpha1.Context) (response *HourDataList, err error)

TODO

func GetLimitedCorrelativeHourRanges

func GetLimitedCorrelativeHourRanges(ctx *v1alpha1.Context) (correlativeRanges []HourDataList, err error)

GetLimitedCorrelativeHourRanges return an array whose elements are lists of correlative hours. Those hours were previously sorted and selected by having the lowest price as criteria

type Schedule

type Schedule struct {
	Start time.Time
	Stop  time.Time
}

Schedule represents a time range to start and stop an external device

func GetBestSchedules

func GetBestSchedules(ctx *v1alpha1.Context) (schedules []Schedule, err error)

GetBestSchedules return a list of schedules that meet 'active hours' config parameter Starts are delayed by 5 minutes, and stops are 5 minutes early. Done in purpose to avoid time collisions on parallel scheduling. This can be improved a lot. Are you willing to contribute?

Jump to

Keyboard shortcuts

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