Mqtt: fix clearing retained topics
This commit is contained in:
parent
f19c87b8ca
commit
1ba175bd5c
2 changed files with 3 additions and 3 deletions
|
|
@ -124,7 +124,7 @@ func (m *Client) Listen(topic string, callback func(string)) {
|
|||
func (m *Client) ListenSetter(topic string, callback func(string)) {
|
||||
m.Listen(topic, func(payload string) {
|
||||
callback(payload)
|
||||
if err := m.Publish(topic, false, nil); err != nil {
|
||||
if err := m.Publish(topic, true, ""); err != nil {
|
||||
m.log.ERROR.Printf("clear: %v", err)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ func (m *MQTT) Run(site site.API, in <-chan util.Param) {
|
|||
m.publish(topic, true, "online")
|
||||
|
||||
// site setters
|
||||
m.Handler.Listen(fmt.Sprintf("%s/site/prioritySoC/set", m.root), func(payload string) {
|
||||
m.Handler.ListenSetter(fmt.Sprintf("%s/site/prioritySoC/set", m.root), func(payload string) {
|
||||
soc, err := strconv.Atoi(payload)
|
||||
if err == nil {
|
||||
_ = site.SetPrioritySoC(float64(soc))
|
||||
|
|
@ -128,7 +128,7 @@ func (m *MQTT) Run(site site.API, in <-chan util.Param) {
|
|||
for id := range site.LoadPoints() {
|
||||
topic := fmt.Sprintf("%s/loadpoints/%d", m.root, id+1)
|
||||
for _, dep := range []string{"range", "socCharge", "vehicleSoc"} {
|
||||
m.publish(fmt.Sprintf("%s/%s", topic, dep), true, nil)
|
||||
m.publish(fmt.Sprintf("%s/%s", topic, dep), true, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue