smart-energy-monitor/software/flow
2023-03-02 14:04:47 +01:00
..
.npm added node-red-contrib-influxdv 2023-02-23 15:38:30 +01:00
00-dashboard-example example flow 2023-02-22 16:27:14 +01:00
docs/images documented plugins 2023-02-26 11:31:14 +01:00
node_modules commit dist folder as it's used by javascript modules 2023-02-27 15:43:31 +01:00
.config.nodes.json added node-red-contrib-influxdv 2023-02-23 15:38:30 +01:00
.config.nodes.json.backup added node-red-contrib-influxdv 2023-02-23 15:38:30 +01:00
.config.projects.json added demo dashboard in node RED 2023-02-22 17:26:41 +01:00
.config.runtime.json added demo dashboard in node RED 2023-02-22 17:26:41 +01:00
.config.users.json added plant monitor 2023-02-26 18:28:15 +01:00
.config.users.json.backup added plant monitor 2023-02-26 18:28:15 +01:00
.flows.json.backup Changing naming convention for nodes 2023-03-01 19:36:59 +01:00
.flows_cred.json.backup Changing naming convention for nodes 2023-03-01 19:36:59 +01:00
flows.json Changing filament mqtt topic and parsing 2023-03-02 14:04:47 +01:00
flows_cred.json Changing naming convention for nodes 2023-03-01 19:36:59 +01:00
package-lock.json added node-red-contrib-influxdv 2023-02-23 15:38:30 +01:00
package.json Adding flows for energy/filament consumtion 2023-03-02 11:49:06 +01:00
README.md there is no grafana plugin 2023-02-26 11:32:09 +01:00
settings.js added demo dashboard in node RED 2023-02-22 17:26:41 +01:00

About

This folder will be mounted into the Node-RED runtime. So be careful.

Node-RED

If you boot up our tech stack using docker-compose you already have a Node-RED instance running on your local machine.

Node-RED is an open-source, low-code, visual programming tool based on the concept of flow-based development. The idea behind it is to make it very easy to connect APIs, hardware devices, and anything else accessible over some type of network connection.

Core Concepts

Nodes are the important part of Node-Red. They are the building blocks when working with Node-Red. Nodes are triggered by either receiving a message object from a previous node or an external event like an MQTT event. The node processes the message or event and then passes it on to the next node.

A node can:

  • Inject: Starts a flow by injecting a message or a payload.
  • Change: Here you can do basic transformation or modification on the message object.
  • Debug: Can be used to help developing flows by sending messages to the side bar.
  • Switch: Here you can add logic (like sending the message to different nodes).
  • Function: Add custom JavaScript for uses cases where simple nodes do not do the trick.

Flows are an organized sequence of nodes. Let's do the "first steps" by creating a simple flow.

Plugins

The plugin folder is pushed into this Git repository and is mounted in Docker. Maybe we should use an own Docker file, instead.

Node-RED uses plugins (e.g. for InfluxDB or own Dashboard capabilites).

You can access the plugins in the right burger menu.

Plugins

First steps

For debuging I already added Node-RED's own dashboard (sure, we are going to use Grafana, later).

Overview

The dashboard should be visible on the righmost menu item in Node-RED.

Dashboard item

In Node-RED you can add a MQQT node to receive values from the power monitor. As we run in docker-composeyou don't have to use the IP address of our Eclipse Mosquitto sever, but you can simply use mosquitto as the host nome.

MQTT Nodegit a

To simply display the values in a gauge (or chart) you can hook it up to a gauge node.

Gauge Node

In the dasboard section you have to create a tab. Inside this tab you have to create a group.

Dashboard Settings

The tricky part is putting the gauges in the group. This is done in the gauge's settings (not in the dashboard's settings).

Gauge Node

You can view the dashboard in an (also mobile) web browser.

Mobile view

Have a look at the flow also in this repository.

InfluxDB

Already added to this project is node-red-contrib-influxdb. You can use it's nodes to write and query data from an InfluxDB time series database. These nodes support both InfluxDB 1.x and InfluxDb 2.0 databases. At the time of this writing we are using version 2.6 of InfluxDB on port 8086.

In Node-RED we will be passing the power consumption number through MQTT.

Overview

By default this will be passed as a string, so we need to create a function to convert it into a Number before storing it in InfluxDB.

Add a function node to the page and put the following code into the node:

msg.payload = Number(msg.payload)
return msg;

Function

You can forward this message to InfluxDB.

Influx Node

The URLof our InfluxDB is http://influxdb:8086. In InfluxDB you have to create a token to connect: Load Data -> API Tokens.

Influx Create Token

You can use this token to create a connection in Node-RED.

Influx Connection

Then the measurements should be visible in Influx Data Explorer.

Influx Data Explorer

As the data is now stored in Influx, let's create a dashboard in Grafana.

Links