Skip to content

Commit 6491d79

Browse files
committed
Update documentation
1 parent 6e5a5c1 commit 6491d79

6 files changed

Lines changed: 102 additions & 20 deletions

File tree

docs/blind.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,51 +60,67 @@ <h2 class="section-title" id="header-classes">Classes</h2>
6060
async def getBatteryLevel(self):
6161
&#34;&#34;&#34;Returns the battery of a blind. We currently don&#39;t know the range or meaning.&#34;&#34;&#34;
6262
value = await self.director.getItemVariableValue(self.item_id, &#34;Battery Level&#34;)
63+
if value is None:
64+
return None
6365
return int(value)
6466

6567
async def getClosing(self):
6668
&#34;&#34;&#34;Returns an indication of whether the blind is moving in the closed direction as a boolean
6769
(True=closing, False=opening). If the blind is stopped, reports the direction it last moved.
6870
&#34;&#34;&#34;
6971
value = await self.director.getItemVariableValue(self.item_id, &#34;Closing&#34;)
72+
if value is None:
73+
return None
7074
return bool(value)
7175

7276
async def getFullyClosed(self):
7377
&#34;&#34;&#34;Returns an indication of whether the blind is fully closed as a boolean
7478
(True=fully closed, False=at least partially open).&#34;&#34;&#34;
7579
value = await self.director.getItemVariableValue(self.item_id, &#34;Fully Closed&#34;)
80+
if value is None:
81+
return None
7682
return bool(value)
7783

7884
async def getFullyOpen(self):
7985
&#34;&#34;&#34;Returns an indication of whether the blind is fully open as a boolean
8086
(True=fully open, False=at least partially closed).&#34;&#34;&#34;
8187
value = await self.director.getItemVariableValue(self.item_id, &#34;Fully Open&#34;)
88+
if value is None:
89+
return None
8290
return bool(value)
8391

8492
async def getLevel(self):
8593
&#34;&#34;&#34;Returns the level (current position) of a blind as an int 0-100.
8694
0 is fully closed and 100 is fully open.
8795
&#34;&#34;&#34;
8896
value = await self.director.getItemVariableValue(self.item_id, &#34;Level&#34;)
97+
if value is None:
98+
return None
8999
return int(value)
90100

91101
async def getOpen(self):
92102
&#34;&#34;&#34;Returns an indication of whether the blind is open as a boolean (True=open, False=closed).
93103
This is true even if the blind is only partially open.&#34;&#34;&#34;
94104
value = await self.director.getItemVariableValue(self.item_id, &#34;Open&#34;)
105+
if value is None:
106+
return None
95107
return bool(value)
96108

97109
async def getOpening(self):
98110
&#34;&#34;&#34;Returns an indication of whether the blind is moving in the open direction as a boolean
99111
(True=opening, False=closing). If the blind is stopped, reports the direction it last moved.
100112
&#34;&#34;&#34;
101113
value = await self.director.getItemVariableValue(self.item_id, &#34;Opening&#34;)
114+
if value is None:
115+
return None
102116
return bool(value)
103117

104118
async def getStopped(self):
105119
&#34;&#34;&#34;Returns an indication of whether the blind is stopped as a boolean
106120
(True=stopped, False=moving).&#34;&#34;&#34;
107121
value = await self.director.getItemVariableValue(self.item_id, &#34;Stopped&#34;)
122+
if value is None:
123+
return None
108124
return bool(value)
109125

110126
async def getTargetLevel(self):
@@ -113,6 +129,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
113129
0 is fully closed and 100 is fully open.
114130
&#34;&#34;&#34;
115131
value = await self.director.getItemVariableValue(self.item_id, &#34;Target Level&#34;)
132+
if value is None:
133+
return None
116134
return int(value)
117135

118136
async def open(self):
@@ -200,6 +218,8 @@ <h3>Methods</h3>
200218
<pre><code class="python">async def getBatteryLevel(self):
201219
&#34;&#34;&#34;Returns the battery of a blind. We currently don&#39;t know the range or meaning.&#34;&#34;&#34;
202220
value = await self.director.getItemVariableValue(self.item_id, &#34;Battery Level&#34;)
221+
if value is None:
222+
return None
203223
return int(value)</code></pre>
204224
</details>
205225
<div class="desc"><p>Returns the battery of a blind. We currently don't know the range or meaning.</p></div>
@@ -217,6 +237,8 @@ <h3>Methods</h3>
217237
(True=closing, False=opening). If the blind is stopped, reports the direction it last moved.
218238
&#34;&#34;&#34;
219239
value = await self.director.getItemVariableValue(self.item_id, &#34;Closing&#34;)
240+
if value is None:
241+
return None
220242
return bool(value)</code></pre>
221243
</details>
222244
<div class="desc"><p>Returns an indication of whether the blind is moving in the closed direction as a boolean
@@ -234,6 +256,8 @@ <h3>Methods</h3>
234256
&#34;&#34;&#34;Returns an indication of whether the blind is fully closed as a boolean
235257
(True=fully closed, False=at least partially open).&#34;&#34;&#34;
236258
value = await self.director.getItemVariableValue(self.item_id, &#34;Fully Closed&#34;)
259+
if value is None:
260+
return None
237261
return bool(value)</code></pre>
238262
</details>
239263
<div class="desc"><p>Returns an indication of whether the blind is fully closed as a boolean
@@ -251,6 +275,8 @@ <h3>Methods</h3>
251275
&#34;&#34;&#34;Returns an indication of whether the blind is fully open as a boolean
252276
(True=fully open, False=at least partially closed).&#34;&#34;&#34;
253277
value = await self.director.getItemVariableValue(self.item_id, &#34;Fully Open&#34;)
278+
if value is None:
279+
return None
254280
return bool(value)</code></pre>
255281
</details>
256282
<div class="desc"><p>Returns an indication of whether the blind is fully open as a boolean
@@ -269,6 +295,8 @@ <h3>Methods</h3>
269295
0 is fully closed and 100 is fully open.
270296
&#34;&#34;&#34;
271297
value = await self.director.getItemVariableValue(self.item_id, &#34;Level&#34;)
298+
if value is None:
299+
return None
272300
return int(value)</code></pre>
273301
</details>
274302
<div class="desc"><p>Returns the level (current position) of a blind as an int 0-100.
@@ -286,6 +314,8 @@ <h3>Methods</h3>
286314
&#34;&#34;&#34;Returns an indication of whether the blind is open as a boolean (True=open, False=closed).
287315
This is true even if the blind is only partially open.&#34;&#34;&#34;
288316
value = await self.director.getItemVariableValue(self.item_id, &#34;Open&#34;)
317+
if value is None:
318+
return None
289319
return bool(value)</code></pre>
290320
</details>
291321
<div class="desc"><p>Returns an indication of whether the blind is open as a boolean (True=open, False=closed).
@@ -304,6 +334,8 @@ <h3>Methods</h3>
304334
(True=opening, False=closing). If the blind is stopped, reports the direction it last moved.
305335
&#34;&#34;&#34;
306336
value = await self.director.getItemVariableValue(self.item_id, &#34;Opening&#34;)
337+
if value is None:
338+
return None
307339
return bool(value)</code></pre>
308340
</details>
309341
<div class="desc"><p>Returns an indication of whether the blind is moving in the open direction as a boolean
@@ -321,6 +353,8 @@ <h3>Methods</h3>
321353
&#34;&#34;&#34;Returns an indication of whether the blind is stopped as a boolean
322354
(True=stopped, False=moving).&#34;&#34;&#34;
323355
value = await self.director.getItemVariableValue(self.item_id, &#34;Stopped&#34;)
356+
if value is None:
357+
return None
324358
return bool(value)</code></pre>
325359
</details>
326360
<div class="desc"><p>Returns an indication of whether the blind is stopped as a boolean
@@ -340,6 +374,8 @@ <h3>Methods</h3>
340374
0 is fully closed and 100 is fully open.
341375
&#34;&#34;&#34;
342376
value = await self.director.getItemVariableValue(self.item_id, &#34;Target Level&#34;)
377+
if value is None:
378+
return None
343379
return int(value)</code></pre>
344380
</details>
345381
<div class="desc"><p>Returns the target level (desired position) of a blind as an int 0-100.

docs/director.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
214214
raise ValueError(&#34;Empty response recieved from Director! The variable {} \
215215
doesn&#39;t seem to exist for item {}.&#34;.format(var_name, item_id))
216216
jsonDictionary = json.loads(data)
217-
return jsonDictionary[0][&#34;value&#34;]
217+
value = jsonDictionary[0][&#34;value&#34;]
218+
if value == &#34;Undefined&#34;:
219+
return None
220+
return value
218221

219222
async def getAllItemVariableValue(self, var_name):
220223
&#34;&#34;&#34;Returns a dictionary with the values of the specified variable
@@ -233,6 +236,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
233236
raise ValueError(&#34;Empty response recieved from Director! The variable {} \
234237
doesn&#39;t seem to exist for any items.&#34;.format(var_name))
235238
jsonDictionary = json.loads(data)
239+
for item in jsonDictionary:
240+
if item.get(&#34;value&#34;) == &#34;Undefined&#34;:
241+
item[&#34;value&#34;] = None
236242
return jsonDictionary
237243

238244
async def getItemCommands(self, item_id):
@@ -397,6 +403,9 @@ <h3>Methods</h3>
397403
raise ValueError(&#34;Empty response recieved from Director! The variable {} \
398404
doesn&#39;t seem to exist for any items.&#34;.format(var_name))
399405
jsonDictionary = json.loads(data)
406+
for item in jsonDictionary:
407+
if item.get(&#34;value&#34;) == &#34;Undefined&#34;:
408+
item[&#34;value&#34;] = None
400409
return jsonDictionary</code></pre>
401410
</details>
402411
<div class="desc"><p>Returns a dictionary with the values of the specified variable
@@ -565,7 +574,10 @@ <h2 id="parameters">Parameters</h2>
565574
raise ValueError(&#34;Empty response recieved from Director! The variable {} \
566575
doesn&#39;t seem to exist for item {}.&#34;.format(var_name, item_id))
567576
jsonDictionary = json.loads(data)
568-
return jsonDictionary[0][&#34;value&#34;]</code></pre>
577+
value = jsonDictionary[0][&#34;value&#34;]
578+
if value == &#34;Undefined&#34;:
579+
return None
580+
return value</code></pre>
569581
</details>
570582
<div class="desc"><p>Returns the value of the specified variable for the
571583
specified item as a string.</p>

docs/fan.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
6969
bool: True if the fan is on, False otherwise.
7070
&#34;&#34;&#34;
7171
value = await self.director.getItemVariableValue(self.item_id, &#34;IS_ON&#34;)
72+
if value is None:
73+
return None
7274
return bool(value)
7375

7476
async def getSpeed(self):
@@ -90,6 +92,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
9092
int: Current fan speed (0–4).
9193
&#34;&#34;&#34;
9294
value = await self.director.getItemVariableValue(self.item_id, &#34;CURRENT_SPEED&#34;)
95+
if value is None:
96+
return None
9397
return int(value)
9498

9599
# ------------------------
@@ -170,6 +174,8 @@ <h3>Methods</h3>
170174
int: Current fan speed (0–4).
171175
&#34;&#34;&#34;
172176
value = await self.director.getItemVariableValue(self.item_id, &#34;CURRENT_SPEED&#34;)
177+
if value is None:
178+
return None
173179
return int(value)</code></pre>
174180
</details>
175181
<div class="desc"><p>Returns the current speed of the fan controller.</p>
@@ -204,6 +210,8 @@ <h2 id="returns">Returns</h2>
204210
bool: True if the fan is on, False otherwise.
205211
&#34;&#34;&#34;
206212
value = await self.director.getItemVariableValue(self.item_id, &#34;IS_ON&#34;)
213+
if value is None:
214+
return None
207215
return bool(value)</code></pre>
208216
</details>
209217
<div class="desc"><p>Returns the current power state of the fan.</p>

docs/light.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ <h2 class="section-title" id="header-classes">Classes</h2>
6262
Will cause an error if called on a non-dimmer switch. Use `getState()` instead.
6363
&#34;&#34;&#34;
6464
value = await self.director.getItemVariableValue(self.item_id, &#34;LIGHT_LEVEL&#34;)
65+
if value is None:
66+
return None
6567
return int(value)
6668

6769
async def getState(self):
6870
&#34;&#34;&#34;Returns the power state of a dimmer or switch as a boolean (True=on, False=off).&#34;&#34;&#34;
6971
value = await self.director.getItemVariableValue(self.item_id, &#34;LIGHT_STATE&#34;)
72+
if value is None:
73+
return None
7074
return bool(value)
7175

7276
async def setLevel(self, level):
@@ -150,6 +154,8 @@ <h3>Methods</h3>
150154
Will cause an error if called on a non-dimmer switch. Use `getState()` instead.
151155
&#34;&#34;&#34;
152156
value = await self.director.getItemVariableValue(self.item_id, &#34;LIGHT_LEVEL&#34;)
157+
if value is None:
158+
return None
153159
return int(value)</code></pre>
154160
</details>
155161
<div class="desc"><p>Returns the level of a dimming-capable light as an int 0-100.
@@ -166,6 +172,8 @@ <h3>Methods</h3>
166172
<pre><code class="python">async def getState(self):
167173
&#34;&#34;&#34;Returns the power state of a dimmer or switch as a boolean (True=on, False=off).&#34;&#34;&#34;
168174
value = await self.director.getItemVariableValue(self.item_id, &#34;LIGHT_STATE&#34;)
175+
if value is None:
176+
return None
169177
return bool(value)</code></pre>
170178
</details>
171179
<div class="desc"><p>Returns the power state of a dimmer or switch as a boolean (True=on, False=off).</p></div>

docs/relay.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
7373
I think this is just used to verify that the relay is functional,
7474
not 100% sure though.
7575
&#34;&#34;&#34;
76-
return bool(
77-
await self.director.getItemVariableValue(self.item_id, &#34;StateVerified&#34;)
78-
)
76+
value = await self.director.getItemVariableValue(self.item_id, &#34;StateVerified&#34;)
77+
if value is None:
78+
return None
79+
return bool(value)
7980

8081
async def open(self):
8182
&#34;&#34;&#34;Set the relay to its open state.
@@ -216,9 +217,10 @@ <h3>Methods</h3>
216217
I think this is just used to verify that the relay is functional,
217218
not 100% sure though.
218219
&#34;&#34;&#34;
219-
return bool(
220-
await self.director.getItemVariableValue(self.item_id, &#34;StateVerified&#34;)
221-
)</code></pre>
220+
value = await self.director.getItemVariableValue(self.item_id, &#34;StateVerified&#34;)
221+
if value is None:
222+
return None
223+
return bool(value)</code></pre>
222224
</details>
223225
<div class="desc"><p>Returns True if Relay is functional.</p>
224226
<h2 id="notes">Notes</h2>

0 commit comments

Comments
 (0)