1

I am using CEP to modify type date fields with update mode.

Entities:

{
  "id":"controller",
  "type":"control",
  "lasmodify":{
    "type":"DataTime",
    "value":""
    }
 }

{
   "id":"Device01",
   "type":"device",
   "id_controller":{
      "type":"Text",
      "value":"controller01"
    }
   "datemodify":{
   "type":"DataTime",
   "value":"2018-12-04T20:05:00.00Z"
   }
 }

I want that the Device01 subscription is shooted, the controller01 attribute lasmodify will be modified with datemodify of device01 entity.

Thank you very much in advance Best regard.

Jason Fox
  • 5,115
  • 1
  • 15
  • 34

1 Answers1

1

If i have understood correctly, you want to update the controler when CEP recibes a device change notification. The solution should be something similar to this rule:

{
   "name":"update_rule",
   "text":"select ev.controler? as controlerID, ev.datemodify? as newDate, \"update_rule\" as ruleName from pattern [every ev=iotEvent(type=\"device\")]",
   "action":{
      "type":"update",
      "parameters":{
          "id":"${controlerID}",
          "type":"control",
          "attributes": [
                {
                "name":"lasmodify",
                "type":"DataTime"
                "value":"${newDate}"
                }
          ]
      }
   }
}

I don't know what version of Perseo you use, but using the latest fiware image for perseo-fe and perseo-core, you could omit the ruleName and use NGSIv2

{
   "name":"update_rule",
   "text":"select ev.controler? as controlerID, ev.datemodify? as newDate from pattern [every ev=iotEvent(type=\"device\")]",
   "action":{
      "type":"update",
      "parameters":{
          "id":"${controlerID}",
          "type":"control",
          "version": "2",
          "attributes": [
                {
                "name":"lasmodify",
                "type":"DataTime"
                "value":"${newDate}"
                }
          ]
      }
   }
}