Changes between Version 6 and Version 7 of nodered


Ignore:
Timestamp:
12/17/2021 11:55:41 PM (9 months ago)
Author:
Ryan Erbstoesser
Comment:

update script

Legend:

Unmodified
Added
Removed
Modified
  • nodered

    v6 v7  
    2222    sudo npm install -g --unsafe-perm node-red #install node-red using npm
    2323    node-red #start the node-red application
     24
     25Welcome to Node-RED
     26===================
     27
     2817 Dec 23:23:34 - [info] Node-RED version: v2.1.4
     2917 Dec 23:23:34 - [info] Node.js  version: v10.19.0
     3017 Dec 23:23:34 - [info] Linux 5.15.0-00085-g2ec7c180b810 arm64 LE
     3117 Dec 23:23:37 - [info] Loading palette nodes
     3217 Dec 23:23:40 - [info] Settings file  : /root/.node-red/settings.js
     3317 Dec 23:23:40 - [info] Context store  : 'default' [module=memory]
     3417 Dec 23:23:40 - [info] User directory : /root/.node-red
     3517 Dec 23:23:40 - [warn] Projects disabled : editorTheme.projects.enabled=false
     3617 Dec 23:23:40 - [info] Flows file     : /root/.node-red/flows.json
     3717 Dec 23:23:40 - [warn]
     38
     39---------------------------------------------------------------------
     40Your flow credentials file is encrypted using a system-generated key.
     41
     42If the system-generated key is lost for any reason, your credentials
     43file will not be recoverable, you will have to delete it and re-enter
     44your credentials.
     45
     46You should set your own key using the 'credentialSecret' option in
     47your settings file. Node-RED will then re-encrypt your credentials
     48file using your chosen key the next time you deploy a change.
     49---------------------------------------------------------------------
     50
     5117 Dec 23:23:40 - [info] Server now running at http://127.0.0.1:1880/
     5217 Dec 23:23:40 - [info] Starting flows
     5317 Dec 23:23:41 - [info] Started flows
     5417 Dec 23:23:41 - [info] [mqtt-broker:c44d6461e1d6d8c3] Connected to broker: mqtt://localhost:1883
     55
    2456}}}
    2557
     
    4678== Gateworks Python Script to send MQTT Messages
    4779
    48 The below is a sample python script to pass MQTT messages from the Gateworks SBC to the Node-Red server (broker). The script will pass the Gateworks SBC temperature as the payload and send it specific to the devices serial number.
     80The below is a sample python script to pass MQTT messages from the Gateworks SBC to the Node-Red server (broker). The script will pass the Gateworks SBC temperature as the payload and send it specific to the device's serial number.
    4981
    5082{{{
     
    74106 client.on_connect = on_connect
    75107 client.on_message = on_message
    76  broker = "122.24.55.93"
     108 broker = "172.24.33.93"
    77109 client.connect(broker)
    78110 client.loop_start()
    79  time.sleep(5)
     111 serialnumber = str(open('/proc/device-tree/serial-number', 'r').read())
     112 print(serialnumber)
     113 prefix = "gateways/id/"
     114 time.sleep(1)
    80115 while True:
    81116    try:
    82117        print("in loop")
    83118        temp = float(open('/sys/class/hwmon/hwmon0/temp1_input', 'r').read().strip())/1000
    84         client.publish("gateways/id/45",temp,1)
     119        prefix = "gateways/id/"
     120        serialnumber = str(open('/proc/device-tree/serial-number', 'r').read().strip('\x00'))
     121        topic = prefix + serialnumber
     122        client.publish(topic,temp,1)
    85123        print("done publishing")
    86124
     
    94132    main(sys.argv)
    95133
    96 
    97134}}}
    98135