JavaScript and Node.js
JavaScript is a good fit
If kuandoHUB is installed on the target machine, JavaScript and Node.js are straightforward ways to control the Busylight.
1. Browser JavaScript with GET​
This is the simplest possible test:
<button id="busy">Busy</button>
<button id="free">Free</button>
<button id="off">Off</button>
<script>
const baseUrl = 'http://localhost:8989';
async function setLight(query) {
const response = await fetch(`${baseUrl}?${query}`);
if (!response.ok) {
throw new Error(`Busylight request failed: ${response.status}`);
}
}
document.getElementById('busy').addEventListener('click', () => {
setLight('action=light&red=100');
});
document.getElementById('free').addEventListener('click', () => {
setLight('action=light&green=100');
});
document.getElementById('off').addEventListener('click', () => {
setLight('action=off');
});
</script>
This works well for local internal tools where browser access to localhost is acceptable.
2. Node.js helper​
const baseUrl = 'http://localhost:8989';
async function setColor({ red = 0, green = 0, blue = 0 }) {
const url = new URL(baseUrl);
url.searchParams.set('action', 'light');
url.searchParams.set('red', String(red));
url.searchParams.set('green', String(green));
url.searchParams.set('blue', String(blue));
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Busylight error: ${response.status}`);
}
}
async function main() {
await setColor({ red: 100, green: 40, blue: 0 });
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
3. Structured POST request​
const baseUrl = 'http://localhost:8989';
async function postLight({ red = 0, green = 0, blue = 0 }) {
const body = {
action: 'Light',
sender: 'SDK',
eventtype: 'Light',
eventname: 'Color',
parameter: JSON.stringify({
RedRgbValue: red,
GreenRgbValue: green,
BlueRgbValue: blue,
}),
};
const response = await fetch(baseUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error(`Busylight POST failed: ${response.status}`);
}
}
4. Register your app as a source​
For a more integrated setup, register a data source once during startup:
async function registerDataSource() {
const body = {
action: 'RegisterDataSource',
sender: null,
eventtype: null,
eventname: null,
parameter: JSON.stringify({
DataSourceName: 'MyDashboard',
eventnames: {
Light: {
EventNames: ['Green', 'Yellow', 'Red', 'Off'],
IsAlertPriority: false,
},
Alert: {
EventNames: ['Alert'],
IsAlertPriority: true,
},
},
}),
};
await fetch('http://localhost:8989', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
}
Then create an initial priority entry if you want kuandoHUB to treat that source as part of its priority model.
5. Good JavaScript use cases​
- Electron helper apps
- local dashboards
- support or NOC panels
- browser-based internal tools
- webhook-to-Busylight bridges
- Teams, CRM, or ticketing overlays
6. Important caveat​
The public manual includes an old XMLHttpRequest sample. Prefer fetch in modern code unless you specifically need to match a legacy environment.