Waziup / WaziCloud

WAZIUP Cloud and local platform
31 stars 28 forks source link

empty sensor historical data #147

Closed j-forster closed 7 years ago

j-forster commented 7 years ago

Hi, a query for historical data like described on https://github.com/Waziup/Platform/blob/master/broker/broker_test.md#historical-data always returns an empty array. Any ideas about that? I set values using https://github.com/Waziup/Platform/blob/master/broker/broker_test.md#insert-datapoint (not for this sensor), but the query result remains empty. Thanks in advance!

j-forster commented 7 years ago

As i see, to collect historical data, a subscription has to be made. https://github.com/Waziup/Platform/blob/master/broker/broker_test.md#entity-subscription

cdupont commented 7 years ago

Yes, exactly

j-forster commented 7 years ago

But http://broker.waziup.io/v1/subscribeContext can not be reached from web apps because of cors. And no api-endpoint ( http://www.waziup.io/documentation/api/api-reference/) addresses subscribeContext?

cdupont commented 7 years ago

You can use http://orion.waziup.io/v1/data/subscriptions Look at the example here: https://github.com/Waziup/Platform/blob/master/broker/SMS_demo.md It's using Orion API V2.

j-forster commented 7 years ago

I'm not sure how to modify https://github.com/Waziup/Platform/blob/master/broker/broker_test.md#entity-subscription to work with http://orion.waziup.io/v1/data/subscriptions ... It's not as easy as:

"notification": {
    "httpCustom": {
      "url": "http://cygnus:5050/notify"
    },
    "attrs": [
      "temperature"
    ]
  }

There is no example on using http://cygnus:5050/notify with v1/data/subscriptions, or?

cdupont commented 7 years ago

I updated the example in https://github.com/Waziup/Platform/blob/master/broker/broker_test.md to use API V2

cdupont commented 7 years ago

You should change broker.waziup.io/v2 -> orion.waziup.io/v1/data Could you try?

cdupont commented 7 years ago

Actually I think we should change Waziup API to authorize access to both V1 and V2 of Orion

j-forster commented 7 years ago

As every feature of V1 is implemented & enhanced in V2, I don't think it's necessary to do so. But all the examples in the docs should use the newer V2 api. Its confusing for me to see V1 for creating subscriptions and V2 for querying data.

j-forster commented 7 years ago

I created a subscription > it confirms GET /subscriptions:

{
  "id": "591095eb48c8c17369619dcd",
  "description": "A subscription to register historical data about Sensor1",
  "expires": "2040-01-01T14:00:00.00Z",
  "status": "active",
  "subject": {
    "entities": [
      {
        "id": "Sensor1",
        "type": "SensingDevice"
      }
    ],
    "condition": {
      "attrs": [
        "temperature"
      ]
    }
  },
  "notification": {
    "timesSent": 4,
    "lastNotification": "2017-05-08T16:12:12.00Z",
    "attrs": [
      "temperature"
    ],
    "attrsFormat": "normalized",
    "http": {
      "url": "http://cygnus:5050/notify"
    },
    "lastSuccess": "2017-05-08T16:12:12.00Z"
  },
  "throttling": 5
}

With timesSent = 4 it looks good to me, but the historical query remains empty:

{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
          {
            "name": "temperature",
            "values": []
          }
        ],
        "id": "Sensor1",
        "isPattern": false,
        "type": "SensingDevice"
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}
sabrine2020 commented 7 years ago

Hello, We need to use the NGSI v1 for the subscription creation since cygnus does not support NGSI v2, it supports only NGSI v1. @cdupont : could you re-update the example to use NGSI v1 and it is good to mention this information in the example to avoid confusion. Thanks.

Best, Sabrine

cdupont commented 7 years ago

Wow, thanks Sabrine for the info. I'll revert it. So I guess we need to expose both APIs.