Skip to content

Commit 977913b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 08960fb + fe388db commit 977913b

File tree

150 files changed

+1338
-1371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+1338
-1371
lines changed

api/globalconfig/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/evcc-io/evcc/api"
10-
"github.com/evcc-io/evcc/provider/mqtt"
10+
"github.com/evcc-io/evcc/plugin/mqtt"
1111
"github.com/evcc-io/evcc/push"
1212
"github.com/evcc-io/evcc/server/eebus"
1313
"github.com/evcc-io/evcc/util/config"

assets/js/views/Config.vue

+10-9
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,17 @@ export default {
619619
async updateValues() {
620620
clearTimeout(this.deviceValueTimeout);
621621
if (!this.offline) {
622-
const promises = [
623-
...this.meters.map((meter) => this.updateDeviceValue("meter", meter.name)),
624-
...this.vehicles.map((vehicle) =>
625-
this.updateDeviceValue("vehicle", vehicle.name)
626-
),
627-
];
628-
629-
await Promise.all(promises);
622+
for (const meter of this.meters) {
623+
await this.updateDeviceValue("meter", meter.name);
624+
}
625+
for (const vehicle of this.vehicles) {
626+
await this.updateDeviceValue("vehicle", vehicle.name);
627+
}
630628
}
631-
this.deviceValueTimeout = setTimeout(this.updateValues, 10000);
629+
// ensure that component is still mounted
630+
if (!this.$el) return;
631+
const interval = (store.state?.interval || 30) * 1000;
632+
this.deviceValueTimeout = setTimeout(this.updateValues, interval);
632633
},
633634
deviceTags(type, id) {
634635
return this.deviceValues[type]?.[id] || [];

charger/charger.go

+25-34
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/evcc-io/evcc/api"
99
"github.com/evcc-io/evcc/meter"
10-
"github.com/evcc-io/evcc/provider"
10+
"github.com/evcc-io/evcc/plugin"
1111
"github.com/evcc-io/evcc/util"
1212
)
1313

@@ -30,40 +30,40 @@ func init() {
3030
func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}) (api.Charger, error) {
3131
var cc struct {
3232
embed `mapstructure:",squash"`
33-
Status, Enable, Enabled, MaxCurrent provider.Config
34-
MaxCurrentMillis *provider.Config
35-
Identify, Phases1p3p *provider.Config
36-
Wakeup *provider.Config
37-
Soc *provider.Config
33+
Status, Enable, Enabled, MaxCurrent plugin.Config
34+
MaxCurrentMillis *plugin.Config
35+
Identify, Phases1p3p *plugin.Config
36+
Wakeup *plugin.Config
37+
Soc *plugin.Config
3838
Tos bool
3939

4040
// optional measurements
41-
Power *provider.Config
42-
Energy *provider.Config
41+
Power *plugin.Config
42+
Energy *plugin.Config
4343

44-
Currents, Voltages []provider.Config
44+
Currents, Voltages []plugin.Config
4545
}
4646

4747
if err := util.DecodeOther(other, &cc); err != nil {
4848
return nil, err
4949
}
5050

51-
status, err := provider.NewStringGetterFromConfig(ctx, cc.Status)
51+
status, err := cc.Status.StringGetter(ctx)
5252
if err != nil {
5353
return nil, fmt.Errorf("status: %w", err)
5454
}
5555

56-
enabled, err := provider.NewBoolGetterFromConfig(ctx, cc.Enabled)
56+
enabled, err := cc.Enabled.BoolGetter(ctx)
5757
if err != nil {
5858
return nil, fmt.Errorf("enabled: %w", err)
5959
}
6060

61-
enable, err := provider.NewBoolSetterFromConfig(ctx, "enable", cc.Enable)
61+
enable, err := cc.Enable.BoolSetter(ctx, "enable")
6262
if err != nil {
6363
return nil, fmt.Errorf("enable: %w", err)
6464
}
6565

66-
maxcurrent, err := provider.NewIntSetterFromConfig(ctx, "maxcurrent", cc.MaxCurrent)
66+
maxcurrent, err := cc.MaxCurrent.IntSetter(ctx, "maxcurrent")
6767
if err != nil {
6868
return nil, fmt.Errorf("maxcurrent: %w", err)
6969
}
@@ -75,12 +75,9 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
7575

7676
c.embed = &cc.embed
7777

78-
var maxcurrentmillis func(float64) error
79-
if cc.MaxCurrentMillis != nil {
80-
maxcurrentmillis, err = provider.NewFloatSetterFromConfig(ctx, "maxcurrentmillis", *cc.MaxCurrentMillis)
81-
if err != nil {
82-
return nil, fmt.Errorf("maxcurrentmillis: %w", err)
83-
}
78+
maxcurrentmillis, err := cc.MaxCurrentMillis.FloatSetter(ctx, "maxcurrentmillis")
79+
if err != nil {
80+
return nil, fmt.Errorf("maxcurrentmillis: %w", err)
8481
}
8582

8683
// decorate phases
@@ -90,7 +87,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
9087
return nil, errors.New("1p3p does no longer handle disable/enable. Use tos: true to confirm you understand the consequences")
9188
}
9289

93-
phases1p3pS, err := provider.NewIntSetterFromConfig(ctx, "phases", *cc.Phases1p3p)
90+
phases1p3pS, err := cc.Phases1p3p.IntSetter(ctx, "phases")
9491
if err != nil {
9592
return nil, fmt.Errorf("phases: %w", err)
9693
}
@@ -101,34 +98,28 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
10198
}
10299

