apearson / insteon-plm

Insteon PLM is a TypeScript/JavaScript library for the Insteon PowerLinc Modem family of devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: If both syncLincs and syncInfo are false, the `ready` event doesn't work

PaulWieland opened this issue · comments

If both syncInfo and syncLinks are false, the ready event never fires. If either of them is true, the ready event fires just fine.

	const outlet = [0x2F,0x98,0xA4];
	let myOutlet = await modem.getDeviceInstance(outlet, {debug: true, syncInfo: false, syncLinks: false});
	console.log(`constructor: ${myOutlet.constructor.name}`);

	// This event is never triggered
	myOutlet.once('ready', async () => {
		console.log("Outlet is ready");
	});

This really makes no sense. If you comment out lines 103 - 108 in insteonDevice.ts you get the same behavior where the 'ready' event never fires.

I think this has to do with the function emitting before the constructor is complete. I've added a workaround in c3d4512

Let me know if this solves your problem.