1 (edited by Gunner 2021-06-29 17:46:48)

Topic: Using RemoteXY on Node-Red to control RPi (or anything with MQTT)

I have just started using Node-Red, and of course that means I want to integrate all the things smile

I had thought of ways of using an ESP and custom code to somehow interface between RemoteXY and MQTT... but in the process I came across this older Node-Red contrib

https://github.com/DeanCording/node-red … -remote-xy

And used it to make a simple test, reading a timestamp from Node-Red and toggling an LED on the RPi

https://www.dropbox.com/s/hdr3bb4r0831f … d.png?dl=0

And here is the Flow JSON for any NR users...

[{"id":"78ffec39.ca2794","type":"tab","label":"RemoteXY","disabled":false,"info":""},{"id":"7084caed.f69234","type":"remote-xy in","z":"78ffec39.ca2794","name":"switch_1","dashboard":"e02397d0.856d38","index":"0","x":120,"y":120,"wires":[["4128ffc6.27135"]]},{"id":"4d16de8b.8ee21","type":"remote-xy out","z":"78ffec39.ca2794","name":"text_1","dashboard":"e02397d0.856d38","index":"0","x":490,"y":200,"wires":[]},{"id":"47bca140.c4c36","type":"inject","z":"78ffec39.ca2794","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":200,"wires":[["2072c169.731fde"]]},{"id":"4128ffc6.27135","type":"rpi-gpio out","z":"78ffec39.ca2794","name":"","pin":"12","set":true,"level":"0","freq":"","out":"out","x":300,"y":120,"wires":[]},{"id":"2072c169.731fde","type":"function","z":"78ffec39.ca2794","name":"To Time & Date","func":"var now = new Date().toLocaleString(\"en-US\");\nnow = now.replace('M','MM')\nreturn {payload: now};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":200,"wires":[["4d16de8b.8ee21","1863d0f1.c9b0af"]]},{"id":"1863d0f1.c9b0af","type":"debug","z":"78ffec39.ca2794","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":520,"y":260,"wires":[]},{"id":"e02397d0.856d38","type":"remote-xy-dashboard","z":"78ffec39.ca2794","name":"RXY Test","port":"6377","config":"//////////////////////////////////////////////\n//        RemoteXY include library          //\n//////////////////////////////////////////////\n\n// RemoteXY select connection mode and include library \n#define REMOTEXY_MODE__ESP8266WIFI_LIB\n#include <ESP8266WiFi.h>\n\n#include <RemoteXY.h>\n\n// RemoteXY connection settings \n#define REMOTEXY_WIFI_SSID \"YOUR_SSID\"\n#define REMOTEXY_WIFI_PASSWORD \"YOUR_PASS\"\n#define REMOTEXY_SERVER_PORT 6377\n\n\n// RemoteXY configurate  \n#pragma pack(push, 1)\nuint8_t RemoteXY_CONF[] =\n  { 255,1,0,26,0,69,0,11,13,0,\n  67,5,23,18,52,5,2,26,26,2,\n  0,39,34,22,11,2,26,31,31,79,\n  78,0,79,70,70,0,129,0,32,11,\n  35,6,8,68,97,116,101,32,38,32,\n  84,105,109,101,0,129,0,28,27,45,\n  6,8,76,69,68,32,111,110,32,71,\n  80,73,79,49,56,0 };\n  \n// this structure defines all the variables and events of your control interface \nstruct {\n\n    // input variables\n  uint8_t switch_1; // =1 if switch ON and =0 if OFF \n\n    // output variables\n  char text_1[26];  // string UTF8 end zero \n\n    // other variable\n  uint8_t connect_flag;  // =1 if wire connected, else =0 \n\n} RemoteXY;\n#pragma pack(pop)\n\n/////////////////////////////////////////////\n//           END RemoteXY include          //\n/////////////////////////////////////////////\n"}]

It works quite well so far... I will explore this more, as I like the idea of controlling an RPi via RemoteXY

"And voila, which is French for.......'and then I found out.'"

2 (edited by Gunner 2021-06-29 17:45:32)

Re: Using RemoteXY on Node-Red to control RPi (or anything with MQTT)

And I updated everything to allow for full feedback (must use button, not switch - see below) when other MQTT clients are also interacting with the same subscriptions.

