JavaScript Examples
Lua API
Only supported in NodeJs
Control task execution by sending Lua API to TCP port 5180
const net = require('node:net');
async function run() {
let client = net.connect(5180, "127.0.0.1");
client.on("data", (data) => { console.log(data.toString()) });
client.write("scene(10087)");
}
run();
SDK
Control task execution by downloading and installing the SDK
NodeJs
let lebai_sdk = require("./lebai_sdk.js");
global.WebSocket = require("ws");
async function run() {
let lebai = await lebai_sdk.connect("127.0.0.1", false);
await lebai.start_sys();
await lebai.start_task("10087", null, null, false, 1);
}
run();
Web
<html>
<body>
<script type="module">
import init, * as lebai_sdk from './lebai_sdk.js';
async function run() {
await init();
let lebai = await lebai_sdk.connect("127.0.0.1", true);
await lebai.start_sys();
await lebai.start_task("10087", null, null, false, 1);
}
run();
</script>
</body>
</html>