Change Raspberry Pi GPIO state by manually publishing MQTT

You can communicate between esp8266 device using this code Multiple MQTT Clients on 8266
For python you can use this code How to interface two RaspberryPis over MQTT with Cayenne - #6 by shramik_salgaonkar