r/LegendsUltimate • u/g0nzonia • 8h ago
Modding Swapping the power button for a momentary switch - Part 2 (Software)
My original plan with the software focused primarily on the shutdown sequence. I use Home Assistant, so I planned to send a webhook to Home Assistant to trigger an automation that would wait a specified period and then cut power when the ALU was shut down from the RCADE interface. That was easy and worked, no problem. As I thought about it, though, what if a user didn't know about the shutdown and just pressed the button? Or what if I wanted to reboot instead of shutting down? What if someone who wanted to do this mod didn't have Home Assistant?
The answer was to move all the logic onto the Shelly and the ALU. Big thanks to the team who work on RCADE for all their support and for making such an awesome system that makes all this possible.
To handle the button press and shut down or reboot:
I added a Python webhooks server to the ALU that starts on boot. On the Shelly, I have 2 scripts.
One script is for sending the call to the ALU to shut down or reboot (single-press shutdown, long-press reboot).
The other script is a server to determine if the ALU has requested a shutdown from the UI. This is what was happening originally on Home Assistant.
The files needed for all this can be found on GitHub.
Edited because I added a countdown function:
After I typed this up I thought of something that I felt would improve on this a little. When the user uses the power button to shutdown, the system will now shut down RCADE and display a countdown letting the user know it is shutting down or rebooting. Here's a video of the reboot being triggered by a long press. I noticed a couple of issues with the marquee I need to work on.
Edit2: Replaced video with higher resolution version.