Skip to content

Commit 57999a3

Browse files
committed
* extend for --external_source parameter
1 parent 2bdb412 commit 57999a3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

klyqa_ctl/devices/light.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,28 @@ def brightness_message(brightness, transition) -> tuple[str, int]:
341341
transition,
342342
)
343343

344+
def external_source_message(protocol, port, channel):
345+
if (protocol == 0):
346+
protocol_str = "EXT_OFF"
347+
elif (protocol == 1):
348+
protocol_str = "EXT_UDP"
349+
elif (protocol == 2):
350+
protocol_str = "EXT_E131"
351+
elif (protocol == 3):
352+
protocol_str = "EXT_TPM2"
353+
else:
354+
protocol_str = "EXT_OFF"
355+
return json.dumps(
356+
{
357+
"type": "request",
358+
"external": {
359+
"mode": protocol_str,
360+
"port": int(port),
361+
"channel": int(channel)
362+
}
363+
}
364+
)
365+
344366

345367
commands_send_to_bulb: list[str] = [
346368
"request",
@@ -491,6 +513,13 @@ def add_command_args_bulb(parser: argparse.ArgumentParser) -> None:
491513
metavar=("IN", "OUT"),
492514
)
493515

516+
parser.add_argument(
517+
"--external_source",
518+
nargs=3,
519+
metavar=("MODE", "PORT", "CHANNEL"),
520+
help="set external protocol receiver 0=OFF 1=RAWUDP 2=E131 2=TMP2",
521+
)
522+
494523
# parser.add_argument("--loop", help="loop", action="store_true")
495524
parser.add_argument("--WW", help="Warm White", action="store_true")
496525
parser.add_argument("--daylight", help="daylight", action="store_true")
@@ -729,6 +758,10 @@ async def send_ping() -> bool:
729758

730759
if args.request:
731760
local_and_cloud_command_msg({"type": "request"}, 10000)
761+
762+
if args.external_source:
763+
mode, port, channel = args.external_source
764+
local_and_cloud_command_msg(external_source_message(int(mode), port, channel), 0)
732765

733766
if args.enable_tb is not None:
734767
a = args.enable_tb[0]

0 commit comments

Comments
 (0)