How to use payload "offline" in availability topic for mqtt device


I have a sensor which is using mqtt discovery. It gets added to the hassio and operates properly. But when I power off the device it still shows the device as active (obviously with no change in data). So I need to know how can I use the payload “offline” on availability topic to show it as not available (greyed out) when I power off the device?

Basically I need to make the device offline when I power it off.

I am already using payload “online” to make the device as available.

Here is my json data sending through config topic:

“name”: “Water_Tank_Sensor_D”,
“stat_t”: “homeassistant/sensor/wts_dist/state”,
“avty_t”: “homeassistant/sensor/wts_dist/available”,
“pl_avail”: “online”,
“pl_not_avail”: “offline”,
“unit_of_meas”: “%”,
“val_tpl”: “{{ value_json.filledcap}}”,
“ic”: “mdi:water-pump”,
“uniq_id”: “Water_Tank_Sensor_D-2C_3A_11_11_11_11”,
“dev”: {“ids”: [“Water_Tank_Sensor_D-2C_3A_11_11_11_11”],“name”: “Water_Tank_Sensor_D”,“mdl”: “NodeMCU 1.0 (ESP12E module)”,“mf”: “Amica”,“sw”: “v0.1”}

Thanks in advance,