/
example.mjs
48 lines (40 loc) · 1.07 KB
/
example.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2023, Thorsten A. Weintz. All rights reserved.
// Licensed under the MIT license. See LICENSE in the project root for license information.
import TplController from './tpl-controller.mjs';
/**
* String with network identifier.
*/
const network = '192.168.178';
/**
* Array with hosts and passwords of TPL devices.
*/
const devices = [
{ host: 1, pwd: '****' },
{ host: 2, pwd: '****' },
{ host: 3, pwd: '****' },
{ host: 4, pwd: '****' }
];
/**
* Iterates over multiple devices.
*/
for (const device of devices) {
const { host, pwd } = device;
/**
* IP address with network identifier and host.
*/
const ipAddress = `${network}.${host}`;
/**
* Initializes instance of @see TplController.
*/
const tplController = new TplController({
ipAddress, password: pwd
});
/**
* Turns device led on, off or toggle.
*/
const { state } = await tplController.turnLed('toggle');
/**
* Outputs IP address of device and action state.
*/
console.log(ipAddress, state);
}