Difference between revisions of "Open Control Architecture"

From Open Source Controls Wiki
Jump to navigation Jump to search
Line 2: Line 2:


----Communications between systems is performed using MQTT using a standardised 5 level topic structure.  '''''network''' / '''node''' / '''device''' / '''group''' / '''key'''.''
----Communications between systems is performed using MQTT using a standardised 5 level topic structure.  '''''network''' / '''node''' / '''device''' / '''group''' / '''key'''.''
----
----A device managing communications is called a node.
*A device managing communications is called a node.
----Data from within a node or from connected devices is assigned a local network identifier of "'''''local'''''" so that the node can separate internal traffic and readings from general traffic. This is stored under '''''global.localNetworkId'''''
----
----The external network identifier is stored under '''''global.networkId'''''
*Data from within a node or from connected devices is assigned a local network identifier of "'''''local'''''" so that the node can separate internal traffic and readings from general traffic. This is stored under '''''global.localNetworkId'''''
----The node identifier is stored under '''''global.node'''''
----
----The topic group is used to define the type of data, including  
* The external network identifier is stored under '''''global.networkId'''''
*'''''dat''''' (operational data)
----
*'''''stat''''' (statistics and status)
* The node identifier is stored under '''''global.node'''''
*'''''settings'''''
----
*'''''cmd''''' (a command)
*The topic group is used to define the type of data, including  
*'''''set''''' (change a setting)
**'''''dat''''' (operational data)
*'''''system''''' (software and networking)
**'''''stat''''' (statistics and status)
**'''''settings'''''
**'''''cmd''''' (a command)
**'''''set''''' (change a setting)
**'''''system''''' (software and networking)  


<br />
<br />
----
----Attributes for data may be loaded from a central index (GitHub hosted), providing additional information such as units and descriptions.  This is to avoid the need to locally describe data, and to assist in compatibility.
*Attributes for data may be loaded from a central index (GitHub hosted), providing additional information such as units and descriptions.  This is to avoid the need to locally describe data, and to assist in compatibility.
----Controls software is written in Node-RED.
----
----Within Node-RED, data and attributes are stored within the '''''global.readings''''' object.
*Controls software is written in Node-RED.
----Persistent settings for a node (or application) are held on disk and in the '''''global.settings''''' object. This is for local operational settings.
----
----Persistent settings for local devices are held on disk and in the '''''global.deviceSettings''''' object, and are specific to a device (or node).
*Within Node-RED, data and attributes are stored within the '''''global.readings''''' object.
----Data within the readings object is nested according to the topic (excluding the node as more than one node may publish data on a device).
----
*Persistent settings for a node (or application) are held on disk and in the '''''global.settings''''' object. This is for local operational settings.
----
*Persistent settings for local devices are held on disk and in the '''''global.deviceSettings''''' object, and are specific to a device (or node).
----
*Data within the readings object is nested according to the topic (excluding the node as more than one node may publish data on a device).
 
  e.g. a message with a topic '''''myNetwork'''/'''node123'''/'''myDevice'''/'''dat'''/'''outputTemperature'''''  would be stored in (global).'''''readings'''.'''myNetwork'''.'''myDevice'''.'''dat'''.'''outputTemperature'''.'''value'''''
  e.g. a message with a topic '''''myNetwork'''/'''node123'''/'''myDevice'''/'''dat'''/'''outputTemperature'''''  would be stored in (global).'''''readings'''.'''myNetwork'''.'''myDevice'''.'''dat'''.'''outputTemperature'''.'''value'''''
Internally, message topics can be truncated and the network and node will be filled in. The data group will be assumed to be "'''''dat"''''' if not supplied, representing operational data.   
Internally, message topics can be truncated and the network and node will be filled in. The data group will be assumed to be "'''''dat"''''' if not supplied, representing operational data.   

Revision as of 19:12, 30 May 2022

The Open Controls described on this site works as follows:


Communications between systems is performed using MQTT using a standardised 5 level topic structure. network / node / device / group / key.


A device managing communications is called a node.


Data from within a node or from connected devices is assigned a local network identifier of "local" so that the node can separate internal traffic and readings from general traffic. This is stored under global.localNetworkId


The external network identifier is stored under global.networkId


The node identifier is stored under global.node


The topic group is used to define the type of data, including

  • dat (operational data)
  • stat (statistics and status)
  • settings
  • cmd (a command)
  • set (change a setting)
  • system (software and networking)



Attributes for data may be loaded from a central index (GitHub hosted), providing additional information such as units and descriptions. This is to avoid the need to locally describe data, and to assist in compatibility.


Controls software is written in Node-RED.


Within Node-RED, data and attributes are stored within the global.readings object.


Persistent settings for a node (or application) are held on disk and in the global.settings object. This is for local operational settings.


Persistent settings for local devices are held on disk and in the global.deviceSettings object, and are specific to a device (or node).


Data within the readings object is nested according to the topic (excluding the node as more than one node may publish data on a device).

e.g. a message with a topic myNetwork/node123/myDevice/dat/outputTemperature  would be stored in (global).readings.myNetwork.myDevice.dat.outputTemperature.value

Internally, message topics can be truncated and the network and node will be filled in. The data group will be assumed to be "dat" if not supplied, representing operational data.

e.g. a message with a topic setpoint  would be stored in (global).readings.local.myNode.dat.setpoint.value

Within Node-RED the current data can be viewed in the data explorer.

Readings1.png

The following code could be used to read data and its attributes for output.

 var localNetworkId = global.get("localNetworkId");
 var node = global.get("node");

 var reading = global.get("readings." + localNetworkId + "." + node + ".dat.outputTemperature");

 var output = "The value of " + reading.title + " is " + reading.value + reading.units;  
 // "The value of Output Temperature is 35°C