I connected a raspberry pi zero to my Yamaha keyboard's MIDI out port. I wrote some custom code to watch for different note or chord sequences. When one of those sequences is detected, the RPI notifies Home Assistant which then runs the corresponding automations.