103100
// decorate identifier
104-
var identify func() (string, error)
105-
if cc.Identify != nil {
106-
identify, err = provider.NewStringGetterFromConfig(ctx, *cc.Identify)
107-
if err != nil {
108-
return nil, fmt.Errorf("identify: %w", err)
109-
}
101+
identify, err := cc.Identify.StringGetter(ctx)
102+
if err != nil {
103+
return nil, fmt.Errorf("identify: %w", err)
110104
}
111105

112106
// decorate wakeup
113107
var wakeup func() error
114108
if cc.Wakeup != nil {
115-
wakeupS, err := provider.NewBoolSetterFromConfig(ctx, "wakeup", *cc.Wakeup)
109+
set, err := cc.Wakeup.BoolSetter(ctx, "wakeup")
116110
if err != nil {
117111
return nil, fmt.Errorf("wakeup: %w", err)
118112
}
119113

120114
wakeup = func() error {
121-
return wakeupS(true)
115+
return set(true)
122116
}
123117
}
124118

125119
// decorate soc
126-
var soc func() (float64, error)
127-
if cc.Soc != nil {
128-
soc, err = provider.NewFloatGetterFromConfig(ctx, *cc.Soc)
129-
if err != nil {
130-
return nil, fmt.Errorf("soc: %w", err)
131-
}
120+
soc, err := cc.Soc.FloatGetter(ctx)
121+
if err != nil {
122+
return nil, fmt.Errorf("soc: %w", err)
132123
}
133124

134125
// decorate measurements

charger/connectiq.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/evcc-io/evcc/api"
2727
"github.com/evcc-io/evcc/charger/connectiq"
28-
"github.com/evcc-io/evcc/provider"
2928
"github.com/evcc-io/evcc/util"
3029
"github.com/evcc-io/evcc/util/request"
3130
)
@@ -71,7 +70,7 @@ func NewConnectIq(uri string, cache time.Duration) (api.Charger, error) {
7170
}
7271

7372
// cache meter readings
74-
wb.meterG = provider.Cached(func() (connectiq.MeterStatus, error) {
73+
wb.meterG = util.Cached(func() (connectiq.MeterStatus, error) {
7574
var res connectiq.MeterStatus
7675
uri := fmt.Sprintf("%s/meter/status", wb.uri)
7776
err := wb.GetJSON(uri, &res)

charger/daheimladen.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/evcc-io/evcc/api"
1010
"github.com/evcc-io/evcc/charger/daheimladen"
11-
"github.com/evcc-io/evcc/provider"
1211
"github.com/evcc-io/evcc/util"
1312
"github.com/evcc-io/evcc/util/request"
1413
"golang.org/x/oauth2"
@@ -22,8 +21,8 @@ type DaheimLaden struct {
2221
idTag string
2322
token string
2423
transactionID int32
25-
statusG provider.Cacheable[daheimladen.GetLatestStatus]
26-
meterG provider.Cacheable[daheimladen.GetLatestMeterValueResponse]
24+
statusG util.Cacheable[daheimladen.GetLatestStatus]
25+
meterG util.Cacheable[daheimladen.GetLatestMeterValueResponse]
2726
cache time.Duration
2827
}
2928

@@ -67,13 +66,13 @@ func NewDaheimLaden(token, stationID string, cache time.Duration) (*DaheimLaden,
6766
Base: c.Client.Transport,
6867
}
6968

70-
c.statusG = provider.ResettableCached(func() (daheimladen.GetLatestStatus, error) {
69+
c.statusG = util.ResettableCached(func() (daheimladen.GetLatestStatus, error) {
7170
var res daheimladen.GetLatestStatus
7271
err := c.GetJSON(fmt.Sprintf("%s/cs/%s/status", daheimladen.BASE_URL, c.stationID), &res)
7372
return res, err
7473
}, c.cache)
7574

76-
c.meterG = provider.ResettableCached(func() (daheimladen.GetLatestMeterValueResponse, error) {
75+
c.meterG = util.ResettableCached(func() (daheimladen.GetLatestMeterValueResponse, error) {
7776
var res daheimladen.GetLatestMeterValueResponse
7877
err := c.GetJSON(fmt.Sprintf("%s/cs/%s/metervalue", daheimladen.BASE_URL, c.stationID), &res)
7978
return res, err

charger/eebus.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/enbility/spine-go/model"
1616
"github.com/evcc-io/evcc/api"
1717
"github.com/evcc-io/evcc/core/loadpoint"
18-
"github.com/evcc-io/evcc/provider"
1918
"github.com/evcc-io/evcc/server/eebus"
2019
"github.com/evcc-io/evcc/util"
2120
"github.com/samber/lo"
@@ -88,7 +87,7 @@ func NewEEBus(ski, ip string, hasMeter, hasChargedEnergy, vasVW bool) (api.Charg
8887
}
8988

9089
c.Connector = eebus.NewConnector()
91-
c.minMaxG = provider.Cached(c.minMax, time.Second)
90+
c.minMaxG = util.Cached(c.minMax, time.Second)
9291

9392
if err := eebus.Instance.RegisterDevice(ski, ip, c); err != nil {
9493
return nil, err

charger/evsewifi.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/evcc-io/evcc/api"
1010
"github.com/evcc-io/evcc/charger/evse"
11-
"github.com/evcc-io/evcc/provider"
1211
"github.com/evcc-io/evcc/util"
1312
"github.com/evcc-io/evcc/util/request"
1413
)
@@ -20,7 +19,7 @@ type EVSEWifi struct {
2019
alwaysActive bool
2120
current int64 // current will always be the physical value sent to the API
2221
hires bool
23-
paramG provider.Cacheable[evse.ListEntry]
22+
paramG util.Cacheable[evse.ListEntry]
2423
}
2524

2625
func init() {
@@ -122,7 +121,7 @@ func NewEVSEWifi(uri string, cache time.Duration) (*EVSEWifi, error) {
122121
current: 6, // 6A defined value
123122
}
124123

125-
wb.paramG = provider.ResettableCached(func() (evse.ListEntry, error) {
124+
wb.paramG = util.ResettableCached(func() (evse.ListEntry, error) {
126125
var res evse.ParameterResponse
127126
uri := fmt.Sprintf("%s/getParameters", wb.uri)
128127
if err := wb.GetJSON(uri, &res); err != nil {

charger/hardybarth-ecb1.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/evcc-io/evcc/charger/echarge"
3131
"github.com/evcc-io/evcc/charger/echarge/ecb1"
3232
"github.com/evcc-io/evcc/meter/obis"
33-
"github.com/evcc-io/evcc/provider"
3433
"github.com/evcc-io/evcc/util"
3534
"github.com/evcc-io/evcc/util/request"
3635
"github.com/evcc-io/evcc/util/sponsor"
@@ -85,7 +84,7 @@ func NewHardyBarth(uri string, chargecontrol, meter int, cache time.Duration) (a
8584
}
8685

8786
// cache meter readings
88-
wb.meterG = provider.Cached(func() (ecb1.Meter, error) {
87+
wb.meterG = util.Cached(func() (ecb1.Meter, error) {
8988
var res struct {
9089
Meter struct {
9190
ecb1.Meter

charger/hardybarth-salia.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/evcc-io/evcc/api"
3131
"github.com/evcc-io/evcc/charger/echarge"
3232
"github.com/evcc-io/evcc/charger/echarge/salia"
33-
"github.com/evcc-io/evcc/provider"
3433
"github.com/evcc-io/evcc/util"
3534
"github.com/evcc-io/evcc/util/request"
3635
"github.com/evcc-io/evcc/util/sponsor"
@@ -46,7 +45,7 @@ type Salia struct {
4645
uri string
4746
current int64
4847
fw int // 2 if fw 2.0
49-
apiG provider.Cacheable[salia.Api]
48+
apiG util.Cacheable[salia.Api]
5049
}
5150

5251
func init() {
@@ -84,7 +83,7 @@ func NewSalia(ctx context.Context, uri string, cache time.Duration) (api.Charger
8483
current: 6,
8584
}
8685

87-
wb.apiG = provider.ResettableCached(func() (salia.Api, error) {
86+
wb.apiG = util.ResettableCached(func() (salia.Api, error) {
8887
var res salia.Api
8988
err := wb.GetJSON(wb.uri, &res)
9089
return res, err

charger/mystrom.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/evcc-io/evcc/api"
88
"github.com/evcc-io/evcc/meter/mystrom"
9-
"github.com/evcc-io/evcc/provider"
109
"github.com/evcc-io/evcc/util"
1110
)
1211

@@ -21,7 +20,7 @@ func init() {
2120
type MyStrom struct {
2221
*switchSocket
2322
conn *mystrom.Connection
24-
reportG provider.Cacheable[mystrom.Report]
23+
reportG util.Cacheable[mystrom.Report]
2524
}
2625

2726
// NewMyStromFromConfig creates a myStrom charger from generic config
@@ -44,7 +43,7 @@ func NewMyStromFromConfig(other map[string]interface{}) (api.Charger, error) {
4443
}
4544

4645
c.switchSocket = NewSwitchSocket(&cc.embed, c.Enabled, c.conn.CurrentPower, cc.StandbyPower)
47-
c.reportG = provider.ResettableCached(c.conn.Report, cc.Cache)
46+
c.reportG = util.ResettableCached(c.conn.Report, cc.Cache)
4847

4948
return c, nil
5049
}

charger/nrgconnect.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/evcc-io/evcc/api"
1111
"github.com/evcc-io/evcc/charger/nrg/connect"
12-
"github.com/evcc-io/evcc/provider"
1312
"github.com/evcc-io/evcc/util"
1413
"github.com/evcc-io/evcc/util/request"
1514
)
@@ -23,8 +22,8 @@ type NRGKickConnect struct {
2322
mac string
2423
password string
2524
enabled bool
26-
settingsG provider.Cacheable[connect.Settings]
27-
measurementsG provider.Cacheable[connect.Measurements]
25+
settingsG util.Cacheable[connect.Settings]
26+
measurementsG util.Cacheable[connect.Measurements]
2827
}
2928

3029
func init() {
@@ -56,7 +55,7 @@ func NewNRGKickConnect(uri, mac, password string, cache time.Duration) (*NRGKick
5655
password: password,
5756
}
5857

59-
nrg.settingsG = provider.ResettableCached(func() (connect.Settings, error) {
58+
nrg.settingsG = util.ResettableCached(func() (connect.Settings, error) {
6059
var res connect.Settings
6160

6261
err := nrg.GetJSON(nrg.apiURL(connect.SettingsPath), &res)
@@ -67,7 +66,7 @@ func NewNRGKickConnect(uri, mac, password string, cache time.Duration) (*NRGKick
6766
return res, err
6867
}, cache)
6968

70-
nrg.measurementsG = provider.ResettableCached(func() (connect.Measurements, error) {
69+
nrg.measurementsG = util.ResettableCached(func() (connect.Measurements, error) {
7170
var res connect.Measurements
7271

7372
err := nrg.GetJSON(nrg.apiURL(connect.MeasurementsPath), &res)

charger/openevse.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/evcc-io/evcc/api"
1212
"github.com/evcc-io/evcc/charger/openevse"
13-
"github.com/evcc-io/evcc/provider"
1413
"github.com/evcc-io/evcc/util"
1514
"github.com/evcc-io/evcc/util/request"
1615
"github.com/evcc-io/evcc/util/transport"
@@ -20,7 +19,7 @@ import (
2019
type OpenEVSE struct {
2120
*request.Helper
2221
uri string
23-
statusG provider.Cacheable[openevse.Status]
22+
statusG util.Cacheable[openevse.Status]
2423
current int
2524
enabled bool
2625
}
@@ -67,7 +66,7 @@ func NewOpenEVSE(uri, user, password string, cache time.Duration) (api.Charger,
6766
c.Client.Transport = transport.BasicAuth(user, password, c.Client.Transport)
6867
}
6968

70-
c.statusG = provider.ResettableCached(func() (openevse.Status, error) {
69+
c.statusG = util.ResettableCached(func() (openevse.Status, error) {
7170
var res openevse.Status
7271

7372
uri := fmt.Sprintf("%s/status", c.uri)

0 commit comments

Comments
 (0)