HomeKit Buttons from Home Assistant feat. Habitat
Integrating multiple home automation platforms is not for the faint of heart, and yet I do it.
Here's a little write-up on getting virtual buttons on a virtual remote into HomeKit, that can be "pressed" by an external platform and make HomeKit stuff happen.
Background:
I like HomeKit because I am in the Apple ecosystem and Siri is fast and responsive for controlling devices by voice weather from my HomePods, iPhone (including CarPlay), or Apple Watch. Otherwise, I try to keep all of my "logic" external to HomeKit -- HomeKit automations are clunky and cumbersome to setup compared to scripting in Home Assistant, Node Red, Xtension, etc.
Sometimes you really need the logic/automation to happen within HomeKit though. For example, I can make my playlists from Apple Music play on my HomePods...but only through a HomeKit automation, which means if I want that to be kicked off by something else (Say, my morning wakeup routine), then I need an input/trigger into HomeKit.
The typical way:
Mostly when people need to do this, they create dummy switches or sensors from another platform in HomeKit. This is okay, but you have to stick them somewhere in your home, and they clutter up the view. We can do better. HomeKit has support for remotes -- and these remotes can have things happen when buttons are pressed -- but it's shockingly difficult to make virtual buttons 😂.
How I did it:
Habitat has a virtual button device. You can configure the number of physical buttons, and send a double_tab, press, hold, and release event for any of the buttons.

Home Assistant can take this device and push it through to HomeKit via the built in integration.
One challenge -- the buttons all come in as "single press" and the names do not match. It also appears that the maximum number of buttons on a remote in HomeKit is 36 buttons.

The mapping is also not intuitive.
Habitat Button 1 Double Tap maps to HomeKit Button 1
Habitat Button 1 Hold maps to HomeKit Button 2
Habitat Button 1 Push maps to HomeKit Button 3
Habitat Button 2 Double Tap maps to HomeKit Button 4
Habitat Button 2 Hold maps to HomeKit Button 5
Habitat Button 2 Push maps to HomeKit Button 6
...
Habitat Button 12 Push maps to HomeKit Button 36
(This is currently the maximum for a HomeKit remote)

Finally, how do we "push" these buttons from Home Assistant? We can write a script using the "fire event" action and simulate a subset of the data from the habitat hub. This makes the habitat plugin in HomeAssistant think the button has been pressed, even though the button press originates in Home Assistant.

And after all this, I am now set up to have different playlists play at different times of day in my house :-)
Bonus:
You "sniff" the event bus data in the developer tab:
