Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

3.6. example for NodeRed

roobbb edited this page Oct 8, 2021 · 1 revision

example when Node Red runs in a container with a user-defined-network

  • add a new user-defined-network

    docker network create testnet
    
  • edit owfs.example and change server ip-address from 127.0.0.1 to the name of the docker container which we want to start (owserver) or its network-alias (myowserver), even the server's port should be the same as what we want to map

  • start owserver-container with new network and alias and map ports as required

    docker run -d \
       --rm \
       --name=owserver \
       --net=testnet \
       --network-alias myowserver \
       -p 2121:2121 \
       -v /etc/localtime:/etc/localtime:ro \
       -v ~/docker/owserver:/root/.local/share \
       -e CUSTOM_CONFIG_ENABLED=1 \
       -e CUSTOM_CONFIG_FILE=/root/.local/share/owfs.example \
    roobbb/owserver:latest
    
  • only port 2121 will be exposed here, just for easy testing if it is reachable

  • check if the web-interface is reachable via http://yourHostIP:2121/ or via http://localhost:2121/

  • the other ports like 4303 for data connection will be available inside the user-defined-network (testnet) only


  • create a local folder on your host for easier testing and accessing files in any location you want and point to actual path inside the docker call

  • the following docker call is just for demonstrating, please take a look into the official docs found here https://nodered.org/docs/getting-started/docker

    docker run -d \
      --rm \
      --name nodered \
      --net=testnet \
      --network-alias mynodered \
      -p 1880:1880 \
      -v yourlocalpath:/data \
      -v /etc/localtime:/etc/localtime:ro \
      -v /etc/timezone:/etc/timezone:ro \
     nodered/node-red:latest
    
  • Node Red should now be reachable via http://yourHostIP:1880

  • install owfs support as described here https://flows.nodered.org/node/node-red-contrib-owfs (I did it by entering the running container via "docker exec -it nodered /bin/bash")

  • restart the container (docker restart nodered)

  • inside Node Red you should see now a owfs node on the left pane under "hardware"

  • adding the attached sensors in node red isn't that "automatic" - just started with an example found here: https://flows.nodered.org/flow/b11cfe3a7728a297e44d

  • copy + paste this example (or even my one, see down below) via Import and open the owfs-node, enter "myowserver" under host, choose Mode Read and hit "Done"

  • reenter owfs-node and there should be all found sensors listed, activate each one you want and copy the name of the first one (e.g. 10.67C6697351FF/temperature), click Done again

  • enter the first inject-node and type in a name and under topic paste in the copied text, hit Done

  • finally click Deploy and open the debug messages on the right: there should appear the measured values from that sensor you added


my resulting testflow looks like that
[ { "id": "4a1b9d33b930ef12", "type": "tab", "label": "Flow 1", "disabled": false, "info": "" }, { "id": "b25fb9bc8e3350df", "type": "owfs", "z": "4a1b9d33b930ef12", "name": "", "uncached": false, "mode": "read", "host": "myowserver", "port": "4304", "paths": [ "10.67C6697351FF/alias", "10.67C6697351FF/latesttemp", "10.67C6697351FF/power", "10.67C6697351FF/scratchpad", "10.67C6697351FF/temperature", "10.67C6697351FF/temphigh", "10.67C6697351FF/templow", "10.67C6697351FF/type", "05.4AEC29CDBAAB/PIO", "05.4AEC29CDBAAB/alias", "05.4AEC29CDBAAB/sensed", "05.4AEC29CDBAAB/type" ], "x": 500, "y": 360, "wires": [ [ "15f95131e6d4954d" ] ] }, { "id": "10c55b2df687e9e8", "type": "inject", "z": "4a1b9d33b930ef12", "name": "10.67C6697351FF", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "10", "crontab": "", "once": true, "onceDelay": "", "topic": "10.67C6697351FF/temperature", "payloadType": "str", "x": 300, "y": 340, "wires": [ [ "b25fb9bc8e3350df" ] ] }, { "id": "15f95131e6d4954d", "type": "change", "z": "4a1b9d33b930ef12", "name": "", "action": "replace", "property": "retain", "from": "", "to": "true", "reg": false, "x": 680, "y": 400, "wires": [ [ "7ebee2eaebb09d99" ] ] }, { "id": "7ebee2eaebb09d99", "type": "debug", "z": "4a1b9d33b930ef12", "name": "", "active": true, "console": false, "complete": false, "x": 878, "y": 330, "wires": [] } ]