Config UI: split SHM HEMS into separate config (BC) (#23190)
This commit is contained in:
parent
018b07ce62
commit
15958df887
24 changed files with 407 additions and 114 deletions
|
|
@ -7,11 +7,11 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const _ClassName = "configfilemeterchargervehicletariffcircuitsitemqttdatabasemodbusproxyeebusjavascriptgohemsinfluxmessengersponsorshiploadpoint"
|
||||
const _ClassName = "configfilemeterchargervehicletariffcircuitsitemqttdatabasemodbusproxyeebusjavascriptgohemsshminfluxmessengersponsorshiploadpoint"
|
||||
|
||||
var _ClassIndex = [...]uint8{0, 10, 15, 22, 29, 35, 42, 46, 50, 58, 69, 74, 84, 86, 90, 96, 105, 116, 125}
|
||||
var _ClassIndex = [...]uint8{0, 10, 15, 22, 29, 35, 42, 46, 50, 58, 69, 74, 84, 86, 90, 93, 99, 108, 119, 128}
|
||||
|
||||
const _ClassLowerName = "configfilemeterchargervehicletariffcircuitsitemqttdatabasemodbusproxyeebusjavascriptgohemsinfluxmessengersponsorshiploadpoint"
|
||||
const _ClassLowerName = "configfilemeterchargervehicletariffcircuitsitemqttdatabasemodbusproxyeebusjavascriptgohemsshminfluxmessengersponsorshiploadpoint"
|
||||
|
||||
func (i Class) String() string {
|
||||
i -= 1
|
||||
|
|
@ -39,13 +39,14 @@ func _ClassNoOp() {
|
|||
_ = x[ClassJavascript-(12)]
|
||||
_ = x[ClassGo-(13)]
|
||||
_ = x[ClassHEMS-(14)]
|
||||
_ = x[ClassInflux-(15)]
|
||||
_ = x[ClassMessenger-(16)]
|
||||
_ = x[ClassSponsorship-(17)]
|
||||
_ = x[ClassLoadpoint-(18)]
|
||||
_ = x[ClassSHM-(15)]
|
||||
_ = x[ClassInflux-(16)]
|
||||
_ = x[ClassMessenger-(17)]
|
||||
_ = x[ClassSponsorship-(18)]
|
||||
_ = x[ClassLoadpoint-(19)]
|
||||
}
|
||||
|
||||
var _ClassValues = []Class{ClassConfigFile, ClassMeter, ClassCharger, ClassVehicle, ClassTariff, ClassCircuit, ClassSite, ClassMqtt, ClassDatabase, ClassModbusProxy, ClassEEBus, ClassJavascript, ClassGo, ClassHEMS, ClassInflux, ClassMessenger, ClassSponsorship, ClassLoadpoint}
|
||||
var _ClassValues = []Class{ClassConfigFile, ClassMeter, ClassCharger, ClassVehicle, ClassTariff, ClassCircuit, ClassSite, ClassMqtt, ClassDatabase, ClassModbusProxy, ClassEEBus, ClassJavascript, ClassGo, ClassHEMS, ClassSHM, ClassInflux, ClassMessenger, ClassSponsorship, ClassLoadpoint}
|
||||
|
||||
var _ClassNameToValueMap = map[string]Class{
|
||||
_ClassName[0:10]: ClassConfigFile,
|
||||
|
|
@ -76,14 +77,16 @@ var _ClassNameToValueMap = map[string]Class{
|
|||
_ClassLowerName[84:86]: ClassGo,
|
||||
_ClassName[86:90]: ClassHEMS,
|
||||
_ClassLowerName[86:90]: ClassHEMS,
|
||||
_ClassName[90:96]: ClassInflux,
|
||||
_ClassLowerName[90:96]: ClassInflux,
|
||||
_ClassName[96:105]: ClassMessenger,
|
||||
_ClassLowerName[96:105]: ClassMessenger,
|
||||
_ClassName[105:116]: ClassSponsorship,
|
||||
_ClassLowerName[105:116]: ClassSponsorship,
|
||||
_ClassName[116:125]: ClassLoadpoint,
|
||||
_ClassLowerName[116:125]: ClassLoadpoint,
|
||||
_ClassName[90:93]: ClassSHM,
|
||||
_ClassLowerName[90:93]: ClassSHM,
|
||||
_ClassName[93:99]: ClassInflux,
|
||||
_ClassLowerName[93:99]: ClassInflux,
|
||||
_ClassName[99:108]: ClassMessenger,
|
||||
_ClassLowerName[99:108]: ClassMessenger,
|
||||
_ClassName[108:119]: ClassSponsorship,
|
||||
_ClassLowerName[108:119]: ClassSponsorship,
|
||||
_ClassName[119:128]: ClassLoadpoint,
|
||||
_ClassLowerName[119:128]: ClassLoadpoint,
|
||||
}
|
||||
|
||||
var _ClassNames = []string{
|
||||
|
|
@ -101,10 +104,11 @@ var _ClassNames = []string{
|
|||
_ClassName[74:84],
|
||||
_ClassName[84:86],
|
||||
_ClassName[86:90],
|
||||
_ClassName[90:96],
|
||||
_ClassName[96:105],
|
||||
_ClassName[105:116],
|
||||
_ClassName[116:125],
|
||||
_ClassName[90:93],
|
||||
_ClassName[93:99],
|
||||
_ClassName[99:108],
|
||||
_ClassName[108:119],
|
||||
_ClassName[119:128],
|
||||
}
|
||||
|
||||
// ClassString retrieves an enum value from the enum constants string name.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/cloudfoundry/jibber_jabber"
|
||||
"github.com/evcc-io/evcc/hems/semp"
|
||||
"github.com/evcc-io/evcc/hems/shm"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/machine"
|
||||
"github.com/evcc-io/evcc/util/templates"
|
||||
|
|
@ -277,7 +277,7 @@ func (c *CmdConfigure) configureDevices(deviceCategory DeviceCategory, askAdding
|
|||
// configureSMAHems asks the user if he wants to add the SMA HEMS
|
||||
func (c *CmdConfigure) configureSMAHems() {
|
||||
// check if the system provides a machine-id
|
||||
if _, err := semp.UniqueDeviceID(); err != nil {
|
||||
if _, err := shm.UniqueDeviceID(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ const (
|
|||
ClassJavascript
|
||||
ClassGo
|
||||
ClassHEMS
|
||||
ClassSHM
|
||||
ClassInflux
|
||||
ClassMessenger
|
||||
ClassSponsorship
|
||||
|
|
|
|||
|
|
@ -252,9 +252,14 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
err = configureMDNS(conf.Network)
|
||||
}
|
||||
|
||||
// start SHM server
|
||||
if err == nil {
|
||||
err = wrapErrorWithClass(ClassSHM, configureSHM(&conf.SHM, site, httpd))
|
||||
}
|
||||
|
||||
// start HEMS server
|
||||
if err == nil {
|
||||
err = wrapErrorWithClass(ClassHEMS, configureHEMS(&conf.HEMS, site, httpd))
|
||||
err = wrapErrorWithClass(ClassHEMS, configureHEMS(&conf.HEMS, site))
|
||||
}
|
||||
|
||||
// setup MCP
|
||||
|
|
@ -277,6 +282,7 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
// publish initial settings
|
||||
valueChan <- util.Param{Key: keys.EEBus, Val: conf.EEBus.Configured()}
|
||||
valueChan <- util.Param{Key: keys.Hems, Val: conf.HEMS}
|
||||
valueChan <- util.Param{Key: keys.Shm, Val: conf.SHM}
|
||||
valueChan <- util.Param{Key: keys.Influx, Val: conf.Influx}
|
||||
valueChan <- util.Param{Key: keys.Interval, Val: conf.Interval}
|
||||
valueChan <- util.Param{Key: keys.Messaging, Val: conf.Messaging.Configured()}
|
||||
|
|
|
|||
20
cmd/setup.go
20
cmd/setup.go
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/evcc-io/evcc/core/session"
|
||||
coresettings "github.com/evcc-io/evcc/core/settings"
|
||||
"github.com/evcc-io/evcc/hems"
|
||||
"github.com/evcc-io/evcc/hems/shm"
|
||||
"github.com/evcc-io/evcc/meter"
|
||||
"github.com/evcc-io/evcc/plugin/golang"
|
||||
"github.com/evcc-io/evcc/plugin/javascript"
|
||||
|
|
@ -674,6 +675,21 @@ func configureMqtt(conf *globalconfig.Mqtt) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// setup SHM
|
||||
func configureSHM(conf *shm.Config, site *core.Site, httpd *server.HTTPd) error {
|
||||
if settings.Exists(keys.Shm) {
|
||||
if err := settings.Json(keys.Shm, &conf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := shm.NewFromConfig(*conf, site, httpd.Addr, httpd.Router()); err != nil {
|
||||
return fmt.Errorf("failed configuring shm: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// setup javascript
|
||||
func configureJavascript(conf []globalconfig.Javascript) error {
|
||||
for _, cc := range conf {
|
||||
|
|
@ -695,7 +711,7 @@ func configureGo(conf []globalconfig.Go) error {
|
|||
}
|
||||
|
||||
// setup HEMS
|
||||
func configureHEMS(conf *globalconfig.Hems, site *core.Site, httpd *server.HTTPd) error {
|
||||
func configureHEMS(conf *globalconfig.Hems, site *core.Site) error {
|
||||
// migrate settings
|
||||
if settings.Exists(keys.Hems) {
|
||||
*conf = globalconfig.Hems{}
|
||||
|
|
@ -713,7 +729,7 @@ func configureHEMS(conf *globalconfig.Hems, site *core.Site, httpd *server.HTTPd
|
|||
return fmt.Errorf("cannot decode custom hems '%s': %w", conf.Type, err)
|
||||
}
|
||||
|
||||
hems, err := hems.NewFromConfig(context.TODO(), conf.Type, props, site, httpd)
|
||||
hems, err := hems.NewFromConfig(context.TODO(), conf.Type, props, site)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed configuring hems: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue