Mqtt: add batteryDischargeControl and smartCostLimit (#13864)
This commit is contained in:
parent
c8b3e24fe2
commit
5750d0d1e9
2 changed files with 16 additions and 1 deletions
|
|
@ -173,10 +173,17 @@ func (m *MQTT) Listen(site site.API) error {
|
|||
|
||||
func (m *MQTT) listenSiteSetters(topic string, site site.API) error {
|
||||
for _, s := range []setter{
|
||||
{"/prioritySoc", floatSetter(site.SetPrioritySoc)},
|
||||
{"/bufferSoc", floatSetter(site.SetBufferSoc)},
|
||||
{"/bufferStartSoc", floatSetter(site.SetBufferStartSoc)},
|
||||
{"/batteryDischargeControl", boolSetter(site.SetBatteryDischargeControl)},
|
||||
{"/prioritySoc", floatSetter(site.SetPrioritySoc)},
|
||||
{"/residualPower", floatSetter(site.SetResidualPower)},
|
||||
{"/smartCostLimit", floatSetter(func(limit float64) error {
|
||||
for _, lp := range site.Loadpoints() {
|
||||
lp.SetSmartCostLimit(limit)
|
||||
}
|
||||
return nil
|
||||
})},
|
||||
} {
|
||||
if err := m.Handler.ListenSetter(topic+s.topic, s.fun); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package server
|
|||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type setter struct {
|
||||
|
|
@ -26,3 +28,9 @@ func floatSetter(set func(float64) error) func(string) error {
|
|||
func intSetter(set func(int) error) func(string) error {
|
||||
return setterFunc(strconv.Atoi, set)
|
||||
}
|
||||
|
||||
func boolSetter(set func(bool) error) func(string) error {
|
||||
return setterFunc(func(v string) (bool, error) {
|
||||
return cast.ToBoolE(v)
|
||||
}, set)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue