@@ -71,26 +71,13 @@ const (
71
71
func init () {
72
72
registry .AddCtx ("em2go" , NewEm2GoFromConfig )
73
73
registry .AddCtx ("em2go-home" , NewEm2GoFromConfig )
74
- registry .AddCtx ("em2go-duo-power " , NewEm2GoDuoPowerFromConfig )
74
+ registry .AddCtx ("em2go-duo" , NewEm2GoFromConfig )
75
75
}
76
76
77
77
//go:generate go tool decorate -f decorateEm2Go -b *Em2Go -r api.Charger -t "api.ChargerEx,MaxCurrentMillis,func(float64) error" -t "api.PhaseSwitcher,Phases1p3p,func(int) error" -t "api.PhaseGetter,GetPhases,func() (int, error)"
78
78
79
79
// NewEm2GoFromConfig creates a Em2Go charger from generic config
80
80
func NewEm2GoFromConfig (ctx context.Context , other map [string ]interface {}) (api.Charger , error ) {
81
- cc := modbus.TcpSettings {
82
- ID : 255 ,
83
- }
84
-
85
- if err := util .DecodeOther (other , & cc ); err != nil {
86
- return nil , err
87
- }
88
-
89
- return NewEm2Go (ctx , cc .URI , cc .ID )
90
- }
91
-
92
- // NewEm2GoDuoPowerFromConfig creates a Em2Go Duo Power charger from generic config
93
- func NewEm2GoDuoPowerFromConfig (ctx context.Context , other map [string ]interface {}) (api.Charger , error ) {
94
81
cc := struct {
95
82
modbus.TcpSettings `mapstructure:",squash"`
96
83
Connector int
@@ -103,11 +90,11 @@ func NewEm2GoDuoPowerFromConfig(ctx context.Context, other map[string]interface{
103
90
return nil , err
104
91
}
105
92
106
- return NewEm2GoDuoPower (ctx , cc .URI , cc .ID , cc .Connector )
93
+ return NewEm2Go (ctx , cc .URI , cc .ID , cc .Connector )
107
94
}
108
95
109
96
// NewEm2Go creates Em2Go charger
110
- func NewEm2Go (ctx context.Context , uri string , slaveID uint8 ) (api.Charger , error ) {
97
+ func NewEm2Go (ctx context.Context , uri string , slaveID uint8 , connector int ) (api.Charger , error ) {
111
98
uri = util .DefaultPort (uri , 502 )
112
99
113
100
conn , err := modbus .NewConnection (ctx , uri , "" , "" , 0 , modbus .Tcp , slaveID )
@@ -122,41 +109,10 @@ func NewEm2Go(ctx context.Context, uri string, slaveID uint8) (api.Charger, erro
122
109
conn .Logger (log .TRACE )
123
110
124
111
wb := & Em2Go {
125
- log : log ,
126
- conn : conn ,
127
- current : 60 ,
128
- workaround : false ,
129
- base : 0 , // single connector, no offset
130
- }
131
-
132
- return wb .initialize ()
133
- }
134
-
135
- // NewEm2GoDuoPower creates Em2Go Duo Power charger
136
- func NewEm2GoDuoPower (ctx context.Context , uri string , slaveID uint8 , connector int ) (api.Charger , error ) {
137
- if connector < 1 || connector > 2 {
138
- return nil , fmt .Errorf ("invalid connector: %d" , connector )
139
- }
140
-
141
- uri = util .DefaultPort (uri , 502 )
142
-
143
- conn , err := modbus .NewConnection (ctx , uri , "" , "" , 0 , modbus .Tcp , slaveID )
144
- if err != nil {
145
- return nil , err
146
- }
147
-
148
- // Add delay of 60 milliseconds between requests
149
- conn .Delay (60 * time .Millisecond )
150
-
151
- log := util .NewLogger ("em2go-duo-power" )
152
- conn .Logger (log .TRACE )
153
-
154
- wb := & Em2Go {
155
- log : log ,
156
- conn : conn ,
157
- current : 60 ,
158
- workaround : false ,
159
- base : uint16 ((connector - 1 ) * em2GoDuoPowerOffset ),
112
+ log : log ,
113
+ conn : conn ,
114
+ current : 60 ,
115
+ base : uint16 ((connector - 1 ) * em2GoDuoPowerOffset ),
160
116
}
161
117
162
118
return wb .initialize ()
0 commit comments