Skip to content

Commit

Permalink
Mqtt: use - to remove vehicle (#11192)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Dec 22, 2023
1 parent 7f9d997 commit e0d77dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion provider/mqtt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion server/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e0d77dc

Please sign in to comment.