@@ -27,16 +27,16 @@ async def toggle(self, brightness_pct=100):
2727 await self .operate_light (action , brightness_pct )
2828
2929 async def turn_on (self , brightness_pct = 100 ):
30- """ Turn light on.
30+ """Turn light on.
3131 :param brightness_pct: brightness in percent, or None.
3232 """
3333 await self .operate_light ("on" , brightness_pct )
3434
3535 async def turn_off (self ):
36- """ Rurn light off."""
36+ """Rurn light off."""
3737 await self .operate_light ("off" )
3838
39- VALID_OPERATIONS = ('on' , ' off' )
39+ VALID_OPERATIONS = ("on" , " off" )
4040
4141 async def operate_light (self , action , brightness_pct = None ):
4242 """
@@ -46,14 +46,20 @@ async def operate_light(self, action, brightness_pct=None):
4646 :return:
4747 """
4848 if action not in Dimmer .VALID_OPERATIONS :
49- raise ValueError ("invalid action %s, expected one of %s" %
50- (repr (action ), repr (Dimmer .VALID_OPERATIONS )))
49+ raise ValueError (
50+ "invalid action %s, expected one of %s"
51+ % (repr (action ), repr (Dimmer .VALID_OPERATIONS ))
52+ )
5153
5254 if brightness_pct is not None and (brightness_pct > 100 or brightness_pct < 0 ):
53- raise ValueError ("invalid brightness_pct %s, expected value between 0 and 100" %
54- (repr (brightness_pct )))
55-
56- url = URL (self .dingz .uri ).join (URL ("%s/%s/%s" % (DIMMER , self .index_relative , action )))
55+ raise ValueError (
56+ "invalid brightness_pct %s, expected value between 0 and 100"
57+ % (repr (brightness_pct ))
58+ )
59+
60+ url = URL (self .dingz .uri ).join (
61+ URL ("%s/%s/%s" % (DIMMER , self .index_relative , action ))
62+ )
5763 params = {}
5864 if brightness_pct is not None :
5965 params ["value" ] = str (brightness_pct )
@@ -73,18 +79,18 @@ def _consume_state(self, state_details):
7379 :param state_details:
7480 :return:
7581 """
76- assert self .absolute_index == state_details [' index' ][ ' absolute' ]
82+ assert self .absolute_index == state_details [" index" ][ " absolute" ]
7783 self .seen_state = True
78- self .index_relative = state_details [' index' ][ ' relative' ]
79- self .on = state_details ['on' ]
80- self .brightness_pct = state_details [' output' ]
84+ self .index_relative = state_details [" index" ][ " relative" ]
85+ self .on = state_details ["on" ]
86+ self .brightness_pct = state_details [" output" ]
8187
8288 def _consume_config (self , config ):
8389 # "output": "halogen", "name": "Dimmable 3", "feedback": null, "feedback_intensity": 10
84- self .output = config [' output' ]
85- self .enabled = config [' output' ] != ' not_connected'
86- self .dimmable = config [' output' ] != ' non_dimmable'
87- self .name = config [' name' ]
90+ self .output = config [" output" ]
91+ self .enabled = config [" output" ] != " not_connected"
92+ self .dimmable = config [" output" ] != " non_dimmable"
93+ self .name = config [" name" ]
8894
8995
9096class DimmerRegistry (BaseRegistry [Dimmer ]):
0 commit comments