Skip to content

Commit

Permalink
Merge 03ae518 into be62481
Browse files Browse the repository at this point in the history
  • Loading branch information
fisuda committed Jan 29, 2023
2 parents be62481 + 03ae518 commit 97f2a13
Show file tree
Hide file tree
Showing 9 changed files with 496 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -23,13 +23,13 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup node
run: npm ci

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## node-red-contrib-letsfiware-NGSI v0.6.0-next

- ADD NGSI to dashboard custom node (#43)
- UPDATE documentation about open-apis node (#44)
- ADD Historical context custom node (#42)
- ADD FIWARE GE type option (#40)
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -23,6 +23,7 @@ Node-RED implementation for FIWARE Open APIs
- [NGSI Subscription](docs/custom_nodes/ngsi_subscription.md)
- [Historical context](docs/custom_nodes/historical_context.md)
- [NGSI to Worldmap](docs/custom_nodes/ngsi_to_worldmap.md)
- [NGSI to Dashboard](docs/custom_nodes/ngsi_to_dashboard.md)
- [NGSI GTFS realtime](docs/custom_nodes/ngsi_gtfs_realtime.md)
- [FIWARE version](docs/custom_nodes/fiware_version.md)

Expand Down
179 changes: 179 additions & 0 deletions docs/custom_nodes/ngsi_to_dashboard.md
@@ -0,0 +1,179 @@
# NGSI to dashboard

This custom node is a simple node that allows to transform context data to data for the dashboard node.

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-01.png)

## Properties

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-02.png)

- `name`: a name for a node instance
- `Input type`: an input type: `Entity (normalized)`, `Notification` or `Historical context`
- `Attributes`: list of attributes
- `Name to replace`: list of names to replace attribute names

## Inputs / Outputs

### NGSI Entity node

#### input

If you want to transform context data received form NGSI Entity node, set `Entity (normalized)` to Input type.

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-03.png)

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-04.png)

```
{
"id": "urn:ngsi-ld:WeatherObserved:sensor001",
"type": "Sensor",
"relativeHumidity": {
"type": "Number",
"value": 32,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-01-28T04:53:13.301Z"
}
}
},
"temperature": {
"type": "Number",
"value": 22.4,
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-01-28T04:53:13.301Z"
}
}
}
}
```

#### Output

```
{ "payload": 22.4, "topic": "temperature", "timestamp": 1674881593301 }
{ "payload": 32, "topic": "relativeHumidity", "timestamp": 1674881593301 }
```

### Notification

#### input

If you want to transform notification data received from Orion Context Broker, set `Notification` to Input type.

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-05.png)

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-06.png)

```
{
"subscriptionId": "57edf55231cee478fe9fff1f",
"data": [
{
"id": "urn:ngsi-ld:WeatherObserved:sensor001",
"type": "Sensor",
"relativeHumidity": {
"type": "Number",
"value": 32,
"metadata": {
"dateModified": {
"type": "DateTime",
"value": "2023-01-28T04:53:13.301Z"
}
}
},
"temperature": {
"type": "Number",
"value": 22.4,
"metadata": {
"dateModified": {
"type": "DateTime",
"value": "2023-01-28T04:53:13.301Z"
}
}
}
}
]
}
```

#### Output
```
{ "payload": 22.4, "topic": "temperature", "timestamp": 1674881593301 }
{ "payload": 32, "topic": "relativeHumidity", "timestamp": 1674881593301 }
```

### Historical context node

#### input

If you want to transform historical context data received form Historical context node, set `Historical` to Input type.

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-07.png)

![](https://raw.githubusercontent.com/lets-fiware/node-red-contrib-letsfiware-NGSI/gh-pages/images/ngsi-to-dashboard-08.png)

```
{
"attrName": "temperature",
"dataType": "raw",
"type": "StructuredValue",
"value": [
{
"_id": "63d45c3587f5b27f576ed498",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 22.2,
"recvTime": "2023-01-27T23:20:21.201Z"
},
{
"_id": "63d45c3787f5b27f576ed49e",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 22.2,
"recvTime": "2023-01-27T23:20:23.199Z"
},
{
"_id": "63d45c3987f5b27f576ed4a4",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 22.2,
"recvTime": "2023-01-27T23:20:25.201Z"
}
]
}
```

#### Output

```
[
{
"series": [
"temperature"
],
"labels": [],
"data": [
[
{
"x": 1674861621201,
"y": 22.2
},
{
"x": 1674861623199,
"y": 22.2
},
{
"x": 1674861625201,
"y": 22.2
}
]
]
}
]
```
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"lint": "./node_modules/eslint/bin/eslint.js --ext .json --ext .js src || eslint -c .eslintrc.html.json --ext .html src",
"test": "./node_modules/nyc/bin/nyc.js --reporter=html --reporter=text ./node_modules/mocha/bin/mocha.js \"test/unit/**/*_spec.js\"",
"coverage": "mkdir coverage && ./node_modules/nyc/bin/nyc.js --reporter=text-lcov ./node_modules/mocha/bin/mocha.js \"test/unit/**/*_spec.js\" > ./coverage/coverage.lcov"
"coverage": "mkdir -p coverage && ./node_modules/nyc/bin/nyc.js --reporter=text-lcov ./node_modules/mocha/bin/mocha.js \"test/unit/**/*_spec.js\" > ./coverage/coverage.lcov"
},
"node-red": {
"version": ">=1.0.0",
Expand All @@ -18,6 +18,7 @@
"NGSI-to-worldmap": "src/nodes/NGSI/to-worldmap/to-worldmap.js",
"FIWARE-version": "src/nodes/NGSI/version/version.js",
"Historical-Context": "src/nodes/NGSI/historical-context/historical-context.js",
"NGSI-to-dashboard": "src/nodes/NGSI/to-dashboard/to-dashboard.js",
"Open-APIs": "src/nodes/NGSI/open-apis/open-apis.js"
}
},
Expand Down Expand Up @@ -59,4 +60,4 @@
"engines": {
"node": ">=12"
}
}
}
55 changes: 55 additions & 0 deletions src/nodes/NGSI/to-dashboard/icons/fiware-non-free.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 97f2a13

Please sign in to comment.