Snap volume to whole steps, and hide deleted AVR sources

A tap now moves to the next multiple of VOLUME_STEP rather than adding
it, so 23 goes to 25 and 25 goes to 30 and the levels stay round. The
panel counts taps and lets the speakers do the rounding from whatever
level they are actually at, since the phone's copy can be seconds old;
the same rule is mirrored in JS so the optimistic number never has to
correct itself when the reply lands.

The input picker also asks the AVR which sources are still switched on
(SSSOD ?) and leaves out the ones deleted in its setup menu. Sources it
does not mention are kept, so a model that ignores the command shows its
whole list rather than nothing; deleted sources also keep their names, in
case the AVR is sitting on one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-14 21:39:31 +02:00
co-authored by Claude Opus 5
parent 4affd18b3b
commit 1a1fcc84d6
9 changed files with 198 additions and 33 deletions
+14 -5
View File
@@ -112,9 +112,12 @@ def api_volume():
key = _target_from(data)
if data.get("level") is not None:
return jsonify({"target": key, "level": controller.set_volume(key, int(data["level"]))})
if data.get("steps") is not None:
# Taps, not points: each one lands on the next multiple of VOLUME_STEP.
return jsonify({"target": key, "level": controller.step_volume(key, int(data["steps"]))})
if data.get("delta") is not None:
return jsonify({"target": key, "level": controller.nudge_volume(key, int(data["delta"]))})
raise ValueError("Provide either 'delta' or 'level'")
raise ValueError("Provide one of 'steps', 'delta' or 'level'")
@app.post("/api/mute")
@@ -195,15 +198,21 @@ def legacy_set_volume():
@app.post("/volume/up")
@handle_errors
def legacy_volume_up():
step = request.args.get("step", default=config.VOLUME_STEP, type=int)
return jsonify({"level": controller.nudge_volume(_target_from(request.args), step)})
key = _target_from(request.args)
step = request.args.get("step", type=int)
# No ?step= means one tap of the panel's own button, snapping to the
# next multiple; an explicit ?step= stays a raw number of points.
level = controller.step_volume(key, 1) if step is None else controller.nudge_volume(key, step)
return jsonify({"level": level})
@app.post("/volume/down")
@handle_errors
def legacy_volume_down():
step = request.args.get("step", default=config.VOLUME_STEP, type=int)
return jsonify({"level": controller.nudge_volume(_target_from(request.args), -step)})
key = _target_from(request.args)
step = request.args.get("step", type=int)
level = controller.step_volume(key, -1) if step is None else controller.nudge_volume(key, -step)
return jsonify({"level": level})
@app.post("/volume/mute")