@@ -47,9 +47,15 @@ class ColorName(IntEnum):
4747 hsl : tuple [int , int , int ] | None = None
4848
4949 # Methods
50- @method ("SetRGB" , "SetRGBSW" )
50+ @method ("SetRGB" , "SetRGBSW" , "SetRGBFollowLevel" )
5151 async def set_rgb (
52- self , red : int = 255 , green : int = 255 , blue : int = 255 , * , sw : bool = False
52+ self ,
53+ red : int = 255 ,
54+ green : int = 255 ,
55+ blue : int = 255 ,
56+ * ,
57+ sw : bool = False ,
58+ follow_level : bool = False ,
5359 ) -> None :
5460 """Set the color of an RGB load.
5561
@@ -58,12 +64,21 @@ async def set_rgb(
5864 green: The green value of the color, (0-255)
5965 blue: The blue value of the color, (0-255)
6066 sw: Set the cached value instead of the hardware value.
67+ follow_level: Follow the level of the load.
6168 """
6269 # INVOKE <id> RGBLoad.SetRGB <red> <green> <blue>
6370 # -> R:INVOKE <id> <rcode> RGBLoad.SetRGB <red> <green> <blue>
64- await self .invoke (
65- "RGBLoad.SetRGBSW" if sw else "RGBLoad.SetRGB" , red , green , blue
66- )
71+ if follow_level and sw :
72+ raise ValueError ("Cannot set both follow_level and sw" )
73+
74+ if follow_level :
75+ method = "RGBLoad.SetRGBFollowLevel"
76+ elif sw :
77+ method = "RGBLoad.SetRGBSW"
78+ else :
79+ method = "RGBLoad.SetRGB"
80+
81+ await self .invoke (method , red , green , blue )
6782
6883 @method ("GetRGB" , "GetRGBHW" )
6984 async def get_rgb (self , channel : RGBChannel , * , hw : bool = False ) -> int :
@@ -123,9 +138,15 @@ async def get_hsl(self, attribute: HSLAttribute, *, hw: bool = False) -> int:
123138 "RGBLoad.GetHSLHW" if hw else "RGBLoad.GetHSL" , attribute
124139 )
125140
126- @method ("DissolveRGB" )
141+ @method ("DissolveRGB" , "DissolveRGBFollowLevel" )
127142 async def dissolve_rgb (
128- self , red : int , green : int , blue : int , rate : float | Decimal
143+ self ,
144+ red : int ,
145+ green : int ,
146+ blue : int ,
147+ rate : float | Decimal ,
148+ * ,
149+ follow_level : bool = False ,
129150 ) -> None :
130151 """Transition the color of an RGB load over a number of seconds.
131152
@@ -134,10 +155,16 @@ async def dissolve_rgb(
134155 green: The new green value of the color, (0-255)
135156 blue: The new blue value of the color, (0-255)
136157 rate: The number of seconds the transition should take.
158+ follow_level: Follow the level of the load.
137159 """
138160 # INVOKE <id> RGBLoad.DissolveRGB <red> <green> <blue> <rate>
139161 # -> R:INVOKE <id> <rcode> RGBLoad.DissolveRGB <red> <green> <blue> <rate>
140- await self .invoke ("RGBLoad.DissolveRGB" , red , green , blue , rate )
162+ if follow_level :
163+ method = "RGBLoad.DissolveRGBFollowLevel"
164+ else :
165+ method = "RGBLoad.DissolveRGB"
166+
167+ await self .invoke (method , red , green , blue , rate )
141168
142169 @method ("DissolveHSL" )
143170 async def dissolve_hsl (
@@ -387,7 +414,7 @@ async def get_color(self, *, hw: bool = False) -> int:
387414 # -> R:INVOKE <id> <color> RGBLoad.GetColor
388415 return await self .invoke ("RGBLoad.GetColorHW" if hw else "RGBLoad.GetColor" )
389416
390- @method ("SetRGBW" , "SetRGBWSW" )
417+ @method ("SetRGBW" , "SetRGBWSW" , "SetRGBWFollowLevel" )
391418 async def set_rgbw (
392419 self ,
393420 red : int = 255 ,
@@ -396,6 +423,7 @@ async def set_rgbw(
396423 white : int = 255 ,
397424 * ,
398425 sw : bool = False ,
426+ follow_level : bool = False ,
399427 ) -> None :
400428 """Set the color of an RGBW load.
401429
@@ -405,12 +433,21 @@ async def set_rgbw(
405433 blue: The blue value of the color, (0-255)
406434 white: The white value of the color, (0-255)
407435 sw: Set the cached value instead of the hardware value.
436+ follow_level: Follow the level of the load.
408437 """
409438 # INVOKE <id> RGBLoad.SetRGBW <red> <green> <blue> <white>
410439 # -> R:INVOKE <id> <rcode> RGBLoad.SetRGBW <red> <green> <blue> <white>
411- await self .invoke (
412- "RGBLoad.SetRGBWSW" if sw else "RGBLoad.SetRGBW" , red , green , blue , white
413- )
440+ if follow_level and sw :
441+ raise ValueError ("Cannot set both follow_level and sw" )
442+
443+ if follow_level :
444+ method = "RGBLoad.SetRGBWFollowLevel"
445+ elif sw :
446+ method = "RGBLoad.SetRGBWSW"
447+ else :
448+ method = "RGBLoad.SetRGBW"
449+
450+ await self .invoke (method , red , green , blue , white )
414451
415452 @method ("GetRGBW" , "GetRGBWHW" )
416453 async def get_rgbw (self , channel : int , * , hw : bool = False ) -> int :
@@ -440,6 +477,36 @@ async def get_transition_level(self) -> Decimal:
440477 # -> R:INVOKE <id> <level> RGBLoad.GetTransitionLevel
441478 return await self .invoke ("RGBLoad.GetTransitionLevel" )
442479
480+ @method ("DissolveRGBW" , "DissolveRGBWFollowLevel" )
481+ async def dissolve_rgbw (
482+ self ,
483+ red : int ,
484+ green : int ,
485+ blue : int ,
486+ white : int ,
487+ rate : float | Decimal ,
488+ * ,
489+ follow_level : bool = False ,
490+ ) -> None :
491+ """Transition the color of an RGBW load over a number of seconds.
492+
493+ Args:
494+ red: The new red value of the color, (0-255)
495+ green: The new green value of the color, (0-255)
496+ blue: The new blue value of the color, (0-255)
497+ white: The new white value of the color, (0-255)
498+ rate: The number of seconds the transition should take.
499+ follow_level: Follow the level of the load.
500+ """
501+ # INVOKE <id> RGBLoad.DissolveRGBW <red> <green> <blue> <white> <rate>
502+ # -> R:INVOKE <id> <rcode> RGBLoad.DissolveRGBW <red> <green> <blue> <white> <rate>
503+ if follow_level :
504+ method = "RGBLoad.DissolveRGBWFollowLevel"
505+ else :
506+ method = "RGBLoad.DissolveRGBW"
507+
508+ await self .invoke (method , red , green , blue , white , rate )
509+
443510 # Convenience functions, not part of the interface
444511 async def get_rgb_color (self ) -> tuple [int , int , int ]:
445512 """Get the RGB color of a load from the controller.
0 commit comments