Tariffs: add outdoor temperature type and OpenMeteo (#27780)
Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
parent
68db0b7727
commit
d68e5e5809
34 changed files with 449 additions and 135 deletions
|
|
@ -121,6 +121,10 @@ func (t *Tariff) run(forecastG func() (string, error), done chan error, interval
|
|||
if t.typ == api.TariffTypeSolar {
|
||||
periodStart = beginningOfDay()
|
||||
}
|
||||
if t.typ == api.TariffTypeTemperature {
|
||||
// Keep 7 days of historical data (in 15-minute intervals) for temperature correction algorithm
|
||||
periodStart = time.Now().AddDate(0, 0, -7)
|
||||
}
|
||||
mergeRatesAfter(t.data, data, periodStart)
|
||||
|
||||
once.Do(func() { close(done) })
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import (
|
|||
)
|
||||
|
||||
type Tariffs struct {
|
||||
Currency currency.Unit
|
||||
Grid, FeedIn, Co2, Planner, Solar api.Tariff
|
||||
Currency currency.Unit
|
||||
Grid, FeedIn, Co2, Planner, Solar, Temperature api.Tariff
|
||||
}
|
||||
|
||||
// At returns the rate at the given time
|
||||
|
|
@ -109,6 +109,9 @@ func (t *Tariffs) Get(u api.TariffUsage) api.Tariff {
|
|||
case api.TariffUsageSolar:
|
||||
return t.Solar
|
||||
|
||||
case api.TariffUsageTemperature:
|
||||
return t.Temperature
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue