Prompt for dimmability; record it in metrics.json

y / n / Enter-if-unknown at the station; only known values are
written, and the scaffolded device page gets a Dimmable spec.
This commit is contained in:
2026-07-09 15:16:46 +07:00
parent cf30182efa
commit b62eac37c6
2 changed files with 11 additions and 3 deletions
+2
View File
@@ -181,6 +181,8 @@ def write_bundle(reading, out_dir, meta, n_readings, supply=None):
if meta.get("type"):
# Lamp technology: led, halogen, cfl, incandescent, ...
metrics["type"] = meta["type"]
if meta.get("dimmable") is not None:
metrics["dimmable"] = meta["dimmable"]
if meta.get("variant"):
metrics["variant"] = meta["variant"]
if meta.get("rated"):
+9 -3
View File
@@ -196,6 +196,8 @@ def scaffold_device_page(web_repo, lamp_id, meta):
specs.append(("EAN", meta["ean"]))
if meta.get("type"):
specs.append(("Type", meta["type"].upper() if meta["type"] in ("led", "cfl") else meta["type"].capitalize()))
if meta.get("dimmable") is not None:
specs.append(("Dimmable", "Yes" if meta["dimmable"] else "No"))
if meta["variant"]:
specs.append(("Variant", meta["variant"]))
if "Power_W" in rated:
@@ -271,6 +273,10 @@ def measure_one(ean, args, data_repo):
model = prompt("Model", model)
lamp_type = prompt("Type (led / halogen / cfl / incandescent / ...)",
previous.get("type", "led")).lower().strip()
prev_dim = previous.get("dimmable")
dim_default = "" if prev_dim is None else ("y" if prev_dim else "n")
dim_raw = prompt("Dimmable? (y / n, Enter if unknown)", dim_default).lower()
dimmable = True if dim_raw.startswith("y") else False if dim_raw.startswith("n") else None
variant = prompt("Variant (e.g. daylight / warm white, Enter if none)",
previous.get("variant", "")).lower()
notes = prompt("Notes", previous.get("notes", "retailer-internal barcode, brand unknown"
@@ -293,9 +299,9 @@ def measure_one(ean, args, data_repo):
"enable": True}
readings, supply = readings_from_device(port, args.readings, False, psu)
reading = average_readings(readings)
meta = {"name": lamp_id, "ean": ean or "", "type": lamp_type, "variant": variant,
"manufacturer": manufacturer, "model": model, "notes": notes,
"rated": rated}
meta = {"name": lamp_id, "ean": ean or "", "type": lamp_type, "dimmable": dimmable,
"variant": variant, "manufacturer": manufacturer, "model": model,
"notes": notes, "rated": rated}
out_dir = data_repo / "lamps" / lamp_id
tm30 = write_bundle(reading, out_dir, meta, len(readings), supply)