Refactor dim/curtail handling- split hems and circuit (BC) (#30284)

This commit is contained in:
andig 2026-06-07 13:22:03 +02:00 • committed by GitHub
parent 3758ce1957
commit 8106dc8b76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
70 changed files with 960 additions and 671 deletions

View file

@ -343,9 +343,27 @@ func runRoot(cmd *cobra.Command, args []string) {
// start HEMS server
if err == nil {
_, err = configureHEMS(&conf.HEMS, site)
if err != nil {
err = wrapErrorWithClass(ClassHEMS, err)
if hems, errConf := configureHEMS(&conf.HEMS, site); errConf == nil && hems != nil {
// republish when HEMS state updates
hems.SetUpdated(func() {
valueChan <- util.Param{Key: keys.Hems, Val: globalconfig.ConfigStatus{
Config: conf.HEMS.Redacted(),
YamlSource: yamlSource.hems,
Status: struct {
Dimmed bool `json:"dimmed"`
Curtailed bool `json:"curtailed"`
MaxConsumptionPower float64 `json:"maxConsumptionPower,omitempty"`
MaxProductionPower *float64 `json:"maxProductionPower,omitempty"`
}{
Dimmed: hems.Dimmed(),
Curtailed: hems.Curtailed(),
MaxConsumptionPower: hems.MaxConsumptionPower(),
MaxProductionPower: hems.MaxProductionPower(),
},
}}
})
} else {
err = wrapErrorWithClass(ClassHEMS, errConf)
}
}

View file

@ -802,6 +802,8 @@ func configureHEMS(conf *globalconfig.Hems, site *core.Site) (hemsapi.API, error
return nil, fmt.Errorf("failed configuring hems: %w", err)
}
site.SetHEMS(hems)
go hems.Run()
return hems, nil