Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-8990

[fiware-stackoverflow] Fiware Orion context broker subscriptions condition does not work

    Details

      Description

      Created question in FIWARE Q/A platform on 25-05-2016 at 14:05
      Please, ANSWER this question AT https://stackoverflow.com/questions/37437225/fiware-orion-context-broker-subscriptions-condition-does-not-work

      Question:
      Fiware Orion context broker subscriptions condition does not work

      Description:
      I am using Orion Context Broker version 1.1.0

      I had the only entity in my DB:

      {
      "id"=>"Room1",
      "type"=>"Room",
      "temperature"=>{"type"=>"none", "value"=>10, "metadata"=>{}}
      }

      I did not have any subscription.

      Then I created 3 subscriptions:

      [
      {
      "subject"=>{"entities"=>[

      {"id"=>"Room1", "idPattern"=>"", "type"=>""}],
      "condition"=>{"attrs"=>["temperature"], "expression"=>{"q"=>"temperature>10"}}}
      },
      {
      "subject"=>{"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}

      ],
      "condition"=>{"attrs"=>["temperature"], "expression"=>

      {"q"=>"temperature<10"}

      }}
      },
      {
      "subject"=>{"entities"=>[

      {"id"=>"Room1", "idPattern"=>"", "type"=>""}],
      "condition"=>{"attrs"=>["temperature"], "expression"=>{"q"=>"temperature==10"}}}
      }
      ]


      As you can see, the difference is only in the expressions: temperature>10, temperature<10, temperature==10.

      So that any time I change the Room1 temperature I should have only one subscription triggering the notification.

      But it does not work as it should !!!

      Each time I change the temperature, I have all 3 notifications.

      However, when subscriptions were created, only one of them triggered a notification, depending on the temperature value of the Room1. It worked as expected.

      But when Room1 temperature is changed, it does not work correctly and triggers all 3 notifications.

      Edit:
      Full output of the GET /v2/subscriptions operation:

      [
      {
      "id"=>"574716a22fe8cdc00a696a94",
      "expires"=>"2017-04-05T14:00:00.00Z",
      "status"=>"active",
      "subject"=>{
      "entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}

      ],
      "condition"=>{"attrs"=>["temperature"],
      "expression"=>{"q"=>"temperature>10"}}
      },
      "notification"=>{"attrs"=>["temperature"], "http"=>{"url"=>"http://localhost:1028/accumulate"}},
      "throttling"=>5
      },
      {
      "id"=>"574716a22fe8cdc00a696a95",
      "expires"=>"2017-04-05T14:00:00.00Z",
      "status"=>"active",
      "subject"=>{
      "entities"=>[

      {"id"=>"Room1", "idPattern"=>"", "type"=>""}],
      "condition"=>{"attrs"=>["temperature"],
      "expression"=>{"q"=>"temperature<10"}}
      },
      "notification"=>{"attrs"=>["temperature"], "http"=>{"url"=>"http://localhost:1028/accumulate"}},
      "throttling"=>5},
      {
      "id"=>"574716a22fe8cdc00a696a96",
      "expires"=>"2017-04-05T14:00:00.00Z",
      "status"=>"active",
      "subject"=>{
      "entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}

      ],
      "condition"=>{"attrs"=>["temperature"],
      "expression"=>{"q"=>"temperature==10"}}
      },
      "notification"=>{"timesSent"=>2, "lastNotification"=>"2016-05-26T15:30:42.00Z", "attrs"=>["temperature"], "http"=>{"url"=>"http://localhost:1028/accumulate"}},
      "throttling"=>5
      }
      ]

      Edit2: Add some scenario:

      Changed Room1 temperature to 11
      Had the same output, but
      [...

      {"timesSent"=>1}..., ...{"timesSent"=>1}

      ..., ...

      {"timesSent"=>3}...]
      Changed Room1 temperature to 10
      Had the same output, but
      [...{"timesSent"=>2}..., ...{"timesSent"=>2}..., ...{"timesSent"=>4}...]
      Changed Room1 temperature to 9
      Had the same output, but
      [...{"timesSent"=>3}

      ..., ...

      {"timesSent"=>3}

      ..., ...

      {"timesSent"=>5}

      ...]

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 15:14|CREATED monitor | # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 15:14|CREATED monitor | # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 18:10|UPDATED status: transition Answer| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 18:10|UPDATED status: transition Answer| # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 21:10|UPDATED status: transition Finish| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 21:10|UPDATED status: transition Finish| # answers= 1, accepted answer= True

          People

          • Assignee:
            backlogmanager Backlog Manager
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: