How to change installed contrib node (IOT Core/MQTT)

I have been using the node-red-contrib-google-iot-core module to publish to Google's IOT Core MQTT broker and it has been working well.

However I want to subscribe to the broker to receive commands on my device from the cloud also. Google have recently added a new 'command' topic which is different to the config topic which the node red module is set up for.

The topic that the node subscribes to is hardcoded into the modules google-iot-core.js file. I have attempted to just edit the string to subscribe to the new topic i.e.

from

/devices/{device_id}/config

to

/devices/{device_id}/commands/#

but when I saved it and restarted NR it threw up errors

6 Mar 17:09:38 - [info] Waiting for missing types to be registered:
6 Mar 17:09:38 - [info]  - google-iot-core-broker
6 Mar 17:09:38 - [info]  - google-iot-core out
6 Mar 17:09:38 - [info]  - google-iot-core in

Am I going about this the correct way? It seems like it should be a pretty quick fix but I'm not experienced with Node.js so I'm not sure if I'm missing a step or if there's a better way to go about it all, for instance cloning in the git repo and making the change and then linking the module locally instead of installing with NPM?

Any advice from experienced users would be greatly appreciated.

Thanks

First step should be to open an issue on github to flag the change that’s neede with the author of the node.
It would be better for the node to work properly than you and anyone else editing the code to get it to work

1 Like

Correct - done. I think a dropdown in the node properties to select between config/command topics would be very useful.

@ukmoose have you any idea why those errors would occur though? I don't see why such a simple change would break the flow

When Node-RED starts it will have logged some errors related to the edited node which has prevented it from being loaded. That's where you should start looking to figure out what has happened.

@knolleary where does node red log to other than the output to the console, is there a default logfile somewhere? I checked in /var/log but nothing there

It only logs to the console - so it will depend on how you run Node-RED and if you're redirecting its output anywhere. If you're running on a Pi using the install script we provide, then you should have node-red-log command available to see the relevant bits of journald log.

Ok, then yeah the only output is what I pasted above as it's not a Pi.

In theory though, editing the js file and restarting shouldn't cause any abnormal behavior should it? I ask because I am new to the Node/javascript set up and I am interested in how these things should be done. If I wanted to test out adding in the functionality for a changing the sub topic I would need to do so locally and submit a pull request perhaps.

Can you share the full log from when you start Node-RED up to the point you see those errors?

I actually re-installed the node and tried again and this time it worked. I must have had a typo in the original attempt at it.

Thanks for the help :+1: