Arduino Code problem or HA / MQTT issue?

I have automated blinds using the below code/thread. Ive noticed that when ever I plug them in or 2.4ghz wifi drops and reconnects the blinds will open and close. In the code there is a line that says comment out if you want to retain position, tried this and still happens. Any idea on how I can fix this issue?

You’re probably using a pin that gets pulled low or high upon boot, and the device probably reboots if it cannot connect to WiFi.

So i am using gpio12 which is safe from boot issue from what Im finding

This?

client.publish("blinds2/level/state", "100", true); // Comment out if you want the blinds to retain the last position, otherwise they will open to 100% when turned on again.

I see you also have this:

cover:
  - platform: mqtt
    ....
    qos: 0

Try setting QOS to 2.