MQTT example in combination with Raspberry Pi

In the past I did write my own Thermostat using a Raspberry Pi (RPI) and a relais.
Now I do like to start to use Homey to control the heating.
For that I think MQTT it is a nice option for controlling the heating relais at the RPI from Homey using MQTT switching on and off the heating.

Is somebody over here doing this also?
So if yes is it possible to give some example code (python?) for the RPI and an example how to use MQTT on Homey and the RPI?