Skip to content

Smart Stream completion

Konstantinos Vandikas edited this page Jul 23, 2015 · 1 revision

Smart stream completion is a feature utilised mainly by the iot-framework-gui in order to auto-complete necessary information when creating a new stream such as min,max values, accuracy etc. The feature is utilised when the user chooses "New Stream from Resource" when creating a new stream. Since the new stream is created out of a resource, the idea is to re-use the information related to that resource in order to fill out this information.

So let's say we are trying to create an AM2302 resource. From the manufacturer's page we can find out that "the AM2302 is a wired version of the DHT22, in large plastic body. It is a basic, low-cost digital temperature and humidity sensor".

The previous text can be used as a plain text description. The manufacturer is Aosong. This information can be used in order to generate the AM2302 resource.

curl -XPOST 'localhost:8000/resources' -H "Content-type: application/json" -d '{"description": "The AM2302 is a wired version of the DHT22, in a large plastic body. It is a basic, low-cost digital temperature and humidity sensor.", "manufacturer": "Aosong", "model": "AM2302", "name": "AM2302"}'

Once we have created the resource, we will receive an id as a response, in this case let's say the id is 123. The next step is to create two sample streams for it, since it can handle both temperature and humidity. The following two curl commands take care of that:

curl -XPOST 'localhost:8000/streams' -H "Content-type: application/json" -d '{"accuracy":"2","data_type":"application/json","description":"this is a test","location":{"lat":59.357709,"lon":17.998635799999988},"max_val":"100","min_val":"0","name":"humidity","parser":"","polling":false,"polling_freq":0,"private":false,"resource":{"resource_type":"123"},"tags":"humidity","type":"humidity","unit":"http://purl.oclc.org/NET/muo/ucum/unit/fraction/percent","uri":""}'
curl -XPOST 'localhost:8000/streams' -H "Content-type: application/json" -d '{"accuracy":"0.5","data_type":"application/json","description":"this is a test","location":{"lat":59.357709,"lon":17.998635799999988},"max_val":"80","min_val":"-40","name":"temperature","parser":"","polling":false,"polling_freq":0,"private":false,"resource":{"resource_type":"123"},"tags":"temperature","type":"http://purl.oclc.org/NET/muo/ucum/unit/temperature/degree-Celsius","unit":"Celsius","uri":""}'

Having filled out this information, the next time we try to create an AM2302 resource, the gui will automatically propose to generate the humidity and temperature stream and it will fill out automatically the corresponding information for min,max value, tags and accuracy.

Clone this wiki locally