Node-RED eMOD API Modules

Node-RED allows you to focus on what really matters, our added value to the solutions.

We have gone one step further on the integration of eManager and Node-RED creating customized nodes for each of our expansion modules.

Node-RED eMOD Nodes

This Getting Started guide covers setting up eMOD nodes, with a description of what each can do, what functions are available, along with usage examples for each of the eMOD nodes.

INSTALLATION

  • No installation is required, as EMOD nodes come already installed by default in our eManager. Specifically, each one incorporates the nodes corresponding to the installed hardware modules.

1) 8 Signal relays API

8 Signal relays node

Connects to a 8SR eMOD module (datasheet) to manage the 8 relays individually or jointly.

It allows to manage the following functionalities on the module:

  • Set the pulse width for each relay.
  • Activate or deactivate one, some or all relays.
  • Get the current relays status.

1.1 Available functions

  • get_one: obtains the status of a single relay.

Example:

To obtain the status of the relay 0 you can use: {"get_one": 0}.

In this case, the response tells us that relay 0 is deactivated: {"status": {"index":0, "value":false}}.

  • get_all: obtains the status of all relays.

Example:

To obtain the status of all relays you can use: {"get_all": "status"}.

In this case, the first and fourth relays are activated: {"all_status": [true, false, false, true, false, false, false, false] }.

  • set_one: activates or deactivates a single relay. On completion of action, input message with result is sent to output port.

Example 1:

Activates relay 0: {"set_one": {"index": 0, "value": true}}.

The output tells us that relay 0 is activated: {"status": {"index":0, "value":true}}.

Example 2:

Deactivates relay 0: {"set_one": {"index": 0, "value": false}}.

The output tells us that relay 0 is deactivated: {"status": {"index":0, "value":false}}.

  • set: activates or deactivates some relays. On completion of action, input message with result is sent to output port.

As a parameter, it has an 8-element array of one among the following:

  • true: activates relay.
  • false: deactivates relay.
  • null: does not change the status of the relay.

Example:

Activate the first and fourth relays and deactivate the eighth: {"set": [true, null, null, true, null, null, null, false]}.

The output tells us all relay status: {"all_status":[true,true,true,true,false,true,false,false]}.

  • set_all: activates or deactivates all relays. On completion of action, input message with result is sent to output port.

Example 1:

To activate all relays: {"set_all": true}.

The output tells us all relay status: {"all_status":[true,true,true,true,true,true,true,true]}.

Example 2:

To deactivate all relays: {"set_all": false}.

The output tells us all relay status: {"all_status":[false,false,false,false,false,false,false,false]}.

2) 10 Digital inputs API

10 Digital inputs node

Connects to a 10DI eMOD module (datasheet) to manage the 10 digital inputs individually or jointly.

It allows to manage the following functionalities on the module:

Configure module parameters. Poll input status for one or all inputs. Poll pulse counter for one or all inputs. Reset pulse counters.

10DI eMOD module can operate in two different ways:

  • In Poll mode, user starts the flow and asks for data when he needs it.
  • In Event mode user configures certain condition when he wants to be notified and it is the module that notifies him when it has been met.

In Node-RED, the module can operate in the following working modes:

  • Poll.
  • [Event] Time interval: module keeps notifying values of all inputs in a fixed time interval.
  • [Event] Input value change: module notifies when a digital input changes.
  • [Event] Pulse count change: module notifies when the pulse counter surpases the threshold from last notification.

2.1 Available functions

  • get_one (only in Poll mode): obtains the status or pulse count of a single digital input.

Example 1:

To obtain the status of a single digital input: {"get_one": {"index": 3, "mode": "status"}}.

In this case, fourth digital input is in high state: {"status": {"index": 3, "value": true}}.

Example 2:

To obtain the pulse count of a digital input: {"get_one": {"index": 3, "mode": "pulse_count"}}.

In this case, pulse count of fourth digital input is 15: {"counter": {"index": 3, "value": 15}}.

  • get_all (only in Poll mode): obtains the status or pulse count of all digital inputs.

Example 1:

To obtain the status of all digital input: {"get_all": "status"}.

In this case, only fourth digital input is high state:{"all_status": [false, false, false, true, false, false, false, false, false, false] }.

Example 2:

To obtain the pulse count of all digital input: {"get_all": "pulse_count"}.

Function returns following pulse counts: {"all_counters": [0, 5, 10, 2, 23, 5, 71, 3, 0, 0] }.

  • reset_pulse_count: resets one or all inputs.

Example 1:

Resets the ninth input: {"reset_pulse_count": 8}.

Example 2:

Resets all input: {"reset_pulse_count": "all"}.

3) 7 Analog inputs and 2 power relays API

7 Analog inputs and 2 power relays node

Connects to a 7AI+2PR eMOD module (datasheet) to manage the 7 analog inputs and 2 relays individually or jointly.

It allows to manage the following functionalities on the module:

  • Set the pulse width for each relay.
  • Set the input mode (current or voltage) for each analog input and also the working mode.
  • Get the input value for one or all inputs.
  • Activate or deactivate one, some or all relays.
  • Get the current relays status.

The 7AI can operate in two different ways:

  • In Poll mode, user starts the flow and asks for data when he needs it.
  • In Event mode user configures certain condition when he wants to be notified and it is the module that notifies him when it has been met.

In Node-RED, the module can operate in the following working modes:

  • Poll.
  • [Event] Time interval: module keeps notifying values of all inputs in a fixed time interval.
  • [Event] Value threshol: module notifies when the measured value in any input surpases the threshold from last notification.
  • [Event] Value within range: module notifies when the measured value in any input enters within a value range.
  • [Event] Value out of range: module notifies when the measured value in any input falls out of a value range.

2PR Module

2PR only can operate in Poll mode.

This module has 2 output: one for the relays and the other for the analog inputs.

3.1 Available functions for analog inputs

  • ai_get_one (only in Poll mode): obtains the value of a single analog input.

Example:

To obtain the value of a single analog input: {"ai_get_one": 3}.

In this case, fourth analog input is configured as voltage and its value is 3.1 V: {"voltage": {"index": 3, "value": 3.1}}.

  • ai_get_all (only in Poll mode): obtains the value of all analog inputs.

Example:

To obtain the value of all analog inputs: {"ai_get_all": "status"}.

In this case, the first three inputs are configured as voltage and the rest as current. Each one has a different value: <code>{"values": [{"voltage": {"index": 0, "value": 5.2}}, {"voltage": {"index": 1, "value": 3.2}} , {"voltage": {"index": 2, "value": 4.8}}, {"current": {"index": 3, "value": 0.3}}, {"current": {"index": 4, "value": 0.2}}, {"current": {"index": 5, "value": 0.4}}, {"current": {"index": 6, "value": 0.3}} ]}.

3.2 Available functions for relays

  • relay_get_one: obtains the status of a single relay.

Example:

To obtain the status of the relay 0: {"relay_get_one": 0}.

In this case, the response tells us that relay 0 is deactivated:{"status": {"index":0, "value":false}}.

  • relay_get_all: obtains the status of all relays.

Example:

To obtain the status of all relays: {"relay_get_all": "status"}.

In this case, only the first relay is activated: {"all_status": [true, false]}.

  • relay_set_one: activates or deactivates a single relay. On completion of action, input message with result is sent to output port.

Example 1:

Activates relay 0: {"relay_set_one": {"index": 0, "value": true}}.

The output tells us that relay 0 is activated: {"status": {"index":0, "value":true}}.

Example 2:

Deactivates relay 0: {"relay_set_one": {"index": 0, "value": false}}.

Output tells us that relay 0 is deactivated: {"status": {"index":0, "value":false}}.

  • relay_set: activates or deactivates some relays. On completion of action, input message with result is sent to output port.

As parameters, it has an 8-element array of one among the following: - true: activates relay. - false: deactivates relay. - null: does not change the status of the relay.

