OpenWB Pro: add wakeup (cp interrupt) (#24706)

This commit is contained in:
andig 2025-10-24 18:09:40 +02:00 • committed by GitHub
parent e087276beb
commit 7ac7e037df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 1 deletions

View file

@ -16,6 +16,8 @@ func init() {
registry.AddCtx("openwbpro", NewOpenWBProFromConfig)
}
//go:generate go tool decorate -f decorateOpenWBPro -b *OpenWBPro -r api.Charger -t "api.Resurrector,WakeUp,func() error"
// https://openwb.de/main/?page_id=771
// OpenWBPro charger implementation
@ -39,7 +41,22 @@ func NewOpenWBProFromConfig(ctx context.Context, other map[string]interface{}) (
return nil, err
}
return NewOpenWBPro(ctx, util.DefaultScheme(cc.URI, "http"), cc.Cache)
wb, err := NewOpenWBPro(ctx, util.DefaultScheme(cc.URI, "http"), cc.Cache)
if err != nil {
return nil, err
}
status, err := wb.statusG.Get()
if err != nil {
return nil, err
}
var wakeup func() error
if status.Version >= 9 {
wakeup = wb.wakeup
}
return decorateOpenWBPro(wb, wakeup), nil
}
// NewOpenWBPro creates OpenWBPro charger
@ -227,3 +244,7 @@ func (wb *OpenWBPro) Identify() (string, error) {
return res.RfidTag, nil
}
func (wb *OpenWBPro) wakeup() error {
return wb.set("cp_interrupt=true")
}

View file

@ -0,0 +1,35 @@
package charger
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
import (
"github.com/evcc-io/evcc/api"
)
func decorateOpenWBPro(base *OpenWBPro, resurrector func() error) api.Charger {
switch {
case resurrector == nil:
return base
case resurrector != nil:
return &struct {
*OpenWBPro
api.Resurrector
}{
OpenWBPro: base,
Resurrector: &decorateOpenWBProResurrectorImpl{
resurrector: resurrector,
},
}
}
return nil
}
type decorateOpenWBProResurrectorImpl struct {
resurrector func() error
}
func (impl *decorateOpenWBProResurrectorImpl) WakeUp() error {
return impl.resurrector()
}

View file

@ -23,4 +23,9 @@ type Status struct {
Soc int `json:"soc_value"`
SocTimestamp int64 `json:"soc_timestamp"`
Serial string
Version int
// v9
CPInterruptDuration int `json:"cp_interrupt_duration"`
CPInterruptIsActive int `json:"cp_interrupt_isactive"`
CPInterrupt string `json:"cp_interrupt_version"`
}