Skip to content

Commit

Permalink
HardyBarth cPH2: update api and require sponsorship (evcc-io#3197)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored and dontbyte committed Aug 2, 2022
1 parent cc4a5b8 commit 94c82a6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
4 changes: 3 additions & 1 deletion charger/echarge/salia/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package salia
const (
HeartBeat = "salia/heartbeat"
ChargeMode = "salia/chargemode"
PauseCharging = "salia/pausecharging"
GridCurrentLimit = "grid_current_limit"
)

Expand Down Expand Up @@ -32,7 +33,8 @@ type Port struct {
}
}
Salia struct {
ChargeMode string
ChargeMode string
PauseCharging int `json:"pausecharging,string"`
}
Metering struct {
Meter struct {
Expand Down
19 changes: 12 additions & 7 deletions charger/hardybarth-salia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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{}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/charger/hardybarth-ecb1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ template: hardybarth-ecb1
products:
- brand: HardyBarth
description:
generic: cPH1 eCB1 Controller
generic: cPH1 (eCB1 Controller)
requirements:
evcc: ["sponsorship"]
params:
Expand Down
4 changes: 3 additions & 1 deletion templates/definition/charger/hardybarth-salia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion templates/docs/charger/hardybarth-ecb1_0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
product:
brand: HardyBarth
description: cPH1 eCB1 Controller
description: cPH1 (eCB1 Controller)
requirements: ["sponsorship"]
render:
- default: |
Expand Down
3 changes: 2 additions & 1 deletion templates/docs/charger/hardybarth-salia_0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
product:
brand: HardyBarth
description: Salia PLCC Controller
description: cPH2 (Salia PLCC Controller)
requirements: ["sponsorship"]
render:
- default: |
type: template
Expand Down

0 comments on commit 94c82a6

Please sign in to comment.