1
votes

My purpose is to make a subscription so that accumulator server from the Orion's test package receives notifications when attribute's value exceeds a treshold. If I am correct this is not implemented on NGSI v1. So on NGSI v2 when I use the above subscription payload with the suitable Service and Subservice Headers

 {  
   "description":"mydescription",
   "subject":{  
      "entities":[  
         {  
            "id":"room1",
            "type":"room",
            "isPattern":"false"
         }
      ],
      "condition":{  
         "attrs":[  
            "temperature"
         ],
         "expression":{  
            "q":"temperature>5"
         }
      }
   },
   "notification":{  
      "http":{  
         "url":"http://myURL:1028/accumulate"
      },
      "attrs":[  

      ]
   },
   "expires":"2040-01 
        -01T14:00:00.00Z"
}

I don't receive any notifications on accumulator server. Without the expression I receive notifications on first place when i make the subscription and also every time that the attribute's value is changed.

Orion version: 1.7.0

I have also tried the solution with noCache for subscriptions on Context Broker.

EDIT: When I query the context for room1

curl -X GET localhost:1026/v2/entities/room1 -H "Fiware-Service: myService" -H "Fiware-ServicePath: /mySubService"

this is the reply from Orion.

{  
   "id":"room1",
   "type":"room",
   "TimeInstant":{  
      "type":"ISO8601",
      "value":"2017-05-15T13:33:35.632Z",
      "metadata":{  

      }
   },
   "temperature":{  
      "type":"float",
      "value":"6",
      "metadata":{  
         "TimeInstant":{  
            "type":"ISO8601",
            "value":"2017-05-15T13:33:35.632Z"
         }
      }
   }
}
1
Could you edit your question post in order to show how the entity looks like, pls? Typically, the result of a GET /v2/entities/room1 operation. Thx!fgalan

1 Answers

1
votes

Note that your temperature is a string ("6") and not a number. In order the filter to work it should be a number, i.e. you have to get:

{  
..
   "temperature":{  
      "type": "float",
      "value": 6,
..
}

Note that the NGSIv1 API doesn't allow to create/update attributes with JSON native types other than strings (a more detailed explanation can be found in this presentation, "Native JSON datatypes" slides) If you attemp to create/update temperature as a number using NGSIv1 operations, it will be casted to string.

Thus you have to use the NGSIv2 API (which doesn't have such limitation) in order to create/update attributes with numeric values. For instance, the following request will update temperature value to the (numeric) value 6:

PUT /v2/entities/room1/attrs/temperature

{  
  "type": "float",
  "value": 6
}