I added my Lego Rollercoaster on Home Assistant[0] a little while back. Nothing fancy, just cut a Power Functions extension wire to put a relay in-between and an ESP board to control it. On one side I had the power pack and the other the motor. Would have loved to switch out the power pack for a constant power source but never got to it.
If you're looking to do some Power Functions (PF) hackery, there are some interesting articles that cover the wiring and working of PF gadgets more in detail[1][2].