-
Notifications
You must be signed in to change notification settings - Fork 8
Using this in a nodeAPI #6
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I am trying to get this module to work in a nodeAPI, so i can use the hue entertainment api in python via this api of mine, now i am kinda running into a lot of problems, mainly that the lights don't change color or do anything at all:
i have this connect function:
router.get('/connect', async (req, res) => {
try {
let options = {
address: '192.168.1.233',
username: 'oyCbaYTEWX9QJ1X4UJNp4LZIDPa0lA6TPuwXhzc9',
psk: 'B1E654E9E1BD7D761CCD6841D590B94E'
};
running = true;
bridge = await Phea.bridge(options);
console.log(bridge);
res.send('Connected');
} catch (err) {
console.error(err.message);
res.status(500).send('Server Error');
}
});
which works fine, i removed the let before the bridge = await Phea.bridge(options);, so it can be used in different fucntions
i got a start and a stop function, stop just runs brige.stop and stops the loop which is running in basicExample (your example):
async function basicExample() {
let groupId = 5;
let transitionTime = 1000; // milliseconds
await bridge.start(groupId);
while (running) {
let color = [
// Generate Random RGB Color Array
Math.floor(55 + Math.random() * Math.floor(200)),
Math.floor(55 + Math.random() * Math.floor(200)),
Math.floor(55 + Math.random() * Math.floor(200))
];
// Set all lights to random color.
bridge.transition(0, color, transitionTime);
console.log(color);
// Sleep until next color update is needed.
await new Promise(resolve => setTimeout(resolve, transitionTime));
}
}
so bassically it does nothing whith the lights at all, it does change the stream to active, but doesn't change any lights.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working