feat(#188): support battery-percent header

This commit is contained in:
Benjamin Nussbaum 2026-02-12 21:48:03 +01:00
parent d9ab052cbc
commit 8400c1eaf1
2 changed files with 37 additions and 2 deletions

View file

@ -49,8 +49,9 @@ Route::get('/display', function (Request $request) {
'last_refreshed_at' => now(),
]);
if ($request->hasHeader('battery-percent')) {
$batteryPercent = (int) $request->header('battery-percent');
$batteryPercent = $request->header('battery-percent') ?? $request->header('percent-charged');
if ($batteryPercent !== null) {
$batteryPercent = (int) $batteryPercent;
$batteryVoltage = $device->calculateVoltageFromPercent($batteryPercent);
$device->update([
'last_battery_voltage' => $batteryVoltage,