From d7082ee95429a71ba66ea49efa0ccee8126732ec Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 2 Aug 2020 21:21:53 +0200 Subject: [PATCH] Update NRG Connect attributes --- charger/nrgconnect.go | 24 ++++++++++++------------ evcc.dist.yaml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/charger/nrgconnect.go b/charger/nrgconnect.go index 3114c4894..1f6320d59 100644 --- a/charger/nrgconnect.go +++ b/charger/nrgconnect.go @@ -64,29 +64,29 @@ type NRGDeviceMetadata struct { // NRGKickConnect charger implementation type NRGKickConnect struct { *util.HTTPHelper - IP string - MacAddress string - Password string + uri string + mac string + password string } // NewNRGKickConnectFromConfig creates a NRGKickConnect charger from generic config func NewNRGKickConnectFromConfig(other map[string]interface{}) (api.Charger, error) { - cc := struct{ IP, MacAddress, Password string }{} + cc := struct{ URI, Mac, Password string }{} if err := util.DecodeOther(other, &cc); err != nil { return nil, err } - return NewNRGKickConnect(cc.IP, cc.MacAddress, cc.Password) + return NewNRGKickConnect(cc.URI, cc.Mac, cc.Password) } // NewNRGKickConnect creates NRGKickConnect charger -func NewNRGKickConnect(IP, MacAddress, Password string) (*NRGKickConnect, error) { +func NewNRGKickConnect(uri, mac, password string) (*NRGKickConnect, error) { log := util.NewLogger("nrgconn") nrg := &NRGKickConnect{ HTTPHelper: util.NewHTTPHelper(log), - IP: IP, - MacAddress: MacAddress, - Password: Password, + uri: uri, + mac: mac, + password: password, } nrg.HTTPHelper.Log.WARN.Println("-- experimental --") @@ -95,7 +95,7 @@ func NewNRGKickConnect(IP, MacAddress, Password string) (*NRGKickConnect, error) } func (nrg *NRGKickConnect) apiURL(api apiFunction) string { - return fmt.Sprintf("%s/api/%s/%s", nrg.IP, api, nrg.MacAddress) + return fmt.Sprintf("%s/api/%s/%s", nrg.uri, api, nrg.mac) } func (nrg *NRGKickConnect) getJSON(url string, result interface{}) error { @@ -142,7 +142,7 @@ func (nrg *NRGKickConnect) Enabled() (bool, error) { // Enable implements the Charger.Enable interface func (nrg *NRGKickConnect) Enable(enable bool) error { settings := NRGSettings{} - settings.Values.DeviceMetadata.Password = nrg.Password + settings.Values.DeviceMetadata.Password = nrg.password settings.Values.ChargingStatus.Charging = &enable return nrg.putJSON(nrg.apiURL(apiSettings), settings) @@ -151,7 +151,7 @@ func (nrg *NRGKickConnect) Enable(enable bool) error { // MaxCurrent implements the Charger.MaxCurrent interface func (nrg *NRGKickConnect) MaxCurrent(current int64) error { settings := NRGSettings{} - settings.Values.DeviceMetadata.Password = nrg.Password + settings.Values.DeviceMetadata.Password = nrg.password settings.Values.ChargingCurrent.Value = float64(current) return nrg.putJSON(nrg.apiURL(apiSettings), settings) diff --git a/evcc.dist.yaml b/evcc.dist.yaml index 67ed3d59d..c05667083 100644 --- a/evcc.dist.yaml +++ b/evcc.dist.yaml @@ -124,8 +124,8 @@ chargers: uri: http://192.168.1.4 # SimpleEVSE-Wifi address - name: nrg-1 type: nrgkick-connect # NRGKick Connect charger - ip: 192.168.1.4 # IP - macaddress: 00:99:22 # MAC address + uri: http://192.168.1.4 # uri + mac: 00:99:22 # MAC address password: # password # - name: nrg-2 # type: nrgkick-bluetooth # NRGKick charger with Bluetooth diff --git a/go.mod b/go.mod index 468e85dff..75a007f20 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/andig/evcc go 1.13 require ( - github.com/andig/evcc-config v0.0.0-20200729105416-7fbb6e0605cc + github.com/andig/evcc-config v0.0.0-20200802191931-3e618540d36b github.com/asaskevich/EventBus v0.0.0-20200428142821-4fc0642a29f3 github.com/avast/retry-go v2.6.0+incompatible github.com/benbjohnson/clock v1.0.3 diff --git a/go.sum b/go.sum index e6dbb8dae..a4d0fd840 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alvaroloes/enumer v1.1.2 h1:5khqHB33TZy1GWCO/lZwcroBFh7u+0j40T83VUbfAMY= github.com/alvaroloes/enumer v1.1.2/go.mod h1:FxrjvuXoDAx9isTJrv4c+T410zFi0DtXIT0m65DJ+Wo= github.com/andig/evcc v0.0.0-20200727161511-d58eb15f2dc9/go.mod h1:8HONEC6cC2s4k0u3QL7GIjrYOZYTOKiiXybw0FIJL0A= -github.com/andig/evcc-config v0.0.0-20200729105416-7fbb6e0605cc h1:G+Zpx2yBwqGVZPrUMm8CXpb9sOavQlH9d1CS++cV4SY= -github.com/andig/evcc-config v0.0.0-20200729105416-7fbb6e0605cc/go.mod h1:N0hIjIy+5E2AR1fF7Tg2IzBlblBrnFvCCaDGAaHzbWk= +github.com/andig/evcc-config v0.0.0-20200802191931-3e618540d36b h1:IZQ3ilzJKqNTjWuGRZEhoE9HZaFRS9cRPEyuxHn5Rqc= +github.com/andig/evcc-config v0.0.0-20200802191931-3e618540d36b/go.mod h1:N0hIjIy+5E2AR1fF7Tg2IzBlblBrnFvCCaDGAaHzbWk= github.com/andig/gosunspec v0.0.0-20200429133549-3cf6a82fed9c h1:AMtX56iHlNYVxMID7fe9efuVtaxgtdjyMeolg7q87IE= github.com/andig/gosunspec v0.0.0-20200429133549-3cf6a82fed9c/go.mod h1:YkshK8WMzYn1iXAZzHUO75gIqhMSan2ctgBVtBkRIyA= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=