node-red-contrib-datacake-helpers
Version:
Node-RED nodes to interact with the Datacake GraphQL API for KPIs and device stats. Includes other helper nodes for device management.
86 lines (64 loc) • 2.19 kB
Markdown
# Node-RED Datacake GraphQL Nodes
A collection of Node-RED nodes for interacting with the Datacake GraphQL API.
## Installation
You can install these nodes directly from the Node-RED palette manager, or via npm:
```bash
npm install node-red-contrib-datacake-helpers
```
## Available Nodes
### Datacake GraphQL Config
Configuration node that stores your Datacake API credentials:
- Workspace UUID
- Workspace Token
### Datacake GraphQL Device
This node fetches data from a Datacake device using the GraphQL API.
Features:
- Dynamic device selection from your Datacake workspace
- Retrieves all device measurements
- Outputs a flattened structure for easy use in flows
- Includes metadata for each measurement (type, unit, etc.)
### Datacake GraphQL Product Stats
This node calculates statistics across multiple devices in a product.
Features:
- Fetches data from all devices in a Datacake product
- Filter devices by tags
- Calculate min, max, average, sum, and count for selected fields
- Provides fleet health statistics (total, online, offline devices)
### Datacake Device Post
This node sends data to a Datacake device using the HTTP API.
Features:
- Post data to a device using its HTTP API endpoint
- Supports both object and primitive payloads
- Automatically formats the payload according to Datacake requirements
## Usage
1. Add a Datacake GraphQL Config node and configure your Datacake API credentials
2. Add a Datacake GraphQL Device node and select your configuration
3. Choose a device from the dropdown (populated from your Datacake workspace)
4. Connect any input to trigger fetching the latest device data
5. Use the flattened output data in your flow
## Example Output
```json
{
"id": "device-uuid",
"serialNumber": "70B3D5CDD000185E",
"verboseName": "My Device Name",
"location": "Device Location",
"online": true,
"lastHeard": "2023-05-04T04:31:15.929264+00:00",
"lastHeardThreshold": 2880,
"BATTERY": 3.3,
"BATTERY_metadata": {
"id": "field-uuid",
"type": "FLOAT",
"unit": ""
},
"TEMPERATURE": 14.64,
"TEMPERATURE_metadata": {
"id": "field-uuid",
"type": "FLOAT",
"unit": "°C"
}
}
```
## License
MIT