MQTT Switch automatically sending commands

I have an MQTT switch setup for my gaming pc and am controlling it from lovelace quite happily, the issue I’m having though is home assistant seems to be sending commands automatically without my interaction. I.e. my pc randomly turned on in the middle of the night.
I’m not sure if its reactive to the a state change, or whether its trying to restore the state from what homeassistant thinks it should be.
Ideally I would only like HA to send commands when I press the lovelace button or if I write my own automation.
This is my config:

  • platform: mqtt
    state_topic: “stat/unlockideas/pc/switch”
    command_topic: “stat/unlockideas/pc/switch/cmd”
    availability_topic: “stat/unlockideas/pc/switch/avail”
    name: “Gaming PC”
    unique_id: “pc_gaming1”
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “online”
    payload_not_available: “offline”
    optimistic: false
    qos: 1
    retain: false

Thanks in advance!

What firmware switch are you using? If its tasmota, I can see some issues with your configuration. let me know which firmware the switch is.

Thanks for the reply!

I’m using my own custom firmware (arduino sketch) which simply reports the status periodically and turns on / off when it receives the mqtt commands.

If its a esp8266 based devise, it would be best if you could shift to esphome or tasmota. Since its a custom firmware, i am not so aware about what is going on.