Enabling the LWT (Last Will and Testament) feature requires adding three lines of code and add the very cool functionality of giving HA the ability to detect if the device looses power.
device.enableSharedAvailability(); // [OPTIONAL] Enables the ability to set the on/off line status of the device
device.setAvailability(true); // Set the device to on-line
device.enableLastWill(); // [OPTIONAL] Allows HA to detect when the device losses power (and thus disable the controls in the HA UI)
Enabling the LWT (Last Will and Testament) feature requires adding three lines of code and add the very cool functionality of giving HA the ability to detect if the device looses power.