This example demonstrates how to create a street camera sensor entity and subscribe to its updates.
Create a new subscription template for the speed camera sensor entity with the following minimal settings:
Field | Value |
---|---|
Name | Speed Alert > 80 km/h |
Broker URL | your_broker_url (e.g., http://127.0.0.1:1026 ) |
Field | Value |
---|---|
Entities | [{ "idPattern": ".*", "type": "SpeedCameraSensor" }] |
Query | speed > 80 |
Field | Value |
---|---|
Subject | Speed Alert from ${id} |
Description | The speed camera sensor ${id} detected a speed of ${speed} km/h. |
Issue geometry | { "type": "Feature", "geometry": "${location}" } |
Attachments | [{"filename": "SC_${timestamp}.jpg", "url": "${image}"}] |
Sent from user | api_user (select the user who will send the issue) |
Create the subscription template and publish it.
Note: When authentication is required, provide the Authorization
header with
-H "Authorization: Bearer ${BROKER_TOKEN}" \
curl -iX POST "${BROKER_URL}/v2/entities" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${BROKER_TOKEN}" \
-H "Fiware-Service: ${FIWARE_SERVICE}" \
-H "Fiware-ServicePath: ${FIWARE_SERVICEPATH}" \
-d '{
"id": "urn:ngsi-ld:SpeedCameraSensor:001",
"type": "SpeedCameraSensor",
"image": {
"value": "https://raw.githubusercontent.com/gtt-project/redmine_gtt_fiware/main/doc/examples/sebastian-pociecha-QS55ASupd6E-unsplash.jpg",
"type": "URL"
},
"speed": {
"value": 50,
"type": "Number"
},
"location": {
"value": {
"type": "Point",
"coordinates": [135.27666, 34.72483]
},
"type": "geo:json"
},
"timestamp": {
"value": "2024-05-14T12:00:00Z",
"type": "DateTime"
}
}'
Photo by Sebastian Pociecha on Unsplash
curl -iX PATCH \
"${BROKER_URL}/v2/entities/urn:ngsi-ld:SpeedCameraSensor:001/attrs" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${BROKER_TOKEN}" \
-H "Fiware-Service: ${FIWARE_SERVICE}" \
-H "Fiware-ServicePath: ${FIWARE_SERVICEPATH}" \
-d '{
"speed": {
"value": 90.0,
"type": "Number"
}
}'
curl -iX DELETE \
"${BROKER_URL}/v2/entities/urn:ngsi-ld:SpeedCameraSensor:001" \
-H "Authorization: Bearer ${BROKER_TOKEN}" \
-H "Fiware-Service: ${FIWARE_SERVICE}" \
-H "Fiware-ServicePath: ${FIWARE_SERVICEPATH}"