Mqtt: use - to remove vehicle (#11192)

This commit is contained in:
andig 2023-12-22 22:59:26 +01:00 • committed by GitHub
parent 7f9d997bda
commit e0d77dc865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -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)

View file

@ -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
}