node-red-contrib-entitypreviousdata 1.0.4
A custom Node-RED node that gives the previous entity information.
node-red-contrib-entitypreviousdata
A custom Node-RED node that retrieves the previous entity data from a PostgreSQL database for a given entity and timestamp.
Install
Run the following command in your Node-RED user directory (typically ~/.node-red):
npm install node-red-contrib-entitypreviousdata
Or install directly from the Node-RED Manage Palette by searching for node-red-contrib-entitypreviousdata.
Usage
The Entity Previous Data node queries a PostgreSQL EntityData table to find the most recent record for a given EntityId that occurred before the provided TimeStamp.
Input (msg.payload)
| Field | Type | Description |
|---|---|---|
EntityId |
string | The entity to look up |
TimeStamp |
string/date | The current timestamp; the node finds the record just before this |
Outputs
- Output 1 (Success):
msg.payloadcontains the original payload merged withmsg.payload.metadata.previousDataandmsg.payload.metadata.previousTimestamp. - Output 2 (Failure):
msg.payloadwithmsg.metadata.errorset if no record is found or a DB error occurs.
Configuration
| Field | Description |
|---|---|
| Host | PostgreSQL host (default: localhost) |
| Port | PostgreSQL port (default: 5432) |
| User | Database user (default: postgres) |
| Password | Database password |
| Database | Database name (default: testdb) |
Requirements
- Node.js >= 12
- Node-RED >= 1.0.0
- PostgreSQL database with an
EntityDatatable containingEntityId,TimeStamp, andDatacolumns
License
MIT