A drastic change of gx, which is made by turning the magic wand dramatically, will turn the Phillips Hue on / off.
We're using the south office couch LED light no. 3 to experiment.
All the controls happen in the same server.js that controls the drawing cursor in the frontend. I added the function updatePhillipsLight to map the magic wand input to HTTP call that is understandable by the Phillips Hue.function updatePhillipsLight(parsed, mousePos =null) {
if (!address||!username) {
console.log('Please enter an address and username');return;
}
if (!parsed?.sensor) return null;
const data=parsed.sensor;
// Phillips Hue power control by hard flick of the wand (gx spike) with debounce
const now = Date.now();
if (Math.abs(data.gx) >PHILLIPS_POWER_GX_THRESHOLD) {
if (now-lastPhillipsToggle>3000) {
// 3 seconds debouncelightState.on=!lightState.on;
lastPhillipsToggle=now;
deletelightState.bri; // avoid errors when turning off
deletelightState.hue; } }
// mouse pos x: map to hue, y: map to brightness
if (mousePos) {if (lightState.on) {
// only change hue & brightness if phillips power is already on
// hue: 0-65535, bri: 0-254
lightState.hue=Math.round((mousePos.x/clientScreenSize.width) *65535);
lightState.bri=Math.round((1-mousePos.y/clientScreenSize.height) *254); }
}
// send the request
setLight(lightNumber, lightState);
}
The x axis (horizontal) is mapped from the screen width size of the frontend (left to right, 0-xxx) to hue: 0-65535 (0-360 deg of hue in the Phillips world).
The y axis (vertical) is mapped from the screen height size of the frontend (bottom to top, 0-xxx) to bri: 0-100.
Elizabeth Kezia Widjaja © 2026 🙂