Skip to content

Commit 386333a

Browse files
committed
Add docstrings
1 parent 5194aec commit 386333a

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

dingz/dingz.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,19 @@ async def get_light(self) -> None:
136136
self._hour_of_day = response["state"]
137137

138138
async def get_state(self) -> None:
139+
"""Get the state."""
139140
url = URL(self.uri).join(URL(STATE))
140141
response = await make_call(self, uri=url)
141142
self._state = response
142143

143144
async def get_blind_config(self) -> None:
145+
"""Get the configuration of a dingz blind part."""
144146
url = URL(self.uri).join(URL(BLIND_CONFIGURATION))
145147
response = await make_call(self, uri=url)
146148
self._blind_config = response
147149

148150
async def get_system_config(self) -> None:
151+
"""Get the system configuration of a dingz."""
149152
url = URL(self.uri).join(URL(SYSTEM_CONFIG))
150153
response = await make_call(self, uri=url)
151154
self._system_config = response
@@ -169,7 +172,8 @@ async def turn_off(self) -> None:
169172
await make_call(self, uri=url, method="POST", data=data)
170173

171174
async def operate_shade(self, shade_no, blind=None, lamella=None) -> None:
172-
"""operate the lamella and blind
175+
"""Operate the lamella and blind.
176+
173177
blind: 0 fully closed, 100 fully open
174178
lamella: 0 lamellas closed, 100 lamellas open
175179
"""
@@ -186,7 +190,7 @@ async def operate_shade(self, shade_no, blind=None, lamella=None) -> None:
186190

187191
if lamella is None:
188192
if self.is_shade_opened(shade_no):
189-
# if the shade is currently completely opened (i.e. up), the lamella
193+
# If the shade is currently completely opened (i.e. up), the lamella
190194
# value is not really relevant (has no effect). We assume the
191195
# lamella value to be 0, ie. closed.
192196
# i.e. we set lamella to 45, raise blind to the top, and then back down again
@@ -200,24 +204,31 @@ async def operate_shade(self, shade_no, blind=None, lamella=None) -> None:
200204
await make_call(self, uri=url, method="POST", parameters=params)
201205

202206
async def shade_up(self, shade_no) -> None:
207+
"""Move the shade up."""
203208
await self.shade_command(shade_no, "up")
204209

205210
async def shade_down(self, shade_no) -> None:
211+
"""Move the shade down."""
206212
await self.shade_command(shade_no, "down")
207213

208214
async def shade_stop(self, shade_no) -> None:
215+
"""Stop the shade."""
209216
await self.shade_command(shade_no, "stop")
210217

211218
async def lamella_open(self, shade_no) -> None:
219+
"""Open the lamella."""
212220
await self.operate_shade(shade_no, lamella=100)
213221

214222
async def lamella_close(self, shade_no) -> None:
223+
"""Close the lamella."""
215224
await self.operate_shade(shade_no, lamella=0)
216225

217226
async def lamella_stop(self, shade_no) -> None:
227+
"""Stop the lamella."""
218228
await self.shade_stop(shade_no)
219229

220230
async def shade_command(self, shade_no, verb):
231+
"""Create a command for the shade."""
221232
url = URL(self.uri).join(URL("%s/%s/%s" % (SHADE, shade_no, verb)))
222233
await make_call(self, uri=url, method="POST")
223234

@@ -234,6 +245,7 @@ async def stop_timer(self, data) -> None:
234245

235246
@property
236247
def dingz_name(self) -> str:
248+
"""Get the name of a dingz."""
237249
return self._system_config["dingz_name"]
238250

239251
@property
@@ -303,72 +315,91 @@ def intensity(self) -> float:
303315

304316
@property
305317
def version(self) -> str:
318+
"""Return the version of a dingz."""
306319
return self._info["version"]
307320

308321
@property
309322
def type(self) -> str:
323+
"""Return the type of a dingz."""
310324
return self._info["type"]
311325

312326
@property
313327
def mac(self) -> str:
328+
"""Return the MAC address of a dingz."""
314329
return self._info["mac"]
315330

316331
@property
317332
def front_hw_model(self) -> str:
333+
"""Get the hardware model of a dingz."""
318334
return self._device_details["front_hw_model"]
319335

320336
@property
321337
def puck_hw_model(self) -> str:
338+
"""Get the hardware model of a dingz puck."""
322339
return self._device_details["puck_hw_model"]
323340

324341
@property
325-
def front_sn(self) -> str:
342+
def front_serial_number(self) -> str:
343+
"""Get the serial_number of the a dingz front."""
326344
return self._device_details["front_sn"]
327345

328346
@property
329-
def puck_sn(self) -> str:
347+
def puck_serial_number(self) -> str:
348+
"""Get the serial number of a dingz puck."""
330349
return self._device_details["puck_sn"]
331350

332351
@property
333352
def hw_version(self) -> str:
353+
"""Get the hardware version of a dingz."""
334354
return self._device_details["hw_version"]
335355

336356
@property
337357
def fw_version(self) -> str:
358+
"""Get the firmware version of a dingz."""
338359
return self._device_details["fw_version"]
339360

340361
def _shade_current_state(self, shade_no: int):
362+
"""Get the configuration of the shade."""
341363
return self._state["blinds"][shade_no]
342364

343365
def current_blind_level(self, shade_no):
366+
"""Get the current blind level."""
344367
return self._shade_current_state(shade_no)["position"]
345368

346369
def current_lamella_level(self, shade_no):
370+
"""Get the current lamella level."""
347371
return self._shade_current_state(shade_no)["lamella"]
348372

349373
def is_shade_closed(self, shade_no):
350-
# when closed, we care if the lamellas are opened or not
374+
"""Get the closed state of a shade."""
375+
# When closed, we care if the lamellas are opened or not
351376
return (
352377
self.current_blind_level(shade_no) == 0
353378
and self.current_lamella_level(shade_no) == 0
354379
)
355380

356381
def is_shade_opened(self, shade_no):
382+
"""Get the open state of a shade."""
357383
return self.current_blind_level(shade_no) == 100
358384

359385
def is_lamella_closed(self, shade_no):
386+
"""Get the closed state of a lamella."""
360387
return self.current_lamella_level(shade_no) == 0
361388

362389
def is_lamella_opened(self, shade_no):
390+
"""Get the open state of lamella."""
363391
return self.current_lamella_level(shade_no) == 100
364392

365393
def is_blind_opening(self, shade_no):
394+
"""Get the state of the blind if opening."""
366395
return self._shade_current_state(shade_no)["moving"] == "up"
367396

368397
def is_blind_closing(self, shade_no):
398+
"""Get the state of the blind if closing."""
369399
return self._shade_current_state(shade_no)["moving"] == "down"
370400

371401
def blind_name(self, shade_no):
402+
"""Get the name of the blind."""
372403
return self._blind_config["blinds"][shade_no]["name"]
373404

374405
# See "Using Asyncio in Python" by Caleb Hattingh for implementation

0 commit comments

Comments
 (0)