Making MQTT switch unavailable if not updated in a while

Hello there!

I am setting up an Arduino based device that will be bounded to a HA MQTT switch.
If my Arduino goes offline, its MQTT sensors will be unavailable thanks to their expire_after properties.

I’ve been looking for an equivalent to make MQTT switches unavailable if they are not being updated for a while. No success so far.
==> Is there a nice and clean way to do so ?

If not, I am considering to have HA sending a MQTT offline message if there is no MQTT online message for a minute or two.



Hi Francis,

Thanks for your reply. That’s a great MQTT feature!

I followed GitHub - adafruit/Adafruit_MQTT_Library: Arduino library for MQTT support and QoS & Wills | MQTT, Adafruit IO & You! | Adafruit Learning System examples without success within reasonable timing.

So I got inspiration from and got it working with automation.

As it is a software only topic, I’ll give it a new try when my project will be running.