From e0d77dc865d860666bf792f0a6c1aa0f51feb7dc Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 22 Dec 2023 22:59:26 +0100 Subject: [PATCH] Mqtt: use - to remove vehicle (#11192) --- provider/mqtt/client.go | 2 +- server/mqtt.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/provider/mqtt/client.go b/provider/mqtt/client.go index 98b4ef6f9f..e593246435 100644 --- a/provider/mqtt/client.go +++ b/provider/mqtt/client.go @@ -129,7 +129,7 @@ func (m *Client) Publish(topic string, retained bool, payload interface{}) error return nil } -// Listen validates uniqueness and registers and attaches listener +// Listen attaches listener to slice of listeners for given topic func (m *Client) Listen(topic string, callback func(string)) error { m.mux.Lock() m.listener[topic] = append(m.listener[topic], callback) diff --git a/server/mqtt.go b/server/mqtt.go index 3ab374367a..f52c414494 100644 --- a/server/mqtt.go +++ b/server/mqtt.go @@ -287,7 +287,8 @@ func (m *MQTT) listenLoadpointSetters(topic string, site site.API, lp loadpoint. } if err == nil { err = m.Handler.ListenSetter(topic+"/vehicle", func(payload string) error { - if payload == "" { + // https://github.com/evcc-io/evcc/issues/11184 empty payload is swallowed by listener + if payload == "-" { lp.SetVehicle(nil) return nil }