Skip to main content
Data Operations · NGSI-LD and Stellio

Stellio Subscriptions

The node manages existing NGSI-LD subscriptions of the Stellio context broker: list all subscriptions, read a single one, activate or deactivate it via PATCH and delete it. The operation can be fixed in the dialog or controlled per message via msg.operation. A Browser tab shows all subscriptions with their status directly in the editor.

  • Subscriptions
  • Manage
  • NGSI-LD
Node type
stellio-subscriptions
Package
@htag/node-red-contrib-hypertegrity-ngsi-ld
Inputs / outputs
1 / 1
Target
Stellio context broker (NGSI-LD)

When to use this node​

Subscriptions make the context broker report changes to entities to a receiver, for example a time series database. Over time, subscriptions accumulate that need to be checked, paused temporarily or removed. This node bundles the required operations; new subscriptions are created with Stellio Create Subscription.

Typical use cases are:

  • Inventory: list all subscriptions of a tenant with entity type, watched attributes and status.
  • Maintenance window: deactivate a subscription while data is being cleaned up and reactivate it afterwards.
  • Clean-up: delete orphaned subscriptions by id.

How the node works​

1

Determine operation

msg.operation or the configured action chooses between List, Get, Set Active and Delete.

2

Send request

The node calls /ngsi-ld/v1/subscriptions via GET, PATCH or DELETE with tenant and Link headers.

3

Emit response

Response body, status code, headers and, for List, the result count are written into the message.

Result: A subscription list, a single subscription or the result of the change in msg.payload.

The node is message-driven and triggers exactly one request per incoming message. The Browser tab loads up to 100 subscriptions through the admin endpoints of the Node-RED server and allows activating, deactivating and deleting via buttons.

Configuration​

The dialog has the tabs Aktion (action) and Browser. All stored fields are on the action tab.

Action tab​

FieldTypeDefaultMeaning
NameTextemptyDisplay name of the node in the flow. Without a name the node shows Subscriptions: <action>.
API URLText${STELLIO_API_URL}Base URL of the broker. Placeholders ${VAR} are replaced at runtime; empty means fallback to the environment variable STELLIO_API_URL.
TenantTextemptyValue of the NGSILD-Tenant header. Empty: default tenant of the broker.
ContextTextsee belowJSON-LD context for the Link header on List, Get and Set Active.
Aktion (action)SelectListList (all subscriptions), Get (single by id), Set Active (switch active/inactive), Delete (delete).
LimitNumber100Maximum number for List.
Subscription IDTextemptyFull URN for Get, Set Active and Delete, for example urn:ngsi-ld:Subscription:001.
StatusSelectaktiv (active)Target state for Set Active: aktiv (active) or inaktiv (inactive).

Default values of the URL fields:

Context: https://context.${DOMAIN}/main-context.jsonld

Which fields are visible depends on the action: Limit for List, Subscription ID for Get, Set Active and Delete, Status only for Set Active.

Browser tab​

Laden (load) lists up to 100 subscriptions with id, description, entity types, watched attributes, q-filter, context and status (active/inactive). Each row offers buttons for details, activate/deactivate and delete (with confirmation).

Changes from the editor

Activating, deactivating and deleting in the Browser tab take effect on the broker immediately, without deploying the flow. They require the Node-RED permission stellio.write.

Input​

Values from the message take precedence over the configuration.

PropertyTypeMeaning
msg.operationstringlist, get, setActive or delete. Unknown values are treated as list.
msg.apiUrlstringOverrides the API URL.
msg.tenantstringOverrides the tenant.
msg.contextUrlstringOverrides the context (Link header).
msg.subscriptionIdstringOverrides the Subscription ID (Get, Set Active, Delete).
msg.activeboolean or string "true"/"false"Target state for setActive. If the property is missing, the Status selection from the dialog applies.
msg.limitnumberOverrides the limit for list.
msg.payloadanyNot evaluated; the message only acts as trigger.

Output​

The message is extended with the broker response. For list, msg.payload contains for example:

[
{
"id": "urn:ngsi-ld:Subscription:7f3a2c1e-0000-4000-8000-000000000001",
"type": "Subscription",
"subscriptionName": "Subscription for entity type WeatherObserved.",
"entities": [{"type": "WeatherObserved"}],
"watchedAttributes": ["dateObserved"],
"notificationTrigger": ["entityCreated", "attributeCreated", "attributeUpdated"],
"isActive": true,
"notification": {
"format": "normalized",
"endpoint": {"uri": "https://quantumleap.exampletown.example/v2/notify", "accept": "application/json"}
},
"@context": ["https://context.exampletown.example/main-context.jsonld"]
}
]
FieldMeaning
msg.payloadlist: array of subscription objects. get: one subscription object. setActive: broker response body; for an empty response (204) an object with id and isActive. delete: usually empty.
msg.statusCodeHTTP status code of the response.
msg.headersResponse headers of the broker.
msg.countResult count from the NGSILD-Results-Count header for list, if the broker sends it.

Example flow​

The package ships with a shared example flow for several Stellio nodes. You can import it in Node-RED via Menu → Import → Examples → @htag/node-red-contrib-hypertegrity-ngsi-ld → stellio-helper-nodes. The Stellio Subscriptions node is included in this shared example, but it is not wired as a complete Inject-Subscriptions-Debug flow; the following excerpt therefore shows a minimal wiring of this node. Alternatively, download stellio-helper-nodes.json and import it via Menu → Import.

Step 1

Inject

An Inject node triggers the query manually or at a fixed interval.

Step 2

Stellio Subscriptions

The node lists up to 100 subscriptions of the tenant using the List action.

Step 3

Debug

A Debug node shows the subscription list and the result count.

Show minimal wiring as JSON
[
{"id": "tab1", "type": "tab", "label": "Stellio Helper Nodes", "disabled": false, "info": ""},
{"id": "inject1", "type": "inject", "z": "tab1", "name": "", "props": [{"p": "payload"}], "repeat": "", "once": false, "payload": "", "payloadType": "date", "x": 160, "y": 320, "wires": [["subs1"]]},
{"id": "subs1", "type": "stellio-subscriptions", "z": "tab1", "name": "", "apiUrl": "${STELLIO_API_URL}", "tenant": "default_dataspace", "contextUrl": "https://context.${DOMAIN}/main-context.jsonld", "operation": "list", "limit": 100, "subscriptionId": "", "active": "true", "x": 420, "y": 320, "wires": [["debug1"]]},
{"id": "debug1", "type": "debug", "z": "tab1", "name": "Subscriptions", "active": true, "tosidebar": true, "complete": "true", "targetType": "full", "x": 680, "y": 320, "wires": []}
]

Status and errors​

IndicatorMeaning
Blue dot "list…" (or name of the operation)The request is running.
Green dot "3 subscriptions"List successful; the number is the result count from the response header.
Green dot "status 204" (or another 2xx code)Get, Set Active or Delete successful.
Yellow ring "status 404" (or another status code)The broker answered with an error status, for example because the subscription does not exist. The message is still sent.
Red ring "error" with error "operation "get" requires a subscriptionId" (likewise for delete and setActive)The Subscription ID is missing.
Red ring "error" with error "Stellio API URL is required (config, msg.apiUrl or STELLIO_API_URL)"No API URL could be determined.
Red ring "error" with network message or "timeout of 30000ms exceeded"Broker unreachable or no answer within 30 seconds.

Typical broker status codes: 200 (List, Get), 204 (Set Active, Delete successful), 400 (invalid id or invalid PATCH body), 404 (subscription not found). Errors are reported via node.error and can be handled with a Catch node.

Notes​

  • Set Active: The node sends via PATCH the body type: Subscription with isActive: true or false. Other properties of the subscription remain unchanged.
  • Authentication: The node sends no authentication headers; access to the broker is protected by the network or an upstream gateway.
  • Timeout: Requests abort after 30 seconds.
  • Admin endpoints: The Browser tab uses /stellio-helper/browse (permission stellio.read) and /stellio-helper/mutate (permission stellio.write) of the Node-RED server.
  • Personal data: Subscriptions contain notification URLs and descriptions; names or contact details do not belong there. Check third-party systems before passing on subscription lists.

References​