Example:

Activate the first and deactivate the second:{relay_set: [true, false]}. Output tells us all relay status: {"all_status":[true,false]}.

  • relay_set_all: activates or deactivates all relays. On completion of action, input message with result is sent to output port.

Example 1:

To activate all relays:{"relay_set_all": true}.

Output tells us all relay status: {"all_status":[true,true]}.

Example 2:

To deactivate all relays: {"relay_set_all": false}.

Output tells us all relay status: {"all_status":[false,false]}.

4) 12 Analog inputs API

12 Analog inputs node

Connects to a 12AI eMOD module (datasheet) to manage the 12 analog inputs individually or jointly.

It allows to manage the following functionalities on the module:

  • Set the input mode (current or voltage) for each analog input and also the working mode.
  • Get the input value for one or all inputs.

12AI can operate in two different ways:

  • In Poll mode, user starts the flow and asks for data when he needs it.
  • In Event mode user configures certain condition when he wants to be notified and it is the module that notifies him when it has been met.

In Node-RED, this module can operate in the following working modes:

  • Poll.
  • [Event] Time interval: module keeps notifying values of all inputs in a fixed time interval.
  • [Event] Value threshold: module notifies when the measured value in any input surpases the threshold from last notification.
  • [Event] Value within range: module notifies when the measured value in any input enters within a value range.
  • [Event] Value out of range: module notifies when the measured value in any input falls out of a value range.

4.1 Available functions

  • ai_get_one (only in Poll mode: obtains the value of a single analog input.

Example:

To obtain the value of a single analog input: {"ai_get_one": 3}.

In this case, fourth analog input is configured as voltage and its value is 3.1 V: {"voltage": {"index": 3, "value": 3.1}}.

  • ai_get_all (only in Poll mode): obtains the value of all analog inputs.

Example:

To obtain the value of all analog inputs: {"ai_get_all": "status"}.

In this case, the first three inputs are configured as voltage and the rest as current. Each one has a different value: {"values": [{"voltage": {"index": 0, "value": 5.2}}, {"voltage": {"index": 1, "value": 3.2}} , {"voltage": {"index": 2, "value": 4.8}}, {"current": {"index": 3, "value": 0.3}}, {"current": {"index": 4, "value": 0.2}}, {"current": {"index": 5, "value": 0.4}}, {"current": {"index": 6, "value": 0.3}} ]}.

5) 5 Digital inputs and 2 Power relays API

5 Digital inputs and 2 power relays node

Connects to a 5DI+2PR eMOD module (datasheet) to manage the 5 digital inputs and 2 relays individually or jointly.

It allows to manage the following functionalities on the module:

  • Configure module parameters.
  • Get the input value for one or all inputs.
  • Poll input status for one or all inputs.
  • Poll pulse counter for one or all inputs.
  • Reset pulse counters.
  • Set the pulse width for each relay.
  • Activate or deactivate one, some or all relays.

The 5DI eMOD module can operate in two different ways:

  • In Poll mode, user starts the flow and asks for data when he needs it.
  • In Event mode user configures certain condition when he wants to be notified and it is the module that notifies him when it has been met.

Module can operate in the following working modes:

  • Poll.
  • [Event] Time interval: module keeps notifying values of all inputs in a fixed time interval.
  • [Event] Input value change: module notifies when a digital input changes.
  • [Event] Pulse count change: module notifies when the pulse counter surpases the threshold from last notification.

5.1 Available functions for the digital inputs

  • di_get_one (only in Poll mode): obtains the status or pulse count of a single digital input.

Example 1:

To obtain the status of a single digital input: {"di_get_one": {"index": 3, "mode": "status"}}.

In this case, fourth digital input is in high state: {"status": {"index": 3, "value": true}}.

Example 2:

To obtain the pulse count of a digital input: {"di_get_one": {"index": 3, "mode": "pulse_count"}}.

