Add remote access (#28688)

This commit is contained in:
Michael Geers 2026-04-13 22:21:33 +02:00 • committed by GitHub
parent 16f2f89d42
commit 9b8ac11777
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 1778 additions and 14 deletions

View file

@ -22,6 +22,7 @@ import (
"github.com/evcc-io/evcc/server/eebus"
"github.com/evcc-io/evcc/server/mcp"
"github.com/evcc-io/evcc/server/network"
"github.com/evcc-io/evcc/server/remote"
"github.com/evcc-io/evcc/server/updater"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/auth"
@ -237,6 +238,12 @@ func runRoot(cmd *cobra.Command, args []string) {
// publish to UI
go socketHub.Run(pipe.NewDropper(ignoreEmpty).Pipe(tee.Attach()), cache)
// remote access tunnel
var remoteAccess *remote.Remote
if remoteHost := os.Getenv("EVCC_REMOTE_ACCESS"); remoteHost != "" {
remoteAccess = remote.New(remoteHost, httpd.Router(), valueChan)
}
// signal ui listening
valueChan <- util.Param{Key: keys.StartupCompleted, Val: false}
@ -385,6 +392,11 @@ func runRoot(cmd *cobra.Command, args []string) {
YamlSource: yamlSource.tariffs,
}}
// publish remote access status
if remoteAccess != nil {
valueChan <- util.Param{Key: keys.Remote, Val: remoteAccess.ConfigStatus()}
}
// publish system infos
valueChan <- util.Param{Key: keys.Version, Val: util.FormattedVersion()}
valueChan <- util.Param{Key: keys.Config, Val: viper.ConfigFileUsed()}
@ -429,7 +441,7 @@ func runRoot(cmd *cobra.Command, args []string) {
log.INFO.Println("evcc was stopped by user. OS should restart the service. Or restart manually.")
err = errors.New("restart required") // https://gokrazy.org/development/process-interface/
once.Do(func() { close(stopC) }) // signal loop to end
}, viper.ConfigFileUsed())
}, viper.ConfigFileUsed(), remoteAccess)
// show and check version, reduce api load during development
if util.Version != util.DevVersion {