I am bookmarking this for future to ensure I can use the apple script for other types of bluetooth devices I have :).
BTW if you aren’t using the Apple AirPods you should give it a try. I would definitely say they were my best purchase in 2017. They are so comfortable that I sleep with them sometimes and I wake up with them intact in my ears and I don’t even realise I had them plugged in my ears. If you aren’t convinced here is a review by Sajib that you can read to convince yourself 🙂 .