Skip to content

Commit

Permalink
Support setting RGBW value in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
iothacker42 authored Oct 10, 2024
1 parent 88d75d4 commit 07297da
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ttls/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ async def command_movie(t: Twinkly, args: argparse.Namespace):

async def command_static(t: Twinkly, args: argparse.Namespace):
await t.interview()
m = re.match(r"(\d+),(\d+),(\d+)", args.colour)
if m is not None:
rgb = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
if m := re.match(r"(\d+),(\d+),(\d+),(\d+)", args.colour):
rgbw = (int(m.group(1)), int(m.group(2)), int(m.group(3)), int(m.group(4)))
elif m := re.match(r"(\d+),(\d+),(\d+)", args.colour):
rgbw = (int(m.group(1)), int(m.group(2)), int(m.group(3)), None)
else:
c = TwinklyColour(args.colour)
rgb = (int(c.red * 255), int(c.green * 255), int(c.blue * 255))
return await t.set_static_colour(rgb)
rgbw = (int(c.red * 255), int(c.green * 255), int(c.blue * 255), None)
return await t.set_static_colour(rgbw)


async def command_summary(t: Twinkly, args: argparse.Namespace):
Expand Down

0 comments on commit 07297da

Please sign in to comment.