Cosm (Pachube)
- Create new account on Cosm (cosm.com)
- Add device
- Something else
- No, I will push data to Cosm
- Mark generated device ID (61803)
- Create new datastream
- select suitable datastream identification (e.g., 1) (id = 1 will be used in examples below)
- set proper kWH, C…
- Save
- You can try to set directly some value to particular datastream (click on orange box)
- for testing only
- simulates push of value from attached device
- Obtain your API keys
- Got to my profile
- Keys
- Add new key
- Set key name and proper restrictions (anyone who will have this key will be restricted by that).
- E.g., if you need to be able to update current value of datastream, Update right must be checked
- E.G. if you like to provide read access, but no modification right, check Read
- E.g., KobDv-Ti81JcqpNA7Y_fFfwtbSOSAKxQSkk3dlFlcEpwWT0g is key that allows update to device with ID 61803 and datastream with id 1
- Howto: Push first value to data stream (as described in https://cosm.com/docs/quickstart/curl.html)
- Download curl tool (curl.haxx.se)
- Create new file cosm.json with following content (id is 34 as created above, current_value is value to be set):
- cosm.json
{ "version":"1.0.0", "datastreams":[ {"id":"1", "current_value":"100"}, ] }
- Execute:
- this command will upload cosm.json to Cosm server, parse it and update current_value to 100
curl --request PUT --data-binary @cosm.json --header "X-ApiKey: KobDv-Ti81JcqpNA7Y_fFfwtbSOSAKxQSkk3dlFlcEpwWT0g" --verbose http://api.cosm.com/v2/feeds/61804
- Howto: Obtain data from Cosm
- Execute:
- this will obtain json formatted response with current state from selected datastream
curl --request GET --header "X-ApiKey: KobDv-Ti81JcqpNA7Y_fFfwtbSOSAKxQSkk3dlFlcEpwWT0g" http://api.cosm.com/v2/feeds/61804
Result:
{"title":"test2","status":"frozen","creator":"https://cosm.com/users/eskel77","datastreams": [{"at":"2012-05-31T20:33:40.722753Z","max_value":"100.0",--->"current_value":"100"<---,"id":"1","min_value":"10.0"}], "location":{"domain":"physical"},"created":"2012-05-31T20:10:52.272380Z","feed":"https:/api.cosm.com/v2/feeds61804.json", "private":"false","id":61804,"version":"1.0.0","updated":"2012-05-31T20:33:40.734846Z"}
- Obtain last 30 days in csv: https://cosm.com/feeds/feed_ID/datastreams/stream_ID/archive.csv (e.g., https://cosm.com/feeds/61803/datastreams/1/archive.csv)
- state only every 15 minutes is stored (raw data are not obtained)