I'm in the process of switching from a Denkovi wifi modbus relay to a SainSmart USB connected relay, both are 16 port relays. I'm trying to use gdziuba/node-red-usbhid to connect up. I've also tried the other hid modules and can't get any of them to work as expected. I'm assuming this has something to do with the configuration of the Raspberry Pi more than it is an issue with Node-Red but I'm not positive about that.
This is the new SainSmart relay: 16-Channel 9-36V USB Relay Module – SainSmart.com
Below is the USBHID flow I'm trying to use to connect to the USB Relay and a screenshot of the LUSB scan to determine the VID and PID.
I've added a file to /etc/udev/rules.d with the additional udev rules I think are needed and added the pi user to the input group.
The debug data is below - the getHIDdevices is throwing the empty array and the HIDdevice is showing disconnected and debug shows the bottom error from that node.
Any ideas on what I'm missing on this? I'm switching relays because I want the local connection for reliability and the Denkovi relay also just stopped connecting and being accessible to my network. A full factory reset on the device (several times) wasn't able to fix it so I'm moving the switchover to the SainSmart relay up on the schedule but struggling to make the SainSmart relay available to node-red.
I haven't really been able to find any support for SainSmart USB relays with node-red so hopefully this thread also is useful for the next person.
[{"id":"cbae0763803aa6e9","type":"group","z":"3b6a718c4021497b","name":"USBHID","style":{"label":true},"nodes":["78f82fb335672aca","c1ecae6308a0525f","d99660be8c6c6066","546ab3a525f72ecc","1b5120024bf4bc62","f8d8cae1919e186c","e1d69c8863f6de73"],"x":34,"y":19,"w":692,"h":122},{"id":"78f82fb335672aca","type":"debug","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":60,"wires":[]},{"id":"c1ecae6308a0525f","type":"getHIDdevices","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","name":"","x":300,"y":60,"wires":[["78f82fb335672aca"]]},{"id":"d99660be8c6c6066","type":"inject","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":60,"wires":[["c1ecae6308a0525f"]]},{"id":"546ab3a525f72ecc","type":"HIDdevice","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","connection":"68a0ec4b6af1dcb1","name":"","x":290,"y":100,"wires":[["e1d69c8863f6de73"],[]]},{"id":"1b5120024bf4bc62","type":"inject","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":100,"wires":[["546ab3a525f72ecc"]]},{"id":"f8d8cae1919e186c","type":"debug","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":100,"wires":[]},{"id":"e1d69c8863f6de73","type":"function","z":"3b6a718c4021497b","g":"cbae0763803aa6e9","name":"Hex to String","func":"const hexBuffer = msg.payload;\n\n// Convert the hex buffer to a Buffer object\nconst buffer = Buffer.from(hexBuffer, 'hex');\n\n// Convert the Buffer to a string\nconst string = buffer.toString();\n\n// Assign the string to msg.payload for further processing\nmsg.payload = string;\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":100,"wires":[["f8d8cae1919e186c"]]},{"id":"68a0ec4b6af1dcb1","type":"HIDConfig","vid":"1504","pid":"1536","name":"Barcode Scanner"}]