Refactor dim/curtail handling- split hems and circuit (BC) (#30284)
This commit is contained in:
parent
3758ce1957
commit
8106dc8b76
70 changed files with 960 additions and 671 deletions
24
cmd/root.go
24
cmd/root.go
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue