Importing or Exporting wave gauge

Wave gauge that changes colour depending if you are importing or exporting to a power-grid

[{"id":"34551bc0.ed7024","type":"subflow","name":"Power wave gauge","info":"","category":"","in":[{"x":40,"y":120,"wires":[{"id":"d299b438.d635b"}]}],"out":[],"env":[{"name":"importingColour","type":"str","value":"#ff0000","ui":{"label":{"en-US":"Importing Colour"},"type":"input","opts":{"types":["str","env"]}}},{"name":"exportingColour","type":"str","value":"#00ff00","ui":{"label":{"en-US":"Exporting Colour"},"type":"input","opts":{"types":["str","env"]}}},{"name":"waveTransparency","type":"str","value":"70","ui":{"label":{"en-US":"Wave Transparency"},"type":"input","opts":{"types":["str","env"]}}},{"name":"textTransparency","type":"str","value":"80","ui":{"label":{"en-US":"Wave Transparency"},"type":"input","opts":{"types":["str","env"]}}},{"name":"exportToGridText","type":"str","value":"Exporting to grid.","ui":{"label":{"en-US":"Export To Grid Text"},"type":"input","opts":{"types":["str","env"]}}},{"name":"importFromGridText","type":"str","value":"Importing from grid.","ui":{"label":{"en-US":"Import From Grid Text"},"type":"input","opts":{"types":["str","env"]}}}],"color":"#DDAA99"},{"id":"d299b438.d635b","type":"function","z":"34551bc0.ed7024","name":"Disply Settings","func":"//Colour wave will be when importing from the grid\nconst importingColour = env.get(\"importingColour\");\n\n//Colour wave will be when exporting to the grid\nconst exportingColour = env.get(\"exportingColour\");\n\n//Transparency factor for the wave fill\nconst waveTransparency = env.get(\"waveTransparency\");\n\n//Transparency factor for text in the wave\nconst textTransparency = env.get(\"textTransparency\");\n\nconst exportToGridText = env.get(\"exportToGridText\");\n\nconst importFromGridText = env.get(\"importFromGridText\");\n\nconst gridDirectionEnum = {\"Exporting\":\"exporting\", \"Importing\":\"importing\"}\nconst gridDirectionFLowContextKey = \"gridDirection\";\n\nreturn RunNode(msg);\nfunction RunNode(msg) {\n\n    let gridDirection = flow.get(gridDirectionFLowContextKey);\n\n    if ((gridDirection !== gridDirectionEnum.Exporting || typeof gridDirection == 'undefined') && msg.payload < 0) {\n        msg.ui_control = {\n            options: {\n                waveColor: exportingColour + waveTransparency,\n                circleColor: exportingColour + waveTransparency,\n                textColor: exportingColour + textTransparency,\n                waveTextColor: exportingColour + textTransparency\n            }\n        };\n\n        flow.set(gridDirectionFLowContextKey, gridDirectionEnum.Exporting);\n    }\n    else if ((gridDirection !== gridDirectionEnum.Importing  || typeof gridDirection == 'undefined') && msg.payload > 0) {\n        msg.ui_control = {\n            options: {\n                waveColor: importingColour + waveTransparency,\n                circleColor: importingColour + waveTransparency,\n                textColor: importingColour + textTransparency,\n                waveTextColor: importingColour + textTransparency\n            }\n        };\n\n        flow.set(gridDirectionFLowContextKey, gridDirectionEnum.Importing);\n    }\n\n    if (flow.get(gridDirectionFLowContextKey) === gridDirectionEnum.Exporting) {\n        msg.payload = msg.payload * -1;\n        msg.gridDirectionText = exportToGridText;\n    } else {\n        msg.gridDirectionText = importFromGridText;\n    }\n\n    return msg;\n}","outputs":1,"noerr":0,"x":160,"y":120,"wires":[["1c1840af.a6e1f7","51d58510.94fec4"]]},{"id":"1c1840af.a6e1f7","type":"ui_gauge","z":"34551bc0.ed7024","name":"Load Meter ","group":"b3149ef8.b466c","order":1,"width":0,"height":0,"gtype":"wave","title":"","label":"W","format":"{{value}}","min":"0","max":"5000","colors":["#00b500","#00b500","#ca3838"],"seg1":"lower","seg2":"upper","x":330,"y":100,"wires":[]},{"id":"51d58510.94fec4","type":"ui_text","z":"34551bc0.ed7024","group":"b3149ef8.b466c","order":3,"width":0,"height":0,"name":"Grid Direction Display","label":"","format":"{{msg.gridDirectionText}}","layout":"col-center","x":360,"y":140,"wires":[]},{"id":"8c5b02.ba7f75","type":"inject","z":"34551bc0.ed7024","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":40,"wires":[["ed724aa.6d033b8"]]},{"id":"ed724aa.6d033b8","type":"change","z":"34551bc0.ed7024","name":"","rules":[{"t":"set","p":"gridDirection","pt":"flow","to":"undefined","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":40,"wires":[[]]},{"id":"b3149ef8.b466c","type":"ui_group","z":"","name":"Power consumption","tab":"362545e3.1cf5ba","order":1,"disp":false,"width":"6","collapse":false},{"id":"362545e3.1cf5ba","type":"ui_tab","z":"","name":"203 Lockwood Road","icon":"home","order":1,"disabled":false,"hidden":false}]

Collection Info

Flow Info

Created 5 years, 9 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • function (x1)
  • inject (x1)
Other
  • subflow (x1)
  • ui_gauge (x1)
  • ui_group (x1)
  • ui_tab (x1)
  • ui_text (x1)

Tags

  • solar
  • powergrid
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option