diff --git a/lamp_export.py b/lamp_export.py index 9ba949c..c368d16 100644 --- a/lamp_export.py +++ b/lamp_export.py @@ -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"): diff --git a/lamp_station.py b/lamp_station.py index 79ae089..04ec45e 100644 --- a/lamp_station.py +++ b/lamp_station.py @@ -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)