Switch rpi_gpio with mqtt

HI,

I am trying to switch a relay connected directly to my pi GPIO using mqtt.
The switches work, but how do I trigger the switch from another device with MQTT.
I have this:
switch:
platform: rpi_gpio
ports:
2: Flower Bed
3: Bedroom Light
4: Bathroom Light
17: Gate
#27: Nothing
23: Kitchen Light
24: Study Light
25: Lounge Light
invert_logic: true

I want 17: Gate to also be able to switch with MQTT. So i can either open the gate from the tablet, or from my keypad with esp8266.

Im guessing I need to create a switch with the platform: mqtt. somehow access the 17: Gate from above

Please help.

Thank you

I think what you want is an automation that triggers on an MQTT message from your keypad, and has an action that turns your switch on or off.

See the MQTT trigger as an example of the trigger, and anything in automation actions on how to do the action.