Tasmota/MQTT/Home Assistant

Take a look at the following thread for some ways to accomplish what you want to do: