Use state of mqtt topic to override physical button press action?!

Hi… i have tid in my ESPHome yaml

- platform: gpio
id: manual_open_switch
internal: true
number: GPIO33
mode: INPUT
inverted: true
- delayed_on_off: 20ms
- switch.toggle: relay_toggle
- platform: gpio
id: relay
pin: GPIO27
internal: true
- platform: template
id: relay_toggle
internal: true
- switch.turn_on: relay
- delay: 1s
- switch.turn_off: relay

and in Home Assistant i have defined a MQTT switch like this

- platform: mqtt
unique_id: big_garagedoor_lockout
name: Deaktiver fysisk bryter til garasjeport
command_topic: 'MH/BigGaragedoor/Lockout'
state_topic: 'MH/BigGaragedoor/Lockout'
payload_on: 'on'
payload_off: 'off'
retain: true

I somehow want the state of the mqtt topic to override the input of the physical switch. like if the topic has the payload of on, i dont want the relay_toggle template switch to be run. Anyone got any clever solutions?

This is so i can disable the physical openswitch of my garagedoor :stuck_out_tongue:

Please read this and post your code properly How to help us help you - or How to ask a good question