diff --git a/wled_push.py b/wled_push.py index 411badb..f4f5d9c 100644 --- a/wled_push.py +++ b/wled_push.py @@ -54,7 +54,9 @@ def main(): p.add_argument("--on", action="store_true", help="Turn on") p.add_argument("--off", action="store_true", help="Turn off") p.add_argument("--toggle", "-t", action="store_true", dest="toggle", help="Toggle on/off") - p.add_argument("--bri", type=int, metavar="0-255", help="Brightness") + p.add_argument("--bri", type=int, metavar="0-255", help="Global brightness") + p.add_argument("--seg-bri", type=int, metavar="0-255", dest="seg_bri", help="Segment 0 brightness") + p.add_argument("--white", "-w", type=int, metavar="0-255", help="Segment 0 white channel (col[0][3], RGBW)") p.add_argument("--cct", type=int, metavar="0-255", help="Color temp: 0=warm, 255=cool white (segment 0)") p.add_argument("--preset", "-p", type=int, metavar="ID", help="Load preset by ID") p.add_argument("--v", action="store_true", help="Return full state in response") @@ -74,6 +76,31 @@ def main(): payload["on"] = "t" if args.bri is not None: payload["bri"] = max(0, min(255, args.bri)) + if args.seg_bri is not None: + seg_bri = max(0, min(255, args.seg_bri)) + payload.setdefault("seg", []) + seg0 = next((s for s in payload["seg"] if s.get("id") == 0), payload["seg"][0] if payload["seg"] else None) + if seg0 is None: + payload["seg"].insert(0, {"id": 0, "bri": seg_bri}) + else: + seg0["bri"] = seg_bri + if args.white is not None: + w = max(0, min(255, args.white)) + payload.setdefault("seg", []) + seg0 = next((s for s in payload["seg"] if s.get("id") == 0), payload["seg"][0] if payload["seg"] else None) + if seg0 is None: + payload["seg"].insert(0, {"id": 0, "fx": 0, "col": [[0, 0, 0, w], [0, 0, 0, 0], [0, 0, 0, 0]]}) + else: + seg0.setdefault("col", [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) + if len(seg0["col"]) < 1: + seg0["col"] = [[0, 0, 0, w], [0, 0, 0, 0], [0, 0, 0, 0]] + else: + prim = list(seg0["col"][0]) + while len(prim) < 4: + prim.append(0) + prim[3] = w + seg0["col"][0] = prim + seg0["fx"] = 0 # Solid so white channel is visible if args.cct is not None: cct = max(0, min(255, args.cct)) payload.setdefault("seg", [])