Hardybarth Salia: add optional user/password (#24161)

This commit is contained in:
Thomas Speer 2025-10-07 08:33:51 +02:00 • committed by GitHub
parent 62475c5661
commit 55a1efd695
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 5 deletions

View file

@ -33,6 +33,7 @@ import (
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
"github.com/evcc-io/evcc/util/sponsor"
"github.com/evcc-io/evcc/util/transport"
"github.com/hashicorp/go-version"
)
@ -57,8 +58,10 @@ func init() {
// NewSaliaFromConfig creates a Salia cPH2 charger from generic config
func NewSaliaFromConfig(ctx context.Context, other map[string]interface{}) (api.Charger, error) {
cc := struct {
URI string
Cache time.Duration
URI string
User string
Password string
Cache time.Duration
}{
Cache: time.Second,
}
@ -67,12 +70,13 @@ func NewSaliaFromConfig(ctx context.Context, other map[string]interface{}) (api.
return nil, err
}
return NewSalia(ctx, cc.URI, cc.Cache)
return NewSalia(ctx, cc.URI, cc.User, cc.Password, cc.Cache)
}
// NewSalia creates Hardy Barth charger with Salia controller
func NewSalia(ctx context.Context, uri string, cache time.Duration) (api.Charger, error) {
log := util.NewLogger("salia")
func NewSalia(ctx context.Context, uri, user, password string, cache time.Duration) (api.Charger, error) {
basicAuth := transport.BasicAuthHeader(user, password)
log := util.NewLogger("salia").Redact(user, password, basicAuth)
uri = strings.TrimSuffix(uri, "/") + "/api"
@ -83,6 +87,10 @@ func NewSalia(ctx context.Context, uri string, cache time.Duration) (api.Charger
current: 6,
}
if user != "" && password != "" {
wb.Client.Transport = transport.BasicAuth(user, password, wb.Client.Transport)
}
wb.apiG = util.ResettableCached(func() (salia.Api, error) {
var res salia.Api
err := wb.GetJSON(wb.uri, &res)

View file

@ -14,8 +14,27 @@ products:
generic: cPμ2
requirements:
evcc: ["sponsorship"]
description:
de: >-
Wenn du ohne Benutzername und Passwort die Meldung '401 (Unauthorized)' bekommst,
benutze die Benutzernamen und Passwort Kombination, die du vom Installateur deiner Wallbox bekommen hast,
die auch für die Weboberfläche der Wallbox funktioniert.
en: >-
If you get the message '401 (Unauthorized)' without a username and password,
use the username and password that you received from the installer of your wallbox.
The combo that also works for the web interface of the wallbox.
params:
- name: host
- name: user
help:
de: Benutzername (optional, nur bei aktivierter Basic Auth der Wallbox)
en: Username (optional, only if Basic Auth is enabled on the wallbox)
- name: password
help:
de: Passwort (optional, nur bei aktivierter Basic Auth der Wallbox)
en: Password (optional, only if Basic Auth is enabled on the wallbox)
render: |
type: hardybarth-salia
uri: http://{{ .host }}
user: {{ .user }}
password: {{ .password }}