HardyBarth cPH2: update api and require sponsorship (#3197)
This commit is contained in:
parent
3bf708f9e8
commit
80c7aac21a
6 changed files with 22 additions and 12 deletions
|
|
@ -3,6 +3,7 @@ package salia
|
|||
const (
|
||||
HeartBeat = "salia/heartbeat"
|
||||
ChargeMode = "salia/chargemode"
|
||||
PauseCharging = "salia/pausecharging"
|
||||
GridCurrentLimit = "grid_current_limit"
|
||||
)
|
||||
|
||||
|
|
@ -32,7 +33,8 @@ type Port struct {
|
|||
}
|
||||
}
|
||||
Salia struct {
|
||||
ChargeMode string
|
||||
ChargeMode string
|
||||
PauseCharging int `json:"pausecharging,string"`
|
||||
}
|
||||
Metering struct {
|
||||
Meter struct {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/evcc-io/evcc/charger/echarge/salia"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/util/sponsor"
|
||||
)
|
||||
|
||||
// http://apidoc.ecb1.de
|
||||
|
|
@ -51,7 +52,7 @@ func init() {
|
|||
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateSalia -b *Salia -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.MeterCurrent,Currents,func() (float64, float64, float64, error)"
|
||||
|
||||
// NewSaliaFromConfig creates a Salia cPH1 charger from generic config
|
||||
// NewSaliaFromConfig creates a Salia cPH2 charger from generic config
|
||||
func NewSaliaFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
cc := struct {
|
||||
URI string
|
||||
|
|
@ -84,9 +85,9 @@ func NewSalia(uri string, cache time.Duration) (api.Charger, error) {
|
|||
cache: cache,
|
||||
}
|
||||
|
||||
// if !sponsor.IsAuthorized() {
|
||||
// return nil, api.ErrSponsorRequired
|
||||
// }
|
||||
if !sponsor.IsAuthorized() {
|
||||
return nil, api.ErrSponsorRequired
|
||||
}
|
||||
|
||||
err := wb.post(salia.ChargeMode, echarge.ModeManual)
|
||||
if err == nil {
|
||||
|
|
@ -102,8 +103,7 @@ func NewSalia(uri string, cache time.Duration) (api.Charger, error) {
|
|||
}
|
||||
|
||||
func (wb *Salia) heartbeat() {
|
||||
_ = wb.post(salia.HeartBeat, "alive")
|
||||
for range time.NewTicker(30 * time.Second).C {
|
||||
for ; true; <-time.NewTicker(30 * time.Second).C {
|
||||
if err := wb.post(salia.HeartBeat, "alive"); err != nil {
|
||||
wb.log.ERROR.Println("heartbeat:", err)
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ func (wb *Salia) Enabled() (bool, error) {
|
|||
if err == nil && res.Secc.Port0.Salia.ChargeMode != echarge.ModeManual {
|
||||
err = fmt.Errorf("invalid mode: %s", res.Secc.Port0.Salia.ChargeMode)
|
||||
}
|
||||
return res.Secc.Port0.GridCurrentLimit > 0, err
|
||||
return res.Secc.Port0.GridCurrentLimit > 0 && res.Secc.Port0.Salia.PauseCharging == 0, err
|
||||
}
|
||||
|
||||
// Enable implements the api.Charger interface
|
||||
|
|
@ -175,6 +175,11 @@ func (wb *Salia) Enable(enable bool) error {
|
|||
}
|
||||
|
||||
err := wb.setCurrent(current)
|
||||
if err == nil {
|
||||
// ignore error for FW <1.52
|
||||
var offOn = map[bool]string{false: "1", true: "0"}
|
||||
_ = wb.post(salia.PauseCharging, offOn[enable])
|
||||
}
|
||||
if err == nil {
|
||||
wb.updated = time.Time{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ template: hardybarth-ecb1
|
|||
products:
|
||||
- brand: HardyBarth
|
||||
description:
|
||||
generic: cPH1 eCB1 Controller
|
||||
generic: cPH1 (eCB1 Controller)
|
||||
requirements:
|
||||
evcc: ["sponsorship"]
|
||||
params:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ template: hardybarth-salia
|
|||
products:
|
||||
- brand: HardyBarth
|
||||
description:
|
||||
generic: Salia PLCC Controller
|
||||
generic: cPH2 (Salia PLCC Controller)
|
||||
requirements:
|
||||
evcc: ["sponsorship"]
|
||||
params:
|
||||
- name: host
|
||||
render: |
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
product:
|
||||
brand: HardyBarth
|
||||
description: cPH1 eCB1 Controller
|
||||
description: cPH1 (eCB1 Controller)
|
||||
requirements: ["sponsorship"]
|
||||
render:
|
||||
- default: |
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
product:
|
||||
brand: HardyBarth
|
||||
description: Salia PLCC Controller
|
||||
description: cPH2 (Salia PLCC Controller)
|
||||
requirements: ["sponsorship"]
|
||||
render:
|
||||
- default: |
|
||||
type: template
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue