Alright, so I did a little digging into that code. It will not work because the Lan messages are not sent to apps as location events. It appears that ST implemented a 2nd way for Lan messages to processed by the system, although I've never seen that used until now. The App is subscribing to all location events and it is expecting any incoming Lan messages to be sent as location events, HE does not do that so you will never see those messages.
You have two options.
Option 1: the App can create a child device with the DNI set to the mac address or ip address of the nodejs server, and that child device will receive the messages that the nodejs server is sending to port 39501.
Option 2: the Hubitat App creates endpoint mappings that the nodejs can send the messages to, this would require that you enable OAuth on that App and then generate an access token for the nodejs app to use to talk to the Hubitat App.
I would recommend option 1, it will be easier than setting up endpoints and passing the token to the nodejs app.
Here is some test code I created just now to see if the request.put worked:
nodejs app: (note that my hub ip was hard coded)
var request = require('request');
var data = {
module: 'myModule',
id: 'myDeviceId'
};
request.put({
url: 'http://' + '192.168.1.161' + ':' + '39501' + '/event',
headers: {
'Content-Type': 'application/json'
},
json: true,
body: {
event: 'event',
data: data
}
},
function (err, response, body) {
if (err) {
log({ error: 'Failed sending event: ' + err });
}
});
device driver:
/*
Copyright 2018 Hubitat, Inc. All Rights Reserved
*/
metadata {
definition(name: "testIncomingLanMessage", namespace: "hubitat", author: "cschwer") {
capability "Sensor"
}
}
def installed() {}
def uninstalled() {}
def parse(String description) {
log.debug description
}
The DNI of my device was set to the ip address of my laptop that I was running nodejs on:
and the log debug message from the logging page:
debug mac:, ip:c0a801b3, port:eb42, headers:UFVUIC9ldmVudCBIVFRQLzEuMQ0KQ29ubmVjdGlvbjogY2xvc2UNCkhvc3Q6IDE5Mi4xNjguMS4xNzk6Mzk1MDENCkFjY2VwdDogYXBwbGljYXRpb24vanNvbg0KQ29udGVudC1MZW5ndGg6IDY0DQpDb250ZW50LVR5cGU6IGFwcGxpY2F0aW9uL2pzb24NCg==, body:eyJldmVudCI6ImV2ZW50IiwiZGF0YSI6eyJtb2R1bGUiOiJteU1vZHVsZSIsImlkIjoibXlEZXZpY2VJZCJ9fQ==