How do I get Node-red to show envirophat sensor values?

Exec node output, via a debug node,

{'lightR': 114, 'lightB': 76, 'lightLevel': 20, 'lightG': 76, 'pressure': 101765.64743934195, 'motionZ': -0.095458984375, 'motionY': -0.960693359375, 'motionX': -0.00994873046875, 'heading': 280.73, 'temperature': 18.85038544858037}

Current flow:

[{"id":"ea573e4793c9cdc1","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5f57101617890f0c","type":"envirophat","z":"ea573e4793c9cdc1","x":80,"y":80,"wires":[["88d3d0ce0a9f2375"]],"outputLabels":["heading"]},{"id":"88d3d0ce0a9f2375","type":"exec","z":"ea573e4793c9cdc1","command":"python /home/pi/.node-red/node_modules/node-red-contrib-envirophat/script2.py","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Script2.py","x":320,"y":80,"wires":[["07be01c909b4b7f7"],[],["575819ad3bd131cf"]],"outputLabels":["results","",""]},{"id":"07be01c909b4b7f7","type":"change","z":"ea573e4793c9cdc1","name":"Change quotes","rules":[{"t":"change","p":"payload","pt":"msg","from":"'","fromt":"str","to":"\"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":60,"wires":[["96d7e779b0ec9235"]]},{"id":"96d7e779b0ec9235","type":"json","z":"ea573e4793c9cdc1","name":"Convert JSON S2O","property":"payload","action":"","pretty":false,"x":870,"y":60,"wires":[["3cf2749a8f51174c","f88c70c9f624153c"]],"outputLabels":["lightlevel"]},{"id":"3cf2749a8f51174c","type":"debug","z":"ea573e4793c9cdc1","name":"script check","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":60,"wires":[]},{"id":"e25afd94f88ea6a1","type":"ui_gauge","z":"ea573e4793c9cdc1","name":"","group":"5beb7aad98f56e80","order":0,"width":0,"height":0,"gtype":"gage","title":"Light level","label":"","format":"{{value}}","min":0,"max":"88","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1290,"y":240,"wires":[]},{"id":"0ef7226bbf7603a9","type":"change","z":"ea573e4793c9cdc1","name":"Lightlevel","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.lightLevel","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":160,"wires":[[]]},{"id":"23caa125510200dc","type":"change","z":"ea573e4793c9cdc1","name":"motionY","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.motionY","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1101,"y":317,"wires":[["807cf399dcf3313e"]]},{"id":"807cf399dcf3313e","type":"ui_gauge","z":"ea573e4793c9cdc1","name":"","group":"d419905ebdf4a006","order":0,"width":0,"height":0,"gtype":"gage","title":"Door","label":"units","format":"{{value | numer:5}}","min":"-2","max":"2","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1250,"y":320,"wires":[]},{"id":"f88c70c9f624153c","type":"change","z":"ea573e4793c9cdc1","name":"Temp","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":460,"wires":[["793cc01bcbf41dc5"]]},{"id":"793cc01bcbf41dc5","type":"ui_gauge","z":"ea573e4793c9cdc1","name":"","group":"26a312ff72db7c37","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"units","format":"{{value | numer:5}}","min":"0","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1270,"y":460,"wires":[]},{"id":"575819ad3bd131cf","type":"debug","z":"ea573e4793c9cdc1","name":"output1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":140,"wires":[]},{"id":"5beb7aad98f56e80","type":"ui_group","name":"Lights","tab":"e3bf1012f9467443","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"d419905ebdf4a006","type":"ui_group","name":"Door","tab":"e3bf1012f9467443","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"26a312ff72db7c37","type":"ui_group","name":"Temperature","tab":"e3bf1012f9467443","order":4,"disp":true,"width":"6","collapse":false,"className":""},{"id":"e3bf1012f9467443","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

You have some nodes not wired together.
You have a couple of typos: "numer :5" instead of "number :5" in your gauges.
The envirophat node may or may not work, but if you are calling your script via exec, it isn't needed. Instead use an inject node, set to repeat however often you want - eg every 5 seconds.

Here is a simplified flow and the result.

[{"id":"e25afd94f88ea6a1","type":"ui_gauge","z":"ea573e4793c9cdc1","name":"","group":"5beb7aad98f56e80","order":0,"width":0,"height":0,"gtype":"gage","title":"Light level","label":"","format":"{{payload.lightLevel}}","min":0,"max":"88","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1100,"y":60,"wires":[]},{"id":"807cf399dcf3313e","type":"ui_gauge","z":"ea573e4793c9cdc1","name":"","group":"d419905ebdf4a006","order":0,"width":0,"height":0,"gtype":"gage","title":"Door","label":"units","format":"{{payload.motionY | number: 5}}","min":"-2","max":"2","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1110,"y":100,"wires":[]},{"id":"793cc01bcbf41dc5","type":"ui_gauge","z":"ea573e4793c9cdc1","name":"","group":"26a312ff72db7c37","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"units","format":"{{payload.temperature | number:5}}","min":"0","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1090,"y":140,"wires":[]},{"id":"6f483083f1676949","type":"exec","z":"ea573e4793c9cdc1","command":"python /home/pi/script3.py","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":550,"y":120,"wires":[["e76d2e7e73dd67ac"],[],[]]},{"id":"407c7c6f9007ce0c","type":"inject","z":"ea573e4793c9cdc1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":120,"wires":[["6f483083f1676949"]]},{"id":"c53b197996edde7f","type":"json","z":"ea573e4793c9cdc1","name":"","property":"payload","action":"","pretty":false,"x":930,"y":120,"wires":[["e25afd94f88ea6a1","807cf399dcf3313e","793cc01bcbf41dc5","b94a439cdf3b4ad1"]]},{"id":"e76d2e7e73dd67ac","type":"change","z":"ea573e4793c9cdc1","name":"Change quotes","rules":[{"t":"change","p":"payload","pt":"msg","from":"'","fromt":"str","to":"\"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":120,"wires":[["c53b197996edde7f"]]},{"id":"b94a439cdf3b4ad1","type":"debug","z":"ea573e4793c9cdc1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":180,"wires":[]},{"id":"5beb7aad98f56e80","type":"ui_group","name":"Lights","tab":"e3bf1012f9467443","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"d419905ebdf4a006","type":"ui_group","name":"Door","tab":"e3bf1012f9467443","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"26a312ff72db7c37","type":"ui_group","name":"Temperature","tab":"e3bf1012f9467443","order":4,"disp":true,"width":"6","collapse":false,"className":""},{"id":"e3bf1012f9467443","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Note that I don't have an envirophat, so I injected your supplied data using script3.py which looks like this

r = 114
g = 76
b = 76
l = 20
t = 18.85038544858037
p = 101765.64743934195
x = -0.00994873046875
y = -0.960693359375
z = -0.095458984375
h = 280.73

results = {
        "lightR": r,
        "lightG": g,
        "lightB": b,
        "lightLevel": l,
        "temperature": t,
        "pressure": p,
        "motionX": x,
        "motionY": y,
        "motionZ": z,
        "heading": h
            }
print(results)

  • I did indeed disconnect some nodes prior to exporting
  • Turns out you do need the Envirophat node to trigger a new set of results. Or of course the route you suggested.
  • Typos. My apologies.
  • The main takeaway from this for me is the gauges need payload in here --> {{payload.object}}

Thank you all for your help.
Node-red is fascinating, I look forward to learning more. :slight_smile:

Or {{msg.payload.object}} as I suggested earlier. Or, in fact {{msg.someothertopic}} if the value is not in the payload, but a different message property.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.