Tariffs: add outdoor temperature type and OpenMeteo (#27780)

Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
Daniel Martin 2026-07-17 14:54:56 +02:00 • committed by GitHub
parent 68db0b7727
commit d68e5e5809
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 449 additions and 135 deletions

View file

@ -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) })

View file

@ -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
}