Skip to content

Commit

Permalink
Merge branch 'evcc-io:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
deadrabbit87 authored Nov 21, 2024
2 parents 6ac3afe + 0dad8b8 commit 0043172
Show file tree
Hide file tree
Showing 170 changed files with 4,057 additions and 2,128 deletions.
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ builds:
goarch: arm
- goos: windows
goarch: arm64
overrides:
- goos: darwin
ldflags:
- "-B gobuildid"

env:
- CGO_ENABLED=0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ build::
CGO_ENABLED=0 go build -v $(BUILD_TAGS) $(BUILD_ARGS)

snapshot::
goreleaser --snapshot --skip-publish --clean
goreleaser --snapshot --skip publish --clean

release::
goreleaser --clean
Expand Down
9 changes: 7 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type CurrentGetter interface {
GetMaxCurrent() (float64, error)
}

// BatteryController optionally allows to control home battery (dis)charging behaviour
// BatteryController optionally allows to control home battery (dis)charging behavior
type BatteryController interface {
SetBatteryMode(BatteryMode) error
}
Expand Down Expand Up @@ -120,7 +120,7 @@ type Authorizer interface {
Authorize(key string) error
}

// PhaseDescriber returns the number of availablephases
// PhaseDescriber returns the number of available phases
type PhaseDescriber interface {
Phases() int
}
Expand Down 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
72 changes: 44 additions & 28 deletions api/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions api/rates.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"errors"
"fmt"
"slices"
"time"
)
Expand Down Expand Up @@ -36,5 +36,9 @@ func (r Rates) Current(now time.Time) (Rate, error) {
}
}

return Rate{}, errors.New("no matching rate")
if len(r) == 0 {
return Rate{}, fmt.Errorf("no matching rate for: %s", now.Local().Format(time.RFC3339))
}
return Rate{}, fmt.Errorf("no matching rate for: %s, %d rates (%s to %s)",
now.Local().Format(time.RFC3339), len(r), r[0].Start.Local().Format(time.RFC3339), r[len(r)-1].End.Local().Format(time.RFC3339))
}
Loading

0 comments on commit 0043172

Please sign in to comment.