Update NRG Connect attributes

This commit is contained in:
andig 2020-08-02 21:21:53 +02:00
parent 569e1e8938
commit d7082ee954
4 changed files with 17 additions and 17 deletions

View file

@ -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)

View file

@ -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

2
go.mod
View file

@ -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

4
go.sum
View file

@ -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=