Ha, I just built something like this with a Raspberry Pi for fun. My standing desk (a Conset) only had a up/down button so I used a RPi + relay hat + distance sensor + screen/buttons to allow height presets as well as control via Homebridge:
Out of curiosity, why did you go with height instead of timing? Wouldn't you get equivalent results without the use of the sensor by activating the motor for a set period of time?
Yeah I tried timing first but it was hard to get right. The weight of the desk affects it and it also goes down quicker then it goes up (not sure if that’s common with all desks - I would assume so). You also can’t use the regular up/down adjustments if you rely on timing as it would be out of sync (I have buttons to raise and lower regularly as well as moving to presets)