In this case, pulse count of fourth digital input is 15: {"counter": {"index": 3, "value": 15}}.

  • di_get_all (only in Poll mode): obtains the status or pulse count of all digital inputs.

Example 1:

To obtain the status of all digital input:{"di_get_all": "status"}.

In this case, only fourth digital input is high state: {"all_status": [false, false, false, true, false, false, false, false, false, false]}.

Example 2:

To obtain the pulse count of all digital input: {"di_get_all": "pulse_count"}.

Function returns following pulse counts:{"all_counters": [0, 5, 10, 2, 23, 5, 71, 3, 0, 0]}.

  • reset_pulse_count: resets one or all inputs.

Example 1:

Resets the ninth input: {"reset_pulse_count": 8}.

Example 2:

Resets all input: {"reset_pulse_count": "all"}.

Available functions for relays

  • relay_get_one: obtains the status of a single relay.

Example:

To obtain the status of the relay 0: {"relay_get_one": 0}.

In this case, the response tells us that relay 0 is deactivated:{"status": {"index":0, "value":false}}.

  • relay_get_all: obtains the status of all relays.

Example:

To obtain the status of all relays: {"relay_get_all": "status"}.

In this case, only the first relay is activated:{"all_status": [true, false]}.

  • relay_set_one: activates or deactivates a single relay. On completion of action, input message with result is sent to output port.

Example 1:

Activates relay 0: {"relay_set_one": {"index": 0, "value": true}}.

Output tells us that relay 0 is activated: {"status": {"index":0, "value":true}}.

Example 2:

Deactivates relay 0: {"relay_set_one": {"index": 0, "value": false}}.

Output tells us that relay 0 is deactivated: {"status": {"index":0, "value":false}}.

  • relay_set: activates or deactivates some relays. On completion of action, input message with result is sent to output port.

As a parameters, an 2-element array of one among the following: - true: activates relay. - false: deactivates relay. - null: does not change the status of the relay.

Example:

Activate the first and deactivate the second:{"relay_set": [true, false]}.

Output tells us all relay status:{"all_status":[true,false]}.

  • relay_set_all: activates or deactivates all relays. On completion of action, input message with result is sent to output port.

Example 1:

To activate all relays: {"relay_set_all": true}.

Output tells us all relay status: {"all_status":[true,true]}.

Example 2:

To deactivate all relays: {"relay_set_all": false}.

Output tells us all relay status: {"all_status":[false,false]}.

6) 3 Phase Energy Meter API

3 Phase Energy Meter node

Connects to 3 Phase Energy Meter module (datasheet) and gets the parameters.

It allows getting a subgroup of parameters relative to the instant POWER on:

  • Phase One (alias "L1").
  • Phase Two (alias "L2").
  • Phase Three (alias "L3").
  • The combination of three phases (alias "L123").

It allows getting a subgroup of parameters relative to the accumulated ENERGY on:

  • Phase One (alias "L1").
  • Phase Two (alias "L2").
  • Phase Three (alias "L3").
  • The combination of three phases (alias "L123").

Finally, it also allows getting the eight subgroups of parameters above, ALL together.

Note

Energy meters can be set back to 0, with the reset command.

6.1 Available functions for Energy Meter

  • get: Gets "power" or "energy" related parameters of any phase ("L1", "L2", "L3") or their combined results ("L123"). It can also get all parameters at once.

Examples:

To obtain the parameters relative to accumulated energy on phases one, two and three:{"get": ["energy_L1", "energy_L2", "energy_L3"]}.

To obtain the parameters relative to accumulated energy on phases one, two and three and their combined results: {"get": ["energy_L1", "energy_L2", "energy_L3", "energy_L123"]}.

To obtain the parameters relative to instant power on phase one: {"get": ["power_L1"]}.

To obtain all the parameters: {"get": ["power_L1", "power_L2", "power_L3", "power_L123", "energy_L1", "energy_L2", "energy_L3", "energy_L123"]}. Also, simpler: {"get": "all"}.

  • reset: Set all energy meter counters back to 0:

