Record lamp technology type (led / halogen / cfl / ...)

Station prompts for it (default led), metrics.json carries it as
'type', and the scaffolded device page description and Type spec
follow it.
This commit is contained in:
2026-07-09 14:44:31 +07:00
parent 817822594c
commit fad8ec0813
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -178,6 +178,9 @@ def write_bundle(reading, out_dir, meta, n_readings, supply=None):
metrics = {"name": meta["name"]}
if meta.get("ean"):
metrics["ean"] = meta["ean"]
if meta.get("type"):
# Lamp technology: led, halogen, cfl, incandescent, ...
metrics["type"] = meta["type"]
if meta.get("variant"):
metrics["variant"] = meta["variant"]
if meta.get("rated"):
+7 -2
View File
@@ -194,6 +194,8 @@ def scaffold_device_page(web_repo, lamp_id, meta):
specs = [("ID", lamp_id)]
if meta["ean"]:
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["variant"]:
specs.append(("Variant", meta["variant"]))
if "Power_W" in rated:
@@ -210,11 +212,12 @@ def scaffold_device_page(web_repo, lamp_id, meta):
if "lifetime_h" in rated:
specs.append(("Rated lifetime", f"{rated['lifetime_h']:,} h".replace(",", " ")))
type_word = {"led": "LED", "cfl": "CFL"}.get(meta.get("type", "led"), meta.get("type", "LED"))
lines = ["---", f'title: "{title}"']
if meta["manufacturer"]:
lines.append(f'manufacturer: "{meta["manufacturer"]}"')
lines += [
'description: "Household LED lamp, measured in our integrating sphere."',
f'description: "Household {type_word} lamp, measured in our integrating sphere."',
f'csv: "/data/comparisons/lamps/{lamp_id}/spd.csv"',
"specs:",
*[f' - {{ label: "{k}", value: "{v}" }}' for k, v in specs],
@@ -265,6 +268,8 @@ def measure_one(ean, args, data_repo):
manufacturer = prompt("Manufacturer", manufacturer)
model = prompt("Model", model)
lamp_type = prompt("Type (led / halogen / cfl / incandescent / ...)",
previous.get("type", "led")).lower().strip()
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"
@@ -287,7 +292,7 @@ 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 "", "variant": variant,
meta = {"name": lamp_id, "ean": ean or "", "type": lamp_type, "variant": variant,
"manufacturer": manufacturer, "model": model, "notes": notes,
"rated": rated}
out_dir = data_repo / "lamps" / lamp_id