diff --git a/api/api.go b/api/api.go index 5aac9e77f..33860d935 100644 --- a/api/api.go +++ b/api/api.go @@ -241,3 +241,8 @@ type Circuit interface { ValidateCurrent(old, new float64) float64 ValidatePower(old, new float64) float64 } + +// Redactor is an interface to redact sensitive data +type Redactor interface { + Redacted() any +} diff --git a/api/globalconfig/types.go b/api/globalconfig/types.go index 42d649e92..8e9b6e30f 100644 --- a/api/globalconfig/types.go +++ b/api/globalconfig/types.go @@ -6,6 +6,7 @@ import ( "strconv" "time" + "github.com/evcc-io/evcc/api" "github.com/evcc-io/evcc/provider/mqtt" "github.com/evcc-io/evcc/push" "github.com/evcc-io/evcc/server/eebus" @@ -30,7 +31,7 @@ type All struct { Go []Go Influx Influx EEBus eebus.Config - HEMS config.Typed + HEMS Hems Messaging Messaging Meters []config.Named Chargers []config.Named @@ -57,6 +58,20 @@ type ModbusProxy struct { modbus.Settings `mapstructure:",squash"` } +var _ api.Redactor = (*Hems)(nil) + +type Hems config.Typed + +func (c Hems) Redacted() any { + return struct { + Type string `json:"type,omitempty"` + }{ + Type: c.Type, + } +} + +var _ api.Redactor = (*Mqtt)(nil) + type Mqtt struct { mqtt.Config `mapstructure:",squash"` Topic string `json:"topic"` @@ -68,9 +83,9 @@ func (m Mqtt) Redacted() any { return struct { Broker string `json:"broker"` Topic string `json:"topic"` - User string `json:"user"` - ClientID string `json:"clientID"` - Insecure bool `json:"insecure"` + User string `json:"user,omitempty"` + ClientID string `json:"clientID,omitempty"` + Insecure bool `json:"insecure,omitempty"` }{ Broker: m.Broker, Topic: m.Topic, diff --git a/assets/css/app.css b/assets/css/app.css index e6d656934..40ecaa9fc 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -620,6 +620,15 @@ html.app .modal-dialog { color: var(--bs-danger-text-emphasis) !important; } +.dark .round-box--error { + box-shadow: 0 0 0.5rem var(--bs-warning); + border: 1px solid var(--bs-warning); +} + +.dark .round-box--error .tags * { + color: var(--bs-warning) !important; +} + .alert-danger code { color: var(--evcc-darkest-green); } diff --git a/assets/js/views/Config.vue b/assets/js/views/Config.vue index d68bf9504..1ac69a627 100644 --- a/assets/js/views/Config.vue +++ b/assets/js/views/Config.vue @@ -261,7 +261,7 @@ > @@ -395,7 +395,6 @@ export default { eebus: false, circuits: false, modbusproxy: false, - hems: false, }, }; }, @@ -454,6 +453,15 @@ export default { if (org) result.org = { value: org }; return result; }, + hemsTags() { + const result = { configured: { value: false } }; + const { type } = store.state?.hems || {}; + if (type) { + result.configured.value = true; + result.hemsType = { value: type }; + } + return result; + }, }, watch: { offline() { diff --git a/cmd/root.go b/cmd/root.go index 82d74917c..4fb4ef7ea 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -211,6 +211,7 @@ func runRoot(cmd *cobra.Command, args []string) { valueChan <- util.Param{Key: keys.Network, Val: conf.Network} valueChan <- util.Param{Key: keys.Mqtt, Val: conf.Mqtt} valueChan <- util.Param{Key: keys.Influx, Val: conf.Influx} + valueChan <- util.Param{Key: keys.Hems, Val: conf.HEMS} // TODO valueChan <- util.Param{Key: keys.Sponsor, Val: sponsor.Status()} diff --git a/cmd/setup.go b/cmd/setup.go index 0827489e6..6629b9c71 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -645,7 +645,7 @@ func configureGo(conf []globalconfig.Go) error { } // setup HEMS -func configureHEMS(conf config.Typed, site *core.Site, httpd *server.HTTPd) error { +func configureHEMS(conf globalconfig.Hems, site *core.Site, httpd *server.HTTPd) error { // migrate settings if settings.Exists(keys.Hems) { if err := settings.Yaml(keys.Hems, new(map[string]any), &conf); err != nil { diff --git a/i18n/de.toml b/i18n/de.toml index ec1047241..6675672eb 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -60,6 +60,7 @@ enabled = "Ladebereit" energy = "Energie" feedinPrice = "Einspeisevergütung" gridPrice = "Netzpreis" +hemsType = "System" no = "Nein" odometer = "Kilometerstand" org = "Organisation" diff --git a/i18n/en.toml b/i18n/en.toml index d0b9262eb..d8755d279 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -60,6 +60,7 @@ enabled = "Enabled" energy = "Energy" feedinPrice = "Feed-in price" gridPrice = "Grid price" +hemsType = "System" no = "no" odometer = "Odometer" org = "Organization" diff --git a/util/tee.go b/util/tee.go index dae3bcafa..81973f75f 100644 --- a/util/tee.go +++ b/util/tee.go @@ -3,6 +3,8 @@ package util import ( "reflect" "sync" + + "github.com/evcc-io/evcc/api" ) // TeeAttacher allows attaching a listener to a tee @@ -32,10 +34,6 @@ func (t *Tee) add(out chan<- Param) { t.recv = append(t.recv, out) } -type redactor interface { - Redacted() any -} - // Run starts parameter distribution func (t *Tee) Run(in <-chan Param) { for msg := range in { @@ -45,7 +43,7 @@ func (t *Tee) Run(in <-chan Param) { } } - if val, ok := (msg.Val).(redactor); ok { + if val, ok := (msg.Val).(api.Redactor); ok { msg.Val = val.Redacted() }