Hubitat > NodeRed > MySQL > Grafana (LONG READ)

Yeah, that doesn't sound right..... I have never see that automatic / in front but that can't work....

I even delete the saved path and created a new one and its still adding the / in there.

Edit: what is weird is it only does it when using the "listen on" option for the websocket. When using "connect to" no extra / is added.

Really not sure what the issue is but it always add the leading /. I just went back to using two websockets for now since it works properly.

It adds the leading / because it's only expecting a path. So if you make it /foo, your socket address will be ws://< ip address >:1880/foo.

Okay so I originally had the "Listen On" websockets setup with the path set to /event-socket. This however resulted in nothing being written to the InfluxDB.

So maybe I am missing something here but from what I understand the websocket relay has a "Connect To" websocket that is actually opening the connection to HE. Then the other websocket in the relay's flow would be set to "Listen On." All other flows that have a websocket that need to connect would have their websocket node set to "Listen On" with the same path, in this case "/event-socket."

This is how I thought it should be setup, which does not work.

Based on what @btk posted above, I believe the path in your last pic should be

ws://< ip address >:1880/eventsocket

If I use the "Listen On" websocket it will add the "/" in front like this which does not work: /ws://< ip address >:1880/eventsocket

Or do I use the "Connect To" websocket instead and format it as you stated above?

This.

Okay so this seems to be working now. I was going by the assumption that the flows I want to connect to the relay needed the websocket node to be setup as "Listen On." That was what caused the issue the whole time.

When I initially imported the flow it was set to "Listen On," that is why I left it that way.

Great tutorial! I ended up modifying your flow to use an Elasticsearch backend instead. Works great!

1 Like

Awesome! I actually thought about using ES with Kibana, but then I didn't feel like the hassle of ES7 and all the new complexities they added to it.

Wonderful guide! Big thank's for this. @corerootedxb. If you have more projekt like this don't be shy to put up more of these tutorial and detailed project description's. Was up and running in just a few minutes with this thanks to the detailed help and the code . :smile: :smile:

I had some issues that some of my multi sensors and other devices did not report temp and battery status to database with the example json for Node Red. Problem was that it couldn't find temp or battery capability if it wasn't stated as the first listed capability under capabilities in the driver. Hade to change the function code for temp and battery in node red for this to make it work.

var devices = [];
msg.payload.forEach(function(device) {
	device.capabilities.forEach(function(cap){
	if(cap == 'TemperatureMeasurement'){
        devices.push(device);
        return;
	}
  });
});

msg.payload = devices;
return msg;
2 Likes

A little help please, I have the Event Socket and Log Socket setup and they say they are connected. I then have them connected to a debug output and am expecting to see events and logs in the debug window but there is nothing there.

Your logsocket for example should look something like this:

Also make sure your debug node is showing the complete message and not just the payload.

Still nothing.

Looks right. Is your network segmented in any way that would prevent your hub from communicating with the device NodeRed is running on?

I am running node-red in a docker in bridge mode, I wonder if that could be it.

Don't know much about dockers in bridge mode. It probably won't yield anything definitive but I would try setting up a ping node and see if it can see your HE hub. If you don't get a ping response then there is probably something blocking your hub's route to the nodered instance.

Docker containers need special firewall rules to reach the host network in bridge mode. I've always just run my containers that need direct host access in host mode.