This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global variables in node red
#1
Maybe everyone else knows all this already, but I've just been digging deeper into global variables in node red. 
There's a node for seeing what they contain, search for 'node-red-contrib-contextbrowser' in the managepalette-install. also you can initialise them with any value on startup with a config node - node-red-contrib-config and view them straight in a browser.
http://10.10.10.1:1880/contextbrowser/global

So rather than parse through nmea 0r signalk messages it seems much easier to grab the messages once as they come in and assign the values to global variables, the change node makes this easy. 
For instance I have an ESP32 with various sensors sending data to the Pi over mqtt, this node puts the pressure into global.pressure where it's easier to get at for other flows to put it into a graph or database.
Hope this helps.

SOme more here - https://tech.scargill.net/node-red-globa...d-context/

Code:
[
   {
       "id": "6f1e8f4b.0d7e6",
       "type": "change",
       "z": "3f30ea31.da3756",
       "name": "",
       "rules": [
           {
               "t": "set",
               "p": "pressure",
               "pt": "global",
               "to": "payload",
               "tot": "msg"
           }
       ],
       "action": "",
       "property": "",
       "from": "",
       "to": "",
       "reg": false,
       "x": 411,
       "y": 1605,
       "wires": [
           []
       ]
   },
   {
       "id": "9a48ef5e.a7d12",
       "type": "mqtt in",
       "z": "3f30ea31.da3756",
       "name": "",
       "topic": "Esp1BMP280Pressure",
       "qos": "2",
       "broker": "c2e0624.6088ea",
       "x": 161,
       "y": 1605,
       "wires": [
           [
               "6f1e8f4b.0d7e6"
           ]
       ]
   },
   {
       "id": "c2e0624.6088ea",
       "type": "mqtt-broker",
       "z": "",
       "broker": "10.10.10.1",
       "port": "1883",
       "clientid": "",
       "usetls": false,
       "compatmode": true,
       "keepalive": "60",
       "cleansession": true,
       "willTopic": "",
       "willQos": "0",
       "willPayload": "",
       "birthTopic": "",
       "birthQos": "0",
       "birthPayload": ""
   }
]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)