Esp-01 Mqtt door sensor troubles

Hi everyone

ive been trying to follow some tutorials on how to make a esp-01 door sensor using mqtt and home assistant but it doesnt seem to work. the esp can connect to wifi and occasionally i will be able to see in the mqtt logs that say 1650823245: New connection from 192.168.1.14 on port 1883. {“result”: “ok”, “data”: {}}1650823245: New client connected from 192.168.1.14 as FrontDoor (p2, c1, k15, u’mqtt-user’). 1650823288: Client FrontDoor has exceeded timeout, disconnecting. but then the icon in lovelace doesnt change. im pretty sure im doing something really wrong.

ps im a noob to this sort of stuff so sorry if it makes no sense

heres link to esp-01 setup code: JustPaste.it - Share Text & Images the Easy Way

link to config.yaml JustPaste.it - Share Text & Images the Easy Way