Open ctgreybeard opened 5 years ago
I've condensed my program to what I think should be a correct 'minimum' but it does not work:
/*
* Test home-controller linking
*/
var Insteon = require("home-controller").Insteon;
var hub = new Insteon();
var util = require("util");
hub.serial("/dev/ttyS4", () => {
console.log("Hub connected");
hub.on("close", () => {
console.log("Hub closed.");
});
hub.link('gw', '0B5B8F', function (err, link) {
console.log("Err: %s, Link:\n%s", err, util.inspect(link));
hub.close();
});
});
The error I receive is:
╰─➤ node linktest.js 1 ↵
Hub connected
(node:14401) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toString' of undefined
at toByte (/home/debian/Projects/superlinker/node_modules/home-controller/lib/Insteon/utils.js:105:17)
at link (/home/debian/Projects/superlinker/node_modules/home-controller/lib/Insteon/index.js:1131:9)
at Insteon.link (/home/debian/Projects/superlinker/node_modules/home-controller/lib/Insteon/index.js:1084:15)
at hub.serial (/home/debian/Projects/superlinker/linktest.js:15:7)
at SerialPort.<anonymous> (/home/debian/Projects/superlinker/node_modules/home-controller/lib/Insteon/index.js:142:32)
at SerialPort.emit (events.js:202:15)
at binding.open.then (/home/debian/Projects/superlinker/node_modules/serialport/lib/serialport.js:234:10)
(node:14401) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14401) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have been digging farther and once I use a single Insteon address for link() it completes but with varying results. I believe that my older (some are quite old) devices don't link using this. I'm going to see if I can find out what the differences might be.
It is very possible that older devices do not support full range of Insteon messages/API.
I personally always link devices using the physical buttons.
I'm confused about the link API and the examples given.
The API says
insteon.link([device,] [options,] [callback])
An example shows
insteon.link('AABBCC', '112233', {group: 2}, function(error, link) {...
The API only has one
device
, the example shows two.I am trying to link two devices, one may be the gateway, what is the proper form of the link? I believe I may use "gw" for the gateway but in many case the gateway isn't one of the devices being linked.
My code has:
but I get an error:
In this case I was trying to link
gw->0D3158