I'm trying to display my mouse's battery level in Home Assistant, but I'm not familiar with PowerShell. My PC and Home Assistant are set up without Bluetooth, so I'm using a 2.4GHz USB stick. I heard that I could use Hass.Agent, which is a Home Assistant Desktop App, to gather data via PowerShell and send it to Home Assistant as a sensor. My main question is whether there's a way to retrieve the battery level from SignalRGB through PowerShell, as I'd like to bypass using Synapse due to the issues it's caused.
4 Answers
Great question! I took a look into it. While I don't have a complete answer, here's something that could help:
On Windows 11 with PowerShell 7.5.4, if you have a Logitech MX2 mouse, you can try this:
```powershell
$d = Get-PnpDevice -PresentOnly | where friendlyname -match 'mx'
$d | Get-PnpDeviceProperty | Out-GridView
```
This might show you a property that corresponds to the battery percentage!
Unfortunately, Razer doesn't provide an API for anything other than color customization (Chroma SDK). You could technically communicate with the USB buffer to extract this info, but that would mean reverse-engineering the firmware, which is quite complicated!
You might want to look into WMI. Check if there are any namespaces or classes added by the Razer software using WMI Explorer. If there are any useful classes, you can call them with PowerShell!
This sounds like an interesting challenge, but since I lack the hardware for troubleshooting, I can't contribute much. Keep us updated on your progress! Also, don't shy away from discussing this with tools like Google AI or Microsoft Copilot, as they might help you with PowerShell commands!
Oh, and a side note: from what I've found, you can't pull battery values from SignalRGB through PowerShell directly. However, you could still get battery info using standard PowerShell commands for your device, such as querying the Win32_Battery WMI class or using the `powercfg` command.

I checked the Win32_Battery class too, and it only seems to relate to the actual machine battery, not the mouse. I'm now trying to see if `powercfg` can help instead.