Hi Ahmar,
if the harmony cannot turn it off you may try moving the Infrared emitter closer to the base of your fan. Once you have the control via the Harmony hub running, you could then implement the code above in your Home Assistant to make the control easier or to even automate it.