Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Jan 23, 2025
2 parents 5551b07 + 4adee73 commit 1889b6b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
16 changes: 10 additions & 6 deletions charger/openwb-2.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ func init() {

// https://openwb.de/main/wp-content/uploads/2023/10/ModbusTCP-openWB-series2-Pro-1.pdf

//go:generate decorate -f decorateOpenWB20 -b *OpenWB20 -r api.Charger -t "api.Identifier,Identify,func() (string, error)"
//go:generate decorate -f decorateOpenWB20 -b *OpenWB20 -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error" -t "api.Identifier,Identify,func() (string, error)"

// NewOpenWB20FromConfig creates a OpenWB20 charger from generic config
func NewOpenWB20FromConfig(other map[string]interface{}) (api.Charger, error) {
cc := struct {
Connector uint16
Phases1p3p bool
modbus.TcpSettings `mapstructure:",squash"`
}{
Connector: 1,
Expand All @@ -63,12 +64,17 @@ func NewOpenWB20FromConfig(other map[string]interface{}) (api.Charger, error) {
return nil, err
}

var phases1p3p func(int) error
if cc.Phases1p3p {
phases1p3p = wb.phases1p3p
}

var identify func() (string, error)
if _, err := wb.identify(); err == nil {
identify = wb.identify
}

return decorateOpenWB20(wb, identify), nil
return decorateOpenWB20(wb, phases1p3p, identify), nil
}

// NewOpenWB20 creates OpenWB20 charger
Expand Down Expand Up @@ -201,10 +207,8 @@ func (wb *OpenWB20) Voltages() (float64, float64, float64, error) {
return wb.getPhaseValues(wb.base + openwbRegVoltages)
}

var _ api.PhaseSwitcher = (*OpenWB20)(nil)

// Phases1p3p implements the api.PhaseSwitcher interface
func (wb *OpenWB20) Phases1p3p(phases int) error {
// phases1p3p implements the api.PhaseSwitcher interface
func (wb *OpenWB20) phases1p3p(phases int) error {
if _, err := wb.conn.WriteSingleRegister(wb.base+openwbRegPhaseTarget, uint16(phases)); err != nil {
return err
}
Expand Down
40 changes: 37 additions & 3 deletions charger/openwb-2.0_decorators.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions templates/definition/charger/openwb-2.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ params:
id: 1
- name: connector
default: 1
- name: phases1p3p
type: bool
description:
en: Charger is equipped with phase switching feature
de: Phasenumschaltung vorhanden
advanced: true
default: true
render: |
type: openwb-2.0
{{- include "modbus" . }}
connector: {{ .connector }}
phases1p3p: {{ .phases1p3p }}

0 comments on commit 1889b6b

Please sign in to comment.