diff --git a/cmd/root.go b/cmd/root.go index dbdd8252f..299c40906 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,10 +15,12 @@ import ( "github.com/evcc-io/evcc/core" "github.com/evcc-io/evcc/push" "github.com/evcc-io/evcc/server" + "github.com/evcc-io/evcc/server/modbus" "github.com/evcc-io/evcc/server/updater" "github.com/evcc-io/evcc/util" "github.com/evcc-io/evcc/util/pipe" "github.com/evcc-io/evcc/util/sponsor" + "github.com/evcc-io/evcc/util/telemetry" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/cobra" @@ -156,6 +158,23 @@ func runRoot(cmd *cobra.Command, args []string) { site, err = configureSiteAndLoadpoints(conf) } + // setup telemetry + if err == nil { + telemetry.Create(conf.Plant) + if conf.Telemetry { + err = telemetry.Enable(true) + } + } + + // setup modbus proxy + if err == nil { + for _, cfg := range conf.ModbusProxy { + if err = modbus.StartProxy(cfg.Port, cfg.Settings, cfg.ReadOnly); err != nil { + break + } + } + } + // setup database if err == nil && conf.Influx.URL != "" { configureInflux(conf.Influx, site.LoadPoints(), tee.Attach()) diff --git a/cmd/setup.go b/cmd/setup.go index b51e43035..30c942ee4 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -27,7 +27,6 @@ import ( "github.com/evcc-io/evcc/util/pipe" "github.com/evcc-io/evcc/util/request" "github.com/evcc-io/evcc/util/sponsor" - "github.com/evcc-io/evcc/util/telemetry" "github.com/libp2p/zeroconf/v2" "github.com/samber/lo" "github.com/spf13/cobra" @@ -93,14 +92,6 @@ func configureEnvironment(cmd *cobra.Command, conf config) (err error) { err = configureDatabase(conf.Database) } - // setup telemetry - if err == nil { - telemetry.Create(conf.Plant) - if conf.Telemetry { - err = telemetry.Enable(true) - } - } - // setup mqtt client listener if err == nil && conf.Mqtt.Broker != "" { err = configureMQTT(conf.Mqtt)