Importing Node RED flows and PI AF - langanjp/PI-NodeRED GitHub Wiki

Importing AF Templates and Hierarchy

  • Before you import the templates, you will need to make sure you have piserver attribute set up.
    • Under Elements, create a new (top level) element named: system
    • create an attribute named: piserver
    • add your pi data archive server as the value of the piserver attribute
    • Alternatively, if you already have an attribute set up for your pi server name, you can replace %@\system|piserver% being used in the templates for auto tag creation.
  • Navigate to the AF templates directory (alternatively, if you have cloned this GIT, navigate to PI-NodeRED/master/AF)
    • Open the XML files (externalservices.xml and rpi.xml) and save them to your computer (you can click on raw and then do a save-as from your browser)
    • Import them into your AF database
    • if you are sharing a PI Data Archive with someone else running this tutorial, you will need to add a unique identifier substitution into the tag name reference for the following templates:
      • ercot_com_realtime
      • pisensehat
      • weather_gov_station

Importing Node-RED flows

  • Navigate to the Node-RED flows directory (alternatively, if you have cloned this GIT, navigate to PI-NodeRED/master/flows)

    • Open the globals.json and save (click raw and save-as), then edit (and save when finished):
    • Search for <yourserver> and replace this with your Pi Web API server (line 22)
    • Search for <yourhex64userpass> and replace this with your base64 encoded username and password (line 22)
    • Search for <yourafserver> and replace with your PI AF Server name (line 22)
    • Search for <yourafdb> and replace with your PI AF Server DB name (line 22)
    • Search for <yourpidb> and replace with your PI DA Archive Server name (line 22)
    • Open toPI.json and save (click raw and save-as), then edit (and save when finished):
      • Search for <youruseragent> and replace it with your name (line 432)
      • Search for <yourhomepage> and replace it with your website (or a valid url) (line 432)
      • Search for <youremail> and replace it with your email address (line 432)
    • Open toRPI.json and save (click raw and save-as)
    • Optionally open 101.json and save (click raw and save-as)
    • Optionally open PISubroutines.json and save (click raw and save-as)
  • Import the saved json files

    • For each of the saved json files Click on the three bars (menu) on the far right hand side of the Node-RED Editor
    • Select Import --> Clipboard
    • Select New Flow
    • Rename tab (Select tab; from menu, select Flows --> Rename)
      • globals.json --> globals init
      • toPI.json --> to PI
      • toRPI.json --> to RPI
      • (Optionally) 101.json --> 101
      • (Optionally) PISubroutines.json --> any tab
  • Clean up the imported websocket configuration on the flow: to RPI

    • Click on the msg.payload.WebId debug and click its sinusoid inject node
    • Take note (copy) of the webid in the debug window (copy without the " marks)
    • Double click the node "web socket init"
    • Click on the edit icon next to URL
      • Replace <yourwebapi> with the name of your anonymous access Pi Web API server
      • Replace <webid> with the webid that you just copied for sinusoid
      • Click update, click Done, and click Deploy

Next Section:

Understanding the to PI flow

⚠️ **GitHub.com Fallback** ⚠️