7
7
8
8
"github.com/evcc-io/evcc/api"
9
9
"github.com/evcc-io/evcc/meter"
10
- "github.com/evcc-io/evcc/provider "
10
+ "github.com/evcc-io/evcc/plugin "
11
11
"github.com/evcc-io/evcc/util"
12
12
)
13
13
@@ -30,40 +30,40 @@ func init() {
30
30
func NewConfigurableFromConfig (ctx context.Context , other map [string ]interface {}) (api.Charger , error ) {
31
31
var cc struct {
32
32
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
38
38
Tos bool
39
39
40
40
// optional measurements
41
- Power * provider .Config
42
- Energy * provider .Config
41
+ Power * plugin .Config
42
+ Energy * plugin .Config
43
43
44
- Currents , Voltages []provider .Config
44
+ Currents , Voltages []plugin .Config
45
45
}
46
46
47
47
if err := util .DecodeOther (other , & cc ); err != nil {
48
48
return nil , err
49
49
}
50
50
51
- status , err := provider . NewStringGetterFromConfig ( ctx , cc .Status )
51
+ status , err := cc .Status . StringGetter ( ctx )
52
52
if err != nil {
53
53
return nil , fmt .Errorf ("status: %w" , err )
54
54
}
55
55
56
- enabled , err := provider . NewBoolGetterFromConfig ( ctx , cc .Enabled )
56
+ enabled , err := cc .Enabled . BoolGetter ( ctx )
57
57
if err != nil {
58
58
return nil , fmt .Errorf ("enabled: %w" , err )
59
59
}
60
60
61
- enable , err := provider . NewBoolSetterFromConfig (ctx , "enable" , cc . Enable )
61
+ enable , err := cc . Enable . BoolSetter (ctx , "enable" )
62
62
if err != nil {
63
63
return nil , fmt .Errorf ("enable: %w" , err )
64
64
}
65
65
66
- maxcurrent , err := provider . NewIntSetterFromConfig (ctx , "maxcurrent" , cc . MaxCurrent )
66
+ maxcurrent , err := cc . MaxCurrent . IntSetter (ctx , "maxcurrent" )
67
67
if err != nil {
68
68
return nil , fmt .Errorf ("maxcurrent: %w" , err )
69
69
}
@@ -75,12 +75,9 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
75
75
76
76
c .embed = & cc .embed
77
77
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 )
84
81
}
85
82
86
83
// decorate phases
@@ -90,7 +87,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
90
87
return nil , errors .New ("1p3p does no longer handle disable/enable. Use tos: true to confirm you understand the consequences" )
91
88
}
92
89
93
- phases1p3pS , err := provider . NewIntSetterFromConfig (ctx , "phases" , * cc . Phases1p3p )
90
+ phases1p3pS , err := cc . Phases1p3p . IntSetter (ctx , "phases" )
94
91
if err != nil {
95
92
return nil , fmt .Errorf ("phases: %w" , err )
96
93
}
@@ -101,34 +98,28 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
101
98
}
102
99
103
100
// 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 )
110
104
}
111
105
112
106
// decorate wakeup
113
107
var wakeup func () error
114
108
if cc .Wakeup != nil {
115
- wakeupS , err := provider . NewBoolSetterFromConfig (ctx , "wakeup" , * cc . Wakeup )
109
+ set , err := cc . Wakeup . BoolSetter (ctx , "wakeup" )
116
110
if err != nil {
117
111
return nil , fmt .Errorf ("wakeup: %w" , err )
118
112
}
119
113
120
114
wakeup = func () error {
121
- return wakeupS (true )
115
+ return set (true )
122
116
}
123
117
}
124
118
125
119
// 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 )
132
123
}
133
124
134
125
// decorate measurements
0 commit comments