Skip to content

Commit

Permalink
Merge pull request #42 from iothacker42/rgbw_support
Browse files Browse the repository at this point in the history
Support setting RGBW value in cli
  • Loading branch information
jschlyter authored Oct 12, 2024
2 parents 6044ecb + f36ea06 commit de9a8ad
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ttls/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ 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)))
#match on r,g,b or r,g,b,w
if m := re.match(r"(\d+),(\d+),(\d+)(?:,(\d+))?", args.colour):
r = int(m.group(1))
g = int(m.group(2))
b = int(m.group(3))
#w is optional; convert to int if set
if w := m.group(4):
w = int(w)
c = TwinklyColour(r,g,b,w)
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)
raise ValueError("Colour argument is not in r,g,b or r,g,b,w format")
return await t.set_static_colour(c)


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

0 comments on commit de9a8ad

Please sign in to comment.