feat(power): add setting to show current status instead of action

Reddit report: the header power toggle switches correctly but
displays "backwards" - the button shows the action a click would
perform (e.g. "Aus" while the printer is on), not the printer's
actual current state, which some users find counterintuitive.

Both readings are legitimate, so this adds a per-printer opt-in
(Settings -> Power Switch -> "Aktuellen Status statt Aktion
anzeigen") rather than flipping the default for everyone.
power_status_inverted=0 (default) keeps today's behavior; =1 mirrors
the actual on/off state instead. The backend's power-status parsing
is untouched - only _applyHeaderPowerState() picks which state to
display, so the click handler still always toggles the real state
regardless of display mode.
This commit is contained in:
2026-09-01 17:31:38 +02:00
parent b44c9021a0
commit 7d28ed4e92
11 changed files with 30 additions and 2 deletions

View File

@ -679,6 +679,7 @@ class EndpointsMixin:
(getattr(br._args, "power_on_url", "") or "").strip()
or (getattr(br._args, "power_off_url", "") or "").strip()
),
"power_status_inverted": bool(getattr(br._args, "power_status_inverted", 0)),
})
return self._json_cors({"result": out})
@ -2018,6 +2019,7 @@ class EndpointsMixin:
"power_on_url": getattr(self._args, "power_on_url", "") or "",
"power_off_url": getattr(self._args, "power_off_url", "") or "",
"power_status_url": getattr(self._args, "power_status_url", "") or "",
"power_status_inverted": getattr(self._args, "power_status_inverted", 0),
"default_ams_slot": getattr(self._args, "default_ams_slot", "auto"),
"auto_leveling": getattr(self._args, "auto_leveling", 1),
"vibration_compensation": getattr(self._args, "vibration_compensation", 0),
@ -2067,6 +2069,7 @@ class EndpointsMixin:
cfg.set("connection", "power_on_url", str(data.get("power_on_url", getattr(self._args, "power_on_url", "") or "")).strip())
cfg.set("connection", "power_off_url", str(data.get("power_off_url", getattr(self._args, "power_off_url", "") or "")).strip())
cfg.set("connection", "power_status_url", str(data.get("power_status_url", getattr(self._args, "power_status_url", "") or "")).strip())
cfg.set("connection", "power_status_inverted", str(int(bool(data.get("power_status_inverted", getattr(self._args, "power_status_inverted", 0))))))
cfg.set("print", "default_ams_slot", str(data.get("default_ams_slot", getattr(self._args, "default_ams_slot", "auto"))))
cfg.set("print", "auto_leveling", str(data.get("auto_leveling", getattr(self._args, "auto_leveling", 1))))
cfg.set("print", "vibration_compensation", str(int(bool(data.get("vibration_compensation", getattr(self._args, "vibration_compensation", 0))))))