Planner: drop deprecated publishing keys #2 (BC) (#26540)

This commit is contained in:
Ingo 2026-02-01 19:38:19 +01:00 • committed by GitHub
parent 8d350a7a65
commit e1accfeb9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 135 additions and 142 deletions

View file

@ -1,17 +1,45 @@
package api
import "time"
import (
"encoding/json"
"time"
)
type RepeatingPlan struct {
Weekdays []int `json:"weekdays"` // 0-6 (Sunday-Saturday)
Time string `json:"time"` // HH:MM
Tz string `json:"tz"` // timezone in IANA format
Soc int `json:"soc"` // target soc
Active bool `json:"active"` // active flag
Precondition int64 `json:"-" todo:"..."` // TODO deprecated
Weekdays []int `json:"weekdays"` // 0-6 (Sunday-Saturday)
Time string `json:"time"` // HH:MM
Tz string `json:"tz"` // timezone in IANA format
Soc int `json:"soc"` // target soc
Active bool `json:"active"` // active flag
}
type PlanStrategy struct {
Continuous bool `json:"continuous"` // force continuous planning
Precondition time.Duration `json:"precondition"` // precondition duration in seconds
}
type planStrategy struct {
Continuous bool `json:"continuous"` // force continuous planning
Precondition int64 `json:"precondition"` // precondition duration in seconds
}
func (ps PlanStrategy) MarshalJSON() ([]byte, error) {
return json.Marshal(planStrategy{
Continuous: ps.Continuous,
Precondition: int64(ps.Precondition.Seconds()),
})
}
func (ps *PlanStrategy) UnmarshalJSON(data []byte) error {
var res planStrategy
if err := json.Unmarshal(data, &res); err != nil {
return err
}
*ps = PlanStrategy{
Continuous: res.Continuous,
Precondition: time.Duration(res.Precondition) * time.Second,
}
return nil
}