SMA EV Charger: align uri configuration with other implementations (#3680)
This commit is contained in:
parent
06b20b8f3b
commit
57c6e07f0f
3 changed files with 19 additions and 17 deletions
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/evcc-io/evcc/provider"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/util/sponsor"
|
||||
"github.com/hashicorp/go-version"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
|
@ -51,7 +52,7 @@ func init() {
|
|||
// NewSmaevchargerFromConfig creates a SMA EV Charger from generic config
|
||||
func NewSmaevchargerFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
cc := struct {
|
||||
Host string
|
||||
Uri string
|
||||
User string
|
||||
Password string
|
||||
Cache time.Duration
|
||||
|
|
@ -63,8 +64,8 @@ func NewSmaevchargerFromConfig(other map[string]interface{}) (api.Charger, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if cc.Host == "" {
|
||||
return nil, errors.New("missing host")
|
||||
if cc.Uri == "" {
|
||||
return nil, errors.New("missing uri")
|
||||
}
|
||||
|
||||
if cc.User == "" || cc.Password == "" {
|
||||
|
|
@ -72,25 +73,27 @@ func NewSmaevchargerFromConfig(other map[string]interface{}) (api.Charger, error
|
|||
}
|
||||
|
||||
if cc.User == "admin" {
|
||||
return nil, errors.New("user admin not allowed, create new user")
|
||||
return nil, errors.New(`user "admin" not allowed, create new user`)
|
||||
}
|
||||
|
||||
return NewSmaevcharger(cc.Host, cc.User, cc.Password, cc.Cache)
|
||||
return NewSmaevcharger(cc.Uri, cc.User, cc.Password, cc.Cache)
|
||||
}
|
||||
|
||||
// NewSmaevcharger creates an SMA EV Charger
|
||||
func NewSmaevcharger(host string, user string, password string, cache time.Duration) (api.Charger, error) {
|
||||
func NewSmaevcharger(uri string, user string, password string, cache time.Duration) (api.Charger, error) {
|
||||
log := util.NewLogger("smaevcharger").Redact(user, password)
|
||||
|
||||
baseUri := "http://" + host
|
||||
|
||||
wb := &Smaevcharger{
|
||||
Helper: request.NewHelper(log),
|
||||
log: log,
|
||||
uri: baseUri + "/api/v1",
|
||||
uri: util.DefaultScheme(strings.TrimRight(uri, "/"), "http") + "/api/v1",
|
||||
cache: cache,
|
||||
}
|
||||
|
||||
if !sponsor.IsAuthorized() {
|
||||
return nil, api.ErrSponsorRequired
|
||||
}
|
||||
|
||||
// setup cached values
|
||||
wb.reset()
|
||||
|
||||
|
|
@ -119,9 +122,10 @@ func NewSmaevcharger(host string, user string, password string, cache time.Durat
|
|||
}
|
||||
|
||||
if err == nil {
|
||||
// Prepare Charger for EVCC Control:
|
||||
// - disable App Lock functionality, this Option have been introduced with 1.2.23 and will lock the Charger until unlocked via SMA App
|
||||
// unfortunately this Lock option will overwrite the status of the charger and prevent ev detection
|
||||
// Prepare charger: disable App Lock functionality.
|
||||
// This option have been introduced with 1.2.23 and will lock the charger
|
||||
// until unlocked via SMA App. Unfortunately this Lock option will overwrite
|
||||
// the status of the charger and prevent ev detection
|
||||
err = wb.Send(
|
||||
value("Parameter.Chrg.ChrgLok", smaevcharger.ChargerAppLockDisabled),
|
||||
value("Parameter.Chrg.ChrgApv", smaevcharger.ChargerManualLockEnabled),
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ products:
|
|||
capabilities: ["mA"]
|
||||
requirements:
|
||||
description:
|
||||
de: Die Wallbox muss sich im Modus "Fast" befinden.
|
||||
de: Der EV Charger muss sich im Modus "Fast" befinden.
|
||||
en: The charger must be switched to "Fast" charging mode.
|
||||
params:
|
||||
- name: title
|
||||
- name: host
|
||||
required: true
|
||||
- name: user
|
||||
|
|
@ -19,6 +18,6 @@ params:
|
|||
mask: true
|
||||
render: |
|
||||
type: smaevcharger
|
||||
host: {{ .host }}
|
||||
uri: http://{{ .host }}
|
||||
user: {{ .user }}
|
||||
password: {{ .password }}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ product:
|
|||
description: EV Charger
|
||||
capabilities: ["mA"]
|
||||
description: |
|
||||
Die Wallbox muss sich im Modus "Fast" befinden.
|
||||
Der EV Charger muss sich im Modus "Fast" befinden.
|
||||
render:
|
||||
- default: |
|
||||
type: template
|
||||
template: smaevcharger
|
||||
title: # Wird in der Benutzeroberfläche angezeigt # Optional
|
||||
host: 192.0.2.2 # IP-Adresse oder Hostname
|
||||
user: # Benutzerkonto (bspw. E-Mail Adresse, User Id, etc.)
|
||||
password: # Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue