BatteryMonitor: add casts to make new compiler versions happy