How to use @tuyapi/link - 1 common examples

To help you get started, we’ve selected a few @tuyapi/link examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TuyaAPI / cli / lib / link.js View on Github external
if (options.saveAPI) {
		config.set('apiKey', options.apiKey);
		config.set('apiSecret', options.apiSecret);
	}

	// Set API parameters
	if (!options.apiKey) {
		options.apiKey = config.get('apiKey');
	}

	if (!options.apiSecret) {
		options.apiSecret = config.get('apiSecret');
	}

	// Start linking process
	const link = new TuyaLink({apiKey: options.apiKey,
		apiSecret: options.apiSecret,
		email: 'johndoe@example.com',
		password: 'examplepassword'});

	const spinner = ora('Registering devices(s)...').start();

	try {
		await link.init();

		const devices = await link.linkDevice({ssid: options.ssid, wifiPassword: options.password, devices: options.num});

		spinner.succeed('Device(s) registered!');

		// Save devices to config
		if (options.save) {
			for (const device of devices) {

@tuyapi/link

📡 Effortlessly connect devices to WiFi and the cloud

MIT
Latest version published 3 years ago

Package Health Score

40 / 100
Full package analysis

Popular @tuyapi/link functions