Ostrom: add SimplyDynamic_V2 contract type (#28726)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
Copilot 2026-04-02 08:50:43 +02:00 • committed by GitHub
parent 388a1480b0
commit e988deaf25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 11 deletions

View file

@ -100,8 +100,13 @@ func NewOstromFromConfig(other map[string]any) (api.Tariff, error) {
t.contractType = contract.Product
t.zip = contract.Address.Zip
tariffType, err := t.tariffType()
if err != nil {
return nil, err
}
done := make(chan error)
if t.Type() == api.TariffTypePriceStatic {
if tariffType == api.TariffTypePriceStatic {
t.cityId, err = t.getCityId()
if err != nil {
return nil, err
@ -253,14 +258,23 @@ func (t *Ostrom) Rates() (api.Rates, error) {
return res, err
}
// Type implements the api.Tariff interface
func (t *Ostrom) Type() api.TariffType {
// tariffType returns the tariff type for the current contract, or an error for unknown contract types.
func (t *Ostrom) tariffType() (api.TariffType, error) {
switch t.contractType {
case ostrom.PRODUCT_DYNAMIC:
return api.TariffTypePriceForecast
case ostrom.PRODUCT_DYNAMIC, ostrom.PRODUCT_DYNAMIC_V2:
return api.TariffTypePriceForecast, nil
case ostrom.PRODUCT_FAIR, ostrom.PRODUCT_FAIR_CAP:
return api.TariffTypePriceStatic
return api.TariffTypePriceStatic, nil
default:
panic("invalid contract type: " + t.contractType)
return 0, fmt.Errorf("invalid contract type: %s", t.contractType)
}
}
// Type implements the api.Tariff interface
func (t *Ostrom) Type() api.TariffType {
tariffType, err := t.tariffType()
if err != nil {
panic(err.Error())
}
return tariffType
}

View file

@ -19,10 +19,11 @@ const (
)
const (
PRODUCT_FAIR = "SIMPLY_FAIR"
PRODUCT_FAIR_CAP = "SIMPLY_FAIR_WITH_PRICE_CAP"
PRODUCT_DYNAMIC = "SIMPLY_DYNAMIC"
PRODUCT_BASIC = "basisProdukt"
PRODUCT_FAIR = "SIMPLY_FAIR"
PRODUCT_FAIR_CAP = "SIMPLY_FAIR_WITH_PRICE_CAP"
PRODUCT_DYNAMIC = "SIMPLY_DYNAMIC"
PRODUCT_DYNAMIC_V2 = "SimplyDynamic_V2"
PRODUCT_BASIC = "basisProdukt"
)
type Prices struct {