Apple has always these kind of bugs with their wireless (or even wired) platforms. You just need to force it to connect.
So you can go to sound settings of system preferences and force connect there.
or if you already have the indicator in the status bar , you can option+click on that and force connect from there.
Note that it could either fail because it ...
The ioreg utility uses IOKit to get the values for for example the battery status of the Magic Mouse.
You can access IOKit from Python using ctypes - a foreign function library for Python. It allows you to call C/Objective C functions etc. from Python.
You can see an example of how to that with IOKit here: