Skip to content

Commit

Permalink
Add schema functionality and move helper functions to lib/helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Feb 27, 2019
1 parent 31a0cab commit 8a00919
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 139 deletions.
150 changes: 41 additions & 109 deletions docs/index.html
Expand Up @@ -3,12 +3,12 @@
<head>
<meta charset='utf-8' />
<title>tuyapi 4.0.3 | Documentation</title>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
<link href='assets/style.css' type='text/css' rel='stylesheet' />
<link href='assets/github.css' type='text/css' rel='stylesheet' />
<link href='assets/split.css' type='text/css' rel='stylesheet' />
<meta name='description' content='An easy-to-use API for devices that use Tuya&#39;s cloud services'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet' />
<link href='assets/style.css' rel='stylesheet' />
<link href='assets/github.css' rel='stylesheet' />
<link href='assets/split.css' rel='stylesheet' />
</head>
<body class='documentation m0'>
<div class='flex'>
Expand Down Expand Up @@ -192,10 +192,7 @@ <h3 class='fl m0' id='tuyadevice'>
you're experiencing problems when only passing
one, try passing both if possible.</p>



<div class='pre p1 fill-light mt0'>new TuyaDevice(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>



<p>
Expand All @@ -219,7 +216,8 @@ <h3 class='fl m0' id='tuyadevice'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>{}</code>)</code>

</div>

Expand Down Expand Up @@ -311,6 +309,14 @@ <h3 class='fl m0' id='tuyadevice'>



<tr>
<td class='break-word'><span class='code bold'>options.schema</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>



</tbody>
</table>

Expand Down Expand Up @@ -344,7 +350,7 @@ <h3 class='fl m0' id='tuyadevice'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>get(options?)</span>
<span class='code strong strong truncate'>get(options = {})</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
Expand All @@ -355,10 +361,7 @@ <h3 class='fl m0' id='tuyadevice'>
<p>Gets a device's current status.
Defaults to returning only the value of the first DPS index.</p>



<div class='pre p1 fill-light mt0'>get(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)></div>




Expand All @@ -375,7 +378,8 @@ <h3 class='fl m0' id='tuyadevice'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?
= <code>{}</code>)</code>

</div>

Expand Down Expand Up @@ -475,10 +479,7 @@ <h3 class='fl m0' id='tuyadevice'>

<p>Sets a property on a device.</p>



