Mqtt: add time/energy setter (#6149)
This commit is contained in:
parent
d17fa26d53
commit
679c435f74
1 changed files with 10 additions and 0 deletions
|
|
@ -120,11 +120,21 @@ func (m *MQTT) listenSetters(topic string, site site.API, lp loadpoint.API) {
|
|||
lp.SetMinSoc(soc)
|
||||
}
|
||||
})
|
||||
m.Handler.ListenSetter(topic+"/targetEnergy/set", func(payload string) {
|
||||
if val, err := strconv.ParseFloat(payload, 64); err == nil {
|
||||
lp.SetTargetEnergy(val)
|
||||
}
|
||||
})
|
||||
m.Handler.ListenSetter(topic+"/targetSoc/set", func(payload string) {
|
||||
if soc, err := strconv.Atoi(payload); err == nil {
|
||||
lp.SetTargetSoc(soc)
|
||||
}
|
||||
})
|
||||
m.Handler.ListenSetter(topic+"/targetTime/set", func(payload string) {
|
||||
if val, err := time.Parse(time.RFC3339, payload); err == nil {
|
||||
_ = lp.SetTargetTime(val)
|
||||
}
|
||||
})
|
||||
m.Handler.ListenSetter(topic+"/minCurrent/set", func(payload string) {
|
||||
if current, err := strconv.ParseFloat(payload, 64); err == nil {
|
||||
lp.SetMinCurrent(current)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue