Bluetooth Headphones Inconsistent Connection

I have a pair of Beats Bluetooth Headphones that I’m trying to use as a state trigger in an automation. I have the automation and everything working but about half of the time that I turn on the headphones they don’t connect to my Pi/Home Assistant. It seems to work more reliably if I have just recently restarted HA, but I’m not sure if that’s a factor.

Are there any know techniques for ensuring consistent Bluetooth connection? I have a similar setup for my phone with no issues so the problem could be with the headphones and not HA?

The situation usually involves a few Bluetooth devices—say, a phone, a smartwatch, and a car stereo—trying to get along. Sometimes the conflict is between a phone, a fitness tracker, and Bluetooth headphones. Occasionally, the issue is simply a keyboard that’s confused about different iPads. And though we haven’t heard about all three-way troubles, we have some ideas about what’s going on.