-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Is your feature request related to a problem? Please describe.
As part of using the MQTT integration in Home-Assistant, I want to signal the unavailability of a device when I disconnect. This requires publishing a payload to a specific topic.
I'm using the LWT for this, but LWT is only triggered for ungraceful disconnects. However, when the context is cancelled, Paho has no facility to publish extra messages during a graceful disconnect.
Describe the solution you'd like
I'd like to have something like OnClientDisconnect, similar to OnClientError, but that only triggers for graceful disconnect. This function should execute as the last thing before the connection to the broker is closed.
Describe alternatives you've considered
I'm currently setting the DisconnectPacketBuilder to a function that always returns nil. This causes every disconnect to be ungraceful from the broker's perspective and thus results in the LWT always getting sent. This feels hacky and unintended.