Shelly1 MQTT Switch toggles on Reboot

Hello!
I created a MQTT switch for the Shelly1. But everytime I reboot the Home Assistant Host- the Shelly 1 toggles. Is it a bug? Or have I missed something in my configruation?

Thanks for your help!

switch:
  - platform: mqtt
    name: "Garagentor"
    state_topic: "shellies/shelly1-xxx/relay/0"
    command_topic: "shellies/shelly1-xxx/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    state_on: "on"
    state_off: "off"
    optimistic: false
    qos: 0
    retain: true

You made a big mistake

  retain: true

You really should not be using this if you don’t understand what it is doing. It causes the last COMMAND to be retained, not as you might have believed the state of the switch.
Remove it from the configuration.yaml AND remove it from your brokers database.

Thank you for your help! In my configuration.yaml I set retain: false -but how do I remove it from my brokers database?

The easiest way is to use a seperate program called mqtt explorer. Just stand on the message, and click on the trash icon

Other ways are explained here :

Thank you it works great!

In my configuration.yaml I set
retain: false

and with the MQTT Explorer I delete the brokers database.