<div class='pre p1 fill-light mt0'>set(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>></div>




Expand Down Expand Up @@ -625,10 +626,7 @@ <h3 class='fl m0' id='tuyadevice'>
<p>Connects to the device. Can be called even
if device is already connected.</p>



<div class='pre p1 fill-light mt0'>connect(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>></div>




Expand Down Expand Up @@ -683,10 +681,7 @@ <h3 class='fl m0' id='tuyadevice'>
<p>Disconnects from the device, use to
close the socket and exit gracefully.</p>



<div class='pre p1 fill-light mt0'>disconnect()</div>




Expand Down Expand Up @@ -731,10 +726,7 @@ <h3 class='fl m0' id='tuyadevice'>

<p>Returns current connection status to device.</p>



<div class='pre p1 fill-light mt0'>isConnected(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></div>




Expand Down Expand Up @@ -790,10 +782,7 @@ <h3 class='fl m0' id='tuyadevice'>





<div class='pre p1 fill-light mt0'>resolveId(options: any)</div>




Expand Down Expand Up @@ -842,7 +831,7 @@ <h3 class='fl m0' id='tuyadevice'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>find(options?)</span>
<span class='code strong strong truncate'>find(options = {})</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
Expand All @@ -854,10 +843,7 @@ <h3 class='fl m0' id='tuyadevice'>
If you didn't pass an ID or IP to the constructor,
you must call this before anything else.</p>



<div class='pre p1 fill-light mt0'>find(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>)></div>




Expand All @@ -874,7 +860,8 @@ <h3 class='fl m0' id='tuyadevice'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?
= <code>{}</code>)</code>

</div>

Expand All @@ -892,21 +879,23 @@ <h3 class='fl m0' id='tuyadevice'>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.all</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>?</code>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>

(default <code>10</code>)
</td>
<td class='break-word'><span>true to return array of all found devices
<td class='break-word'><span>how long, in seconds, to wait for device
to be resolved before timeout error is thrown
</span></td>
</tr>



<tr>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
<td class='break-word'><span class='code bold'>options.all</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>?</code>

(default <code>10</code>)
(default <code>false</code>)
</td>
<td class='break-word'><span>how long, in seconds, to wait for device
to be resolved before timeout error is thrown
<td class='break-word'><span>true to return array of all found devices
</span></td>
</tr>

Expand Down Expand Up @@ -966,10 +955,7 @@ <h3 class='fl m0' id='tuyadevice'>

<p>Toggles a boolean property.</p>



<div class='pre p1 fill-light mt0'>toggle(property: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>></div>




Expand Down Expand Up @@ -1030,6 +1016,7 @@ <h3 class='fl m0' id='tuyadevice'>

</section>




<div class='keyline-top-not py2'>
Expand All @@ -1046,50 +1033,6 @@ <h2 id='events' class='mt0'>
</section>
</div>

<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='events'>
Events
</h3>


</div>


<p>Events that TuyAPI emits.</p>




























</section>



<section class='p2 mb2 clearfix bg-white minishadow'>
Expand All @@ -1109,10 +1052,7 @@ <h3 class='fl m0' id='eventtuyadeviceerror'>
result of a connection timeout.
Also emitted on parsing errors.</p>



<div class='pre p1 fill-light mt0'>TuyaDevice#error</div>




Expand Down Expand Up @@ -1152,6 +1092,7 @@ <h3 class='fl m0' id='eventtuyadeviceerror'>

</section>




<section class='p2 mb2 clearfix bg-white minishadow'>
Expand All @@ -1169,10 +1110,7 @@ <h3 class='fl m0' id='eventtuyadevicedata'>

<p>Emitted when data is returned from device.</p>



<div class='pre p1 fill-light mt0'>TuyaDevice#data</div>




Expand Down Expand Up @@ -1220,6 +1158,7 @@ <h3 class='fl m0' id='eventtuyadevicedata'>

</section>




<section class='p2 mb2 clearfix bg-white minishadow'>
Expand All @@ -1241,10 +1180,7 @@ <h3 class='fl m0' id='eventtuyadevicedisconnected'>
at the same time if, for example, the device
goes off the network.</p>



<div class='pre p1 fill-light mt0'>TuyaDevice#disconnected</div>




Expand Down Expand Up @@ -1272,6 +1208,7 @@ <h3 class='fl m0' id='eventtuyadevicedisconnected'>

</section>




<section class='p2 mb2 clearfix bg-white minishadow'>
Expand All @@ -1293,10 +1230,7 @@ <h3 class='fl m0' id='eventtuyadeviceconnected'>
so don't use this as a trigger for your
initialization code.</p>



<div class='pre p1 fill-light mt0'>TuyaDevice#connected</div>




Expand Down Expand Up @@ -1324,6 +1258,7 @@ <h3 class='fl m0' id='eventtuyadeviceconnected'>

</section>




<section class='p2 mb2 clearfix bg-white minishadow'>
Expand All @@ -1339,13 +1274,10 @@ <h3 class='fl m0' id='parse'>
</div>


<p>Static wrapper for lower-level MessageParser
functions to easily parse packets.</p>
<p>Parse a packet from a device into a
payload and command type</p>



<div class='pre p1 fill-light mt0'>parse(data: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>




Expand Down Expand Up @@ -1407,6 +1339,7 @@ <h3 class='fl m0' id='parse'>

</section>




<section class='p2 mb2 clearfix bg-white minishadow'>
Expand All @@ -1422,13 +1355,11 @@ <h3 class='fl m0' id='encode'>
</div>


<p>Static wrapper for lower-level MessageParser
functions to easily encode packets</p>
<p>Encode data (usually an object) into
a protocol-compliant form that a device
can understand.</p>



<div class='pre p1 fill-light mt0'>encode(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://nodejs.org/api/buffer.html">Buffer</a></div>




Expand Down Expand Up @@ -1511,6 +1442,7 @@ <h3 class='fl m0' id='encode'>

</section>



</div>
</div>
Expand Down

0 comments on commit 8a00919

Please sign in to comment.