From 7ac7e037dfee05266c5c1cf068add15f887fd994 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 24 Oct 2025 18:09:40 +0200 Subject: [PATCH] OpenWB Pro: add wakeup (cp interrupt) (#24706) --- charger/openwb-pro.go | 23 ++++++++++++++++++++- charger/openwb-pro_decorators.go | 35 ++++++++++++++++++++++++++++++++ charger/openwb/pro/types.go | 5 +++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 charger/openwb-pro_decorators.go diff --git a/charger/openwb-pro.go b/charger/openwb-pro.go index 01c447580..d697c997b 100644 --- a/charger/openwb-pro.go +++ b/charger/openwb-pro.go @@ -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") +} diff --git a/charger/openwb-pro_decorators.go b/charger/openwb-pro_decorators.go new file mode 100644 index 000000000..07c25b9e5 --- /dev/null +++ b/charger/openwb-pro_decorators.go @@ -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() +} diff --git a/charger/openwb/pro/types.go b/charger/openwb/pro/types.go index 2f5d319e8..3fc4885f5 100644 --- a/charger/openwb/pro/types.go +++ b/charger/openwb/pro/types.go @@ -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"` }