Scorpion, happy to help but what is your setup? how far are you? have you managed to get the python script running and feeding fan speed via mqtt? or do you need help from scratch?
BTW i switched to a better and easier option if you are using Raspberry Pi: using the HA’s GPIO and Climate components. So basically HA handles when to start or stop the fan based on a low and high limit that you set. Only problem is you dont get to control (or monitor) the speed of fan. see a screenshot below.

steps to follow:
- Ready the fan using this link. You basically need to integrate a transistor so the Fan can be turned on or off from GPIO and even has its speed adjusted. This will give you 3 wires, Power, Ground and a Control pin.
https://www.instructables.com/id/Control-a-Cooling-Fan-on-a-Raspberry-Pi-3/ - Plug the fan onto Raspberry Pi. Power to any of the power (making sure the voltage matches i.e. 3v or 5v) and ground to ground. The control pin, plug it onto pin 17.
- Add a switch with gpio platform to your configuration.yaml. This is my code for pin 17.
- Add a climate entity to your configuration.yaml. you can read the official documentation for climate control to fine tune these parameters to adjust to your needs
- Add the climate and if needed the switch to groups.yaml