The older Node-Red contrib was made back when RemoteXY didn't allow bidirectional data flow with the elements (AKA a switch was output only, no way to tell the switch to toggle possition from code).

RemoteXY advanced, the older Node-Red contrib didn't.

But I found  way to use other Node-Red nodes to allow a button to act as a switch - with visual feedback in form of a nested LED.  Now the button looks like an edge lit button.

https://www.dropbox.com/s/ovj8p1ipxac6m … e.png?dl=0

And the Node-Red Flow that makes it work

https://www.dropbox.com/s/inpdggfke9epv … e.PNG?dl=0

[{"id":"78ffec39.ca2794","type":"tab","label":"RemoteXY","disabled":false,"info":""},{"id":"4d16de8b.8ee21","type":"remote-xy out","z":"78ffec39.ca2794","name":"text_1","dashboard":"ea8a0fa4.cc86c","index":"0","x":490,"y":420,"wires":[]},{"id":"47bca140.c4c36","type":"inject","z":"78ffec39.ca2794","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":420,"wires":[["2072c169.731fde"]]},{"id":"2072c169.731fde","type":"function","z":"78ffec39.ca2794","name":"To Time & Date","func":"var now = new Date().toLocaleString(\"en-US\");\nnow = now.replace('M','MM')\nreturn {payload: now};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":420,"wires":[["4d16de8b.8ee21"]]},{"id":"d708fade.24d7b8","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_1_g","dashboard":"ea8a0fa4.cc86c","index":"2","x":620,"y":120,"wires":[]},{"id":"dc020e44.8f118","type":"remote-xy in","z":"78ffec39.ca2794","name":"button_1","dashboard":"ea8a0fa4.cc86c","index":"0","x":80,"y":80,"wires":[["57c4e908.2b1d28"]]},{"id":"ee03c9d3.26d418","type":"range","z":"78ffec39.ca2794","minin":"0","maxin":"1","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":120,"wires":[["d708fade.24d7b8"]]},{"id":"30cd4e5c.d331b2","type":"range","z":"78ffec39.ca2794","minin":"1","maxin":"0","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":160,"wires":[["5d8c58dc.0f0498"]]},{"id":"5d8c58dc.0f0498","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_1_r","dashboard":"ea8a0fa4.cc86c","index":"1","x":620,"y":160,"wires":[]},{"id":"f19dcce0.01774","type":"mqtt in","z":"78ffec39.ca2794","name":"","topic":"test/led","qos":"0","datatype":"auto","broker":"236d220c.514f8e","nl":false,"rap":true,"rh":0,"x":70,"y":120,"wires":[["ee03c9d3.26d418","30cd4e5c.d331b2","96c639b6.76ba98"]]},{"id":"d2b810fd.d809d","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_2_g","dashboard":"ea8a0fa4.cc86c","index":"4","x":620,"y":300,"wires":[]},{"id":"3c7aeb5b.0e7194","type":"remote-xy in","z":"78ffec39.ca2794","name":"button_2","dashboard":"ea8a0fa4.cc86c","index":"1","x":80,"y":260,"wires":[["cee1471.6aaacb8"]]},{"id":"53ccf57a.c9266c","type":"range","z":"78ffec39.ca2794","minin":"0","maxin":"1","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":300,"wires":[["d2b810fd.d809d"]]},{"id":"c35bc35a.1879a","type":"range","z":"78ffec39.ca2794","minin":"1","maxin":"0","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":340,"wires":[["1e65c31e.c714bd"]]},{"id":"1e65c31e.c714bd","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_2_r","dashboard":"ea8a0fa4.cc86c","index":"3","x":620,"y":340,"wires":[]},{"id":"e92eb668.3882a8","type":"mqtt in","z":"78ffec39.ca2794","name":"","topic":"test/relay","qos":"0","datatype":"auto","broker":"236d220c.514f8e","nl":false,"rap":true,"rh":0,"x":80,"y":300,"wires":[["53ccf57a.c9266c","c35bc35a.1879a"]]},{"id":"39e9d2a2.82ffbe","type":"mqtt out","z":"78ffec39.ca2794","name":"","topic":"test/led","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"236d220c.514f8e","x":540,"y":80,"wires":[]},{"id":"2aacdf94.d0f7a","type":"mqtt out","z":"78ffec39.ca2794","name":"","topic":"test/relay","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"236d220c.514f8e","x":540,"y":260,"wires":[]},{"id":"96c639b6.76ba98","type":"rpi-gpio out","z":"78ffec39.ca2794","name":"","pin":"12","set":true,"level":"0","freq":"","out":"out","x":220,"y":160,"wires":[]},{"id":"d9c64d70.401e88","type":"toggle","z":"78ffec39.ca2794","name":"","onOffTopic":"","onValue":"1","onType":"str","offValue":"0","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"always","x":350,"y":80,"wires":[["39e9d2a2.82ffbe","ee03c9d3.26d418","30cd4e5c.d331b2"]]},{"id":"57c4e908.2b1d28","type":"function","z":"78ffec39.ca2794","name":"","func":"if (msg.payload == 1){\n    msg.payload = \"-\"\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":80,"wires":[["d9c64d70.401e88"]]},{"id":"cee1471.6aaacb8","type":"function","z":"78ffec39.ca2794","name":"","func":"if (msg.payload == 1){\n    msg.payload = \"-\"\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":260,"wires":[["41c46b50.e4fe74"]]},{"id":"41c46b50.e4fe74","type":"toggle","z":"78ffec39.ca2794","name":"","onOffTopic":"","onValue":"1","onType":"str","offValue":"0","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"always","x":350,"y":260,"wires":[["2aacdf94.d0f7a","53ccf57a.c9266c","c35bc35a.1879a"]]},{"id":"ea8a0fa4.cc86c","type":"remote-xy-dashboard","name":"RemoteXY","port":"6377","config":"//////////////////////////////////////////////\n//        RemoteXY include library          //\n//////////////////////////////////////////////\n\n// RemoteXY select connection mode and include library \n#define REMOTEXY_MODE__ESP8266WIFI_LIB\n#include <ESP8266WiFi.h>\n\n#include <RemoteXY.h>\n\n// RemoteXY connection settings \n#define REMOTEXY_WIFI_SSID \"YOUR_SSID\"\n#define REMOTEXY_WIFI_PASSWORD \"YOUR_PASS\"\n#define REMOTEXY_SERVER_PORT 6377\n\n\n// RemoteXY configurate  \n#pragma pack(push, 1)\nuint8_t RemoteXY_CONF[] =\n  { 255,2,0,30,0,152,0,11,27,1,\n  67,5,9,18,46,5,16,26,26,129,\n  0,16,11,18,6,8,68,97,116,101,\n  32,38,32,84,105,109,101,0,129,0,\n  10,29,44,6,8,76,69,68,32,111,\n  110,32,71,80,73,79,49,56,0,129,\n  0,8,59,48,6,8,82,101,108,97,\n  121,32,111,110,32,87,101,109,111,115,\n  0,129,0,7,92,49,6,8,77,81,\n  84,84,32,102,111,114,32,116,104,101,\n  32,119,105,110,0,129,0,8,92,49,\n  6,95,77,81,84,84,32,102,111,114,\n  32,116,104,101,32,119,105,110,0,65,\n  22,24,36,16,16,1,0,26,38,12,\n  12,29,31,0,65,22,24,66,16,16,\n  1,0,26,68,12,12,29,31,0 };\n  \n// this structure defines all the variables and events of your control interface \nstruct {\n\n    // input variables\n  uint8_t button_1; // =1 if button pressed, else =0 \n  uint8_t button_2; // =1 if button pressed, else =0 \n\n    // output variables\n  char text_1[26];  // string UTF8 end zero \n  uint8_t led_1_r; // =0..255 LED Red brightness \n  uint8_t led_1_g; // =0..255 LED Green brightness \n  uint8_t led_2_r; // =0..255 LED Red brightness \n  uint8_t led_2_g; // =0..255 LED Green brightness \n\n    // other variable\n  uint8_t connect_flag;  // =1 if wire connected, else =0 \n\n} RemoteXY;\n#pragma pack(pop)\n\n/////////////////////////////////////////////\n//           END RemoteXY include          //\n/////////////////////////////////////////////"},{"id":"236d220c.514f8e","type":"mqtt-broker","name":"RPi Mosquitto broker","broker":"10.10.3.13","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
"And voila, which is French for.......'and then I found out.'"