From 8a5d92852238c7e0f0b651e98a2b88a7881ac4ef Mon Sep 17 00:00:00 2001 From: Ranim Naimi <156652078+ranim-n@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:09:09 +0200 Subject: [PATCH] feat: add entities and context for alerts received when a threshold is breached (#15) * first samples of alert related entities + context * reformatted files * basic fixes * upgrade core context to v1.8 --- jsonld-contexts/cud-eco-gagnant.jsonld | 3 +- ngsild-payloads/alert.jsonld | 32 ++++++++++++++++++++ ngsild-payloads/event.jsonld | 41 ++++++++++++++++++++++++++ ngsild-payloads/subscription.jsonld | 20 +++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 ngsild-payloads/alert.jsonld create mode 100644 ngsild-payloads/event.jsonld create mode 100644 ngsild-payloads/subscription.jsonld diff --git a/jsonld-contexts/cud-eco-gagnant.jsonld b/jsonld-contexts/cud-eco-gagnant.jsonld index d7100b7..b05495c 100644 --- a/jsonld-contexts/cud-eco-gagnant.jsonld +++ b/jsonld-contexts/cud-eco-gagnant.jsonld @@ -6,6 +6,7 @@ "https://easy-global-market.github.io/cud-data-models/jsonld-contexts/user.jsonld", "https://easy-global-market.github.io/cud-data-models/jsonld-contexts/fluid.jsonld", "https://easy-global-market.github.io/cud-data-models/jsonld-contexts/consent.jsonld", - "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld" + "https://easy-global-market.github.io/ngsild-api-data-models/alertEventRisk/jsonld-contexts/alertEventRisk.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.8.jsonld" ] } diff --git a/ngsild-payloads/alert.jsonld b/ngsild-payloads/alert.jsonld new file mode 100644 index 0000000..6b80c7f --- /dev/null +++ b/ngsild-payloads/alert.jsonld @@ -0,0 +1,32 @@ +{ + "id": "urn:ngsi-ld:Alert:7a08a58e-e613-4cc0-9160-8a2636970721", + "type": "Alert", + "hasSubject": { + "type": "Relationship", + "object": "urn:ngsi-ld:Event:7a08a58e-e613-4cc0-9160-8a2636970721" + }, + "mailingList": { + "type": "Property", + "value": { + "email": [ + "user@email.com" + ] + } + }, + "message": { + "type": "JsonProperty", + "json": { + "body": "[body of the mail]", + "subject": "[ALERT] Electricity consumption exceeded set value" + } + }, + "occurrence": { + "type": "Property", + "value": true, + "observedAt": "2024-04-18T16:40:00Z" + }, + "triggeredBy": { + "type": "Property", + "value": "urn:ngsi-ld:Subscription:7a08a58e-e613-4cc0-9160-8a2636970721" + } +} \ No newline at end of file diff --git a/ngsild-payloads/event.jsonld b/ngsild-payloads/event.jsonld new file mode 100644 index 0000000..195116c --- /dev/null +++ b/ngsild-payloads/event.jsonld @@ -0,0 +1,41 @@ +{ + "id": "urn:ngsi-ld:Event:7a08a58e-e613-4cc0-9160-8a2636970721", + "type": [ + "Event", + "AggregatedThresholdBreach" + ], + "hasSubject": { + "type": "Relationship", + "watchedProperties": { + "type": "Property", + "value": "consumption" + }, + "object": "urn:ngsi-ld:FluidMonitoring:Electricity:7a08a58e-e613-4cc0-9160-8a2636970721" + }, + "occurrence": { + "type": "Property", + "value": "510", + "observedAt": "2024-04-18T16:39:00Z" + }, + "status": { + "type": "Property", + "value": "true", + "observedAt": "2024-04-18T16:39:00Z" + }, + "thresholdType": { + "type": "Property", + "value": "Upper" + }, + "thresholdValue": { + "type": "Property", + "value": "500" + }, + "thresholdAggrPeriod": { + "type": "Property", + "value": "P7D" + }, + "hasAlert": { + "type": "Relationship", + "object": "urn:ngsi-ld:Alert:7a08a58e-e613-4cc0-9160-8a2636970721" + } +} \ No newline at end of file diff --git a/ngsild-payloads/subscription.jsonld b/ngsild-payloads/subscription.jsonld new file mode 100644 index 0000000..0871d37 --- /dev/null +++ b/ngsild-payloads/subscription.jsonld @@ -0,0 +1,20 @@ +{ + "id": "urn:ngsi-ld:Subscription:7a08a58e-e613-4cc0-9160-8a2636970721", + "type": "Subscription", + "entities": [ + { + "id": "urn:ngsi-ld:Event:7a08a58e-e613-4cc0-9160-8a2636970721", + "type": "AggregatedThresholdBreach" + } + ], + "watchedAttributes": [ + "occurrence" + ], + "notification": { + "format": "normalized", + "endpoint": { + "uri": "http://localhost:8080", + "accept": "application/json" + } + } +} \ No newline at end of file