Can you provide any more details about how you did it? Sounds like I need to do this.
homeassistant
Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io
Not OP, but we just installed Caseta/Lutron switches (https://www.lowes.com/pd/Lutron-Caseta-Wireless-4-Speed-1-5-Amp-White-Smart-Touch-Fan-Control/1000790772) and they work like a charm. They do require a bridge, but it integrates pretty easily into Home Assistant.
This obviously wouldn't work if your fan is hooked up to the overhead light switch. You'd need a box to put in the fan itself.
We have a bedside button (Shelly, I think?) that when we press it for bedtime, it turns off all lights in the house (Hue bulbs and Kasa wall switches), turns off the TV (Kasa outlet), turns up the fan speed (Caseta wall switch), and plays rain noises (Google Home speaker).