Skip to content

Commit 77dcfe7

Browse files
committed
fix(battery): pick first battery when multiple detected instead of silently failing
The showBatteryPicker, showManualBatteryInput, and batteryChoices properties were set but never consumed by any view: discoveredBatId was never assigned, sensors never armed, and battery data never appeared. - Auto-select first detected battery when ids.length > 1 - Add console.warn diagnostics for multi-battery and exhausted fallback paths - Remove dead properties: showBatteryPicker, showManualBatteryInput, batteryChoices
1 parent bf2bb85 commit 77dcfe7

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

contents/ui/sensors/BatterySensors.qml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ Item {
4343
"battery_BATT0"
4444
]
4545
property var stage1Probes: []
46-
property var batteryChoices: []
47-
property bool showBatteryPicker: false
48-
property bool showManualBatteryInput: false
4946

5047
Component.onCompleted: {
5148
if (batteryDevice && batteryDevice !== "auto")
@@ -140,8 +137,8 @@ Item {
140137
return;
141138
}
142139
if (ids.length > 1) {
143-
batteryChoices = ids;
144-
showBatteryPicker = true;
140+
console.warn("BatterySensors: multiple batteries found:", JSON.stringify(ids), "— using first:", ids[0]);
141+
persistDetectedBattery(ids[0]);
145142
return;
146143
}
147144
}
@@ -159,7 +156,7 @@ Item {
159156

160157
function tryNextQdbus() {
161158
if (qdbusIndex >= qdbusVariants.length) {
162-
showManualBatteryInput = true;
159+
console.warn("BatterySensors: all detection methods exhausted; set batteryDevice manually in widget config");
163160
return;
164161
}
165162
var variant = qdbusVariants[qdbusIndex];

0 commit comments

Comments
 (0)