Closed JustJoostNL closed 1 year ago
The ready event not being fired was indeed my mistake, but that is fixed now in v2.1.0.
You typically don't have to call discover if you just created the instance. By default it automatically starts discovering when you create the class.
If you want to disable this, you can disable it (in 2.1.0) by doing this:
new Govee.default({
startDiscover: false
});
So this is how your script would look like:
async function goveeControl() {
const Govee = require("govee-lan-control");
const govee = new Govee.default();
console.log("Alright!");
win.webContents.send("log", "Alright!");
govee.on("ready", () => {
console.log("Server and client are ready to go!");
console.log("Connecting to Govee...");
win.webContents.send("log", "Connecting to Govee...");
// You could also put this outside of the ready listener
govee.on("deviceAdded", (device) => {
console.log(device.model);
});
});
}
Thanks for making the issue!
Hey! First I want to thank you for creating this! This is all I needed!
Unfortunately, I get an error when I am using the
govee.discover()
function, this is the error I get back:(node:16484) UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'send')
The error seems something to do with line 420 in your code (index.js)
Line 420 in your code:
udpSocket.send(message, 0, message.length, 4001, "239.255.255.250");
I tried both
govee.discover()
andawait govee.discover()
and both give the same error.I also tried calling it when the ready event was emitted:
But when I use this, only the text "Alright!" is getting outputted, and that one is outside of the 'ready' event, so I guess the 'ready' event is never emitted. Maybe that is a part of the problem.
Again, I really appreciate your work!
Thanks for helping in advance!