Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config UI: HEMS configuration status #17001

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
23 changes: 19 additions & 4 deletions api/globalconfig/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"`
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
12 changes: 10 additions & 2 deletions assets/js/views/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
>
<template #icon><HemsIcon /></template>
<template #tags>
<DeviceTags :tags="yamlTags('hems')" />
<DeviceTags :tags="hemsTags" />
</template>
</DeviceCard>
</ul>
Expand Down Expand Up @@ -395,7 +395,6 @@ export default {
eebus: false,
circuits: false,
modbusproxy: false,
hems: false,
},
};
},
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()}

Expand Down
2 changes: 1 addition & 1 deletion cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enabled = "Ladebereit"
energy = "Energie"
feedinPrice = "Einspeisevergütung"
gridPrice = "Netzpreis"
hemsType = "System"
no = "Nein"
odometer = "Kilometerstand"
org = "Organisation"
Expand Down
1 change: 1 addition & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enabled = "Enabled"
energy = "Energy"
feedinPrice = "Feed-in price"
gridPrice = "Grid price"
hemsType = "System"
no = "no"
odometer = "Odometer"
org = "Organization"
Expand Down
8 changes: 3 additions & 5 deletions util/tee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package util
import (
"reflect"
"sync"

"github.com/evcc-io/evcc/api"
)

// TeeAttacher allows attaching a listener to a tee
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}

Expand Down