6.5 Use Case: Subscribe to be notified when temperature is above/below threshold in building (UC4)
Use Case 4 (UC4) is subscribing to changes in the indoor temperature of a building, filtering for an indoor temperature greater than 30°C, i.e. only once the threshold of 30°C has been crossed, notifications are going to be sent. Figure 6.5-1 visualizes this scenario.
Figure 6.5-1: UC4 - Subscribe to be notified whenever temperature changes and is above threshold
The NGSI-LD Entity Type used is Building, also from the NGSI-LD compatible Smart Data Model[i.5] on Smart Cities. For this purpose, we are interested in the following properties of Building: - category - floorsAboveGround - floorsBelowGround - indoorTemperature - location - owner
The subscribe operation for the indoor temperature of the Building with the id "building-a85e3da145c1" and the filter on indoorTemperature greater that 30 looks as follows:
{
"id": "urn:ngsi-ld:Subscription:storeSubscription4",
"type": "Subscription",
"entities": [
{
"id": "urn:ngsi-ld:Building:building-a85e3da145c1",
"type": "Building"
}
],
"watchedAttributes": ["indoorTemperature"],
"q": "indoorTemperature>30",
"notification": {
"format": "normalized",
"endpoint": {
"uri": "http://localhost:8080",
"accept": "application/json"
}
}
}
{
"id": "urn:ngsi-ld:Notification:515236543545",
"type": "Notification",
"subscriptionId": "urn:ngsi-ld:Subscription:storeSubscription4",
"data": {
"id": "urn:ngsi-ld:Building:building-a85e3da145c1",
"type": "Building",
"address": {
"type": "Property",
"value": {
"addressLocality": "London",
"postalCode": "EC4N 8AF",
"streetAddress": "25 Walbrook"
}
},
"category": {
"type": "Property",
"value": [
"office"
]
},
“indoorTemperature": {
"type": "Property",
"value": 31.3,
}
...
}
}
In order to do this, the application needs to know the following: - Data model: - type: Building - Property: indoorTemperature (and its value, e.g. that Celsius scale is used) - Root URL: localhost:9090