{"reset": ""}

6.2 Return value for "get" command

The "get" command triggers a msg.payload at the output of the node EM3, which is a list of key parameters with their corresponding values. Every parameter is autodescriptive, the prefix indicating the mesured variable, the suffix indicating the input phase, L1, L2, L3 or L123 (for combined calculated values). An example of output is as follows:

{"voltage_L1": "230.2", "current_L1": "491", "frequency_L1": "50", "cosine_L1": "0.997", "angle_L1" : "85.61", ...}

6.3 Main parameters and unit measurements

Parameter Unit
Voltage V
Current A
Frequency Hz
active_power kW
aparent_power kVA
reactive_power kVAr
inductive_power kVArl
capacitive_power kWh
active_energy kVAh
aparent_energy kVArh
reactive_energy kVArlh
inductive_energy kVArlh


7) 6_3 Level Meters API

6_3 Level Meters node

Connects to Level Meters Module to get the status of 6 conductive sensors and 3 current type sensors. The module also have a 4-20 mA analog input.

7.1 Configuration

Conductive sensors must be configured to have a detection resistance ranging from 1 to 50 kohms, and a refill resistance ranging from 2 to 100 kohm. Usually refill resistance doubles detection resistance.

Current sensors can be configured to be of type Namur, Capacitive or PNP. Namur type should be powered to 8.2V, whereas Capacitive and PNP type should be powered to 24V.

7.2 Commands

This 6_3LM+1AI allows getting individual status of any of the 9 level meters. Meter numbers from 1 to 6 refers to conductive sensors, while meter numbers from 7 to 9 refers to current type sensors.

It allows getting all meter status at once. See examples below.

Finally, it also allows getting current of the 4-20 mA analog input.

7.3 Available functions for Level Meter

  • lm_get_one: Gets the input status of the corresponding level meter (from 1 to 9).

Example:

To obtain the status of the conductive level meter 4: {"lm_get_one": 4}.

Return message payload is: {"status": {"index": 4, "value": true}}. If value equals true, the sensor is detecting, otherwise it returns "value": false.

  • lm_get_all: Gets the input status of all level meters (from 1 to 9).

Example:

You can use: {"lm_get_all": ""}. Return message payload is:

{"all_status": [ {"index": 1, "value": true}, {"index": 2, "value": false}, {"index": 3, "value": false}, {"index": 4, "value": true}, {"index": 5, "value": false}, {"index": 6, "value": true}, {"index": 7, "value": false}, {"index": 8, "value": true}, {"index": 9, "value": true} ]}

If value equals true, the sensor is detecting, otherwise the corresponding position in the array object will be false.

  • ai_get: Gets the current of the analog input. Resulting value is in mA units.

Example:

You can use: {"ai_get": ""}. Return message payload is: {"current": { "index": 1, "value": "6.723"}}.

8) SuperCap Node

SuperCap node

Allows Supercapacitor module (datasheet) notifies when there is a power source change.

It has one output:

  • Power source change: notifies when power source switches from external power (AC) to internal (if supercap module is present), or vice versa.

When power source switches from external power (AC) to internal (supercap), message payload is:

`{"external_power":false}

When power source switches from internal (supercap) to external power (AC), message payload is:

`{"external_power":true}

Restrictions

Working Mode

  • One module entries only can be configured in polling mode or event mode, but never with both work modes at the same time.
  • If a module has inputs and outputs, the inputs can be configured in event mode and there will be no problem operating on the outputs in polling mode.
  • In polling mode there can be as many nodes as we need, but they have to use the same configuration node.
  • In event mode there can only be one node, which is the one that receives events.

Recommendation

Create only one configuration node (e.g. 10DI-Config). If several are created only one will be active.

Multiple modules of the same type

  • In both polling and event mode, two or more nodes associated to different hardware modules (with the same type) can share the same configuration node. This can simplify configuration where possible.
  • The same hardware module cannot have two different configuration nodes assigned.