OpenWB: add CP interrupt (#3968)
This commit is contained in:
parent
abf4f76568
commit
346c818c5d
2 changed files with 19 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package charger
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
|
|
@ -24,6 +25,7 @@ type OpenWB struct {
|
|||
currentPowerG func() (float64, error)
|
||||
totalEnergyG func() (float64, error)
|
||||
currentsG []func() (float64, error)
|
||||
wakeupS func(int64) error
|
||||
authS func(string) error
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +97,14 @@ func NewOpenWB(log *util.Logger, mqttconf mqtt.Config, id int, topic string, p1p
|
|||
currentS := provider.NewMqtt(log, client, fmt.Sprintf("%s/set/isss/%s", topic, currentTopic),
|
||||
timeout).WithRetained().IntSetter("current")
|
||||
|
||||
cpTopic := openwb.SlaveCPInterruptTopic
|
||||
if id == 2 {
|
||||
// TODO remove after https://github.com/snaptec/openWB/issues/1757
|
||||
cpTopic = strings.TrimSuffix(cpTopic, "1") + "2"
|
||||
}
|
||||
wakeupS := provider.NewMqtt(log, client, fmt.Sprintf("%s/set/isss/%d/get/%s", topic, id, cpTopic),
|
||||
timeout).WithRetained().IntSetter("cp")
|
||||
|
||||
authS := provider.NewMqtt(log, client, fmt.Sprintf("%s/set/chargepoint/%d/get/%s", topic, id, openwb.RfidTopic),
|
||||
timeout).WithRetained().StringSetter("rfid")
|
||||
|
||||
|
|
@ -115,6 +125,7 @@ func NewOpenWB(log *util.Logger, mqttconf mqtt.Config, id int, topic string, p1p
|
|||
currentPowerG: currentPowerG,
|
||||
totalEnergyG: totalEnergyG,
|
||||
currentsG: currentsG,
|
||||
wakeupS: wakeupS,
|
||||
authS: authS,
|
||||
}
|
||||
|
||||
|
|
@ -222,3 +233,10 @@ var _ api.Authorizer = (*OpenWB)(nil)
|
|||
func (m *OpenWB) Authorize(key string) error {
|
||||
return m.authS(key)
|
||||
}
|
||||
|
||||
var _ api.AlarmClock = (*OpenWB)(nil)
|
||||
|
||||
// WakeUp implements the api.AlarmClock interface
|
||||
func (m *OpenWB) WakeUp() error {
|
||||
return m.wakeupS(1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,5 @@ const (
|
|||
SlaveChargeCurrentTopic = "Current"
|
||||
SlavePhasesTopic = "U1p3p"
|
||||
SlaveClearRfidTopic = "ClearRfid"
|
||||
SlaveCPInterruptTopic = "Cpulp1"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue