A wrapper that combines @tuya/tuya-connector-nodejs
and
(@tuyapi/link).manual
(included in this package)
to make registration Just Work™️. Exported as
(@tuyapi/link).wizard
.
(Object
= {}
)
construction options
Name | Description |
---|---|
options.email String
|
user email |
options.password String
|
user password |
options.region String
(default 'us' )
|
region (us=Americas, cn=Asia, eu=Europe) |
options.timezone String
(default 'America/Chicago' )
|
timezone of device in tz format |
options.apiKey String
|
API key |
options.apiSecret String
|
API secret |
options.schema String
|
app schema to register the device under |
// Note: user account does not need to already exist
const register = new TuyaLink.wizard({key: 'your-api-key',
secret: 'your-api-secret',
email: 'example@example.com',
password: 'example-password'});
Links device to WiFi and cloud
(Object
= {}
)
options
Name | Description |
---|---|
options.timeout Number
(default 100 )
|
how long we should wait for devices to connect before throwing an error, in seconds |
options.ssid String
|
the SSID to send to the device |
options.wifiPassword String
(default '' )
|
password for the SSID |
options.devices Number
(default 1 )
|
if linking more than 1 device at a time, set to number of devices being linked |
Promise<Object>
:
A Promise that contains data on device(s)
register.linkDevice({ssid: 'example-ssid',
wifiPassword: 'example-password'}).then(device => {
console.log(device);
});
A lower level option for linking
devices. Use only if you're not generating
a token through @tuyapi/cloud
. Exported
as (@tuyapi/link).manual
.
const register = new TuyaLink.manual();
Thin wrapper for this.sendSmartLinkStart() and this.sendSmartLinkData(). Unless you have a special use case, prefer this method over calling this.sendSmartLinkStart() and this.sendSmartLinkData() directly.
Promise<Undefined>
:
A Promise that resolves when all data has been transmitted
device.registerSmartLink({region: 'AZ',
token: '00000000',
secret: '0101',
ssid: 'Example SSID',
wifiPassword: 'example-password'}).then(() => {
console.log('Done!');
});
Aborts broadcasting UDP packets.
Encodes data as UDP packet lengths.
Array
:
array of packet lengths
Un-references UDP instance so that a script can cleanly exit.