feat: Add ability to read battery and charging status#106
feat: Add ability to read battery and charging status#106mithun50 merged 2 commits intomithun50:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds battery status capability to the application. Native Android code retrieves battery information via a broadcast receiver. A Flutter bridge method invokes this native code via MethodChannel. A new Changes
Sequence DiagramsequenceDiagram
participant Client as External Client
participant Capability as BatteryCapability
participant Bridge as NativeBridge
participant MethodChannel as MethodChannel
participant Native as Android Native
Client->>Capability: battery.status command
Capability->>Capability: _status()
Capability->>Bridge: getBatteryStatus()
Bridge->>MethodChannel: invokeMethod("getBatteryStatus")
MethodChannel->>Native: getBatteryStatus handler
Native->>Native: Register battery broadcast receiver
Native->>Native: Extract battery extras (level, temp, voltage, status, plugged)
Native->>Native: Compute percentage & derive status string
Native-->>MethodChannel: Return HashMap with battery data
MethodChannel-->>Bridge: Cast to Map<String, dynamic>
Bridge-->>Capability: Return battery map
Capability->>Capability: Construct NodeFrame.response
Capability-->>Client: Return NodeFrame with battery data or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This PR adds the ability for openclaw to read the battery and charging state from the device.
Thanks for a great project, and if this PR is desirable, please let me know how to improve it.
Summary by cubic
Adds a new battery capability so nodes can report device battery level, charging state, temperature, and voltage via the
battery.statuscommand. This enables monitoring power status from the app and gateway.getBatteryStatusinMainActivityusingACTION_BATTERY_CHANGEDto return level, percentage, charging status, plug type, temperatureC, and voltageMv.BatteryCapabilityexposingbattery.status, withNativeBridge.getBatteryStatus()to call the native method.NodeProviderand allowedbattery.statusinGatewayService.Written for commit 82fb9b2. Summary will update on new commits.
Summary by CodeRabbit
Release Notes