Agent COSM alternative

Has anyone managed to build an agent alternative for the COSM node?
I really could use a hint to accomplish a solution like this, to bring actions as much as possible into the cloud.
I’m a terrible coder and it’s even worse coding in squirrel. :((

There’s actually an example on devwiki:

Thanks Hugo,
I missed that one.
But by looking at the example I don’t understand anything of it.
By example, I suppose I have to supply an API key. How?
And what is that “foo.csv”?
I admit, I will never win a coding prize, and am trying to learn a bit by looking at examples, but in this case it’s too complicated for me.

@DolfTraanberg I also had some issues setting up a COSM data feed, but finally got it working. The hard part is the confusing way you set up the feed in COSM. Once that is set up, entering the values in the Planner COSM node is straightforward.

Here is what I did:

  1. Create login by registering at
  2. Once logged in, click on your username in the upper right corner of the web page (not very intuitive :wink:
  3. This opens a drop down with menu items: Console, Keys,Debug,etc.
  4. Click on “Console”
  5. On the console page click the “+Device/Feed” blue button to create a new feed.
  6. On the "What type of device/feed do you want to add? popup, click on “Something Else”
  7. On the “Configure your Device/Feed”, set the “No, I will push to COSM” radio button and click “Next”
  8. On the “Give your device a title” textbox, enter the name of your feed, such as “MyFeed” (Write this name down) and click “Next”
  9. On the next screen, enter a description if you like and click “Next”
  10. Finally, click on “Create” button and it will show the FeedID (Write this number down).
  11. Now you need an API key, click on your Username again and select “Keys” menu item.
  12. Create a key by clicking on the “+Key” blue button.
  13. On the next screen, enter any Label, Use any Public Feed, and “all” for Access privileges (Update later with more restrictions for better security).
  14. Finally, click “Create” to create the key and cut and paste the new API key into a text file for later user.

15 Now you have all the values you need to enter into the COSM Node:

The API Key
The Feed ID
The datastream is the name of the data feed you created “MyFeed”

Hope that helps and that I wrote these down correctly.

apineda thanks very much.
you made a great afford writing this down.
Unfortunately, this way I have learned how to use ( )
What I want is to do the same with Agents, because I’ve also learned that COSM allows a maximum of feeds in a minute, so I have to do some programming to make sure I don’t overfeed COSM and lose some data. Those calculations I would like to be made by the agent, so I that have more resources available for the Imp.
(I don’t know why, in spite of the heartbeat function I use, the Imp goes offline too much). It is essential for me, that the solution is as fail proof as possible.

Hmm. You’re right, that example was incomplete. I’ve updated it and this should then work.

If your device drops offline even with a watchdog, this isn’t good - we have been running soak tests on imps and they’ve been online for easily over a month (basically since we started running the tests). They obviously need to stay online forever and we are finding and fixing bugs that prevent this as we go along.

Thanks Hugo, the devwiki example makes sense now.

Hugo, I won’t jump in conclusions at this stage. It is very well possible I have to move the Imp to an other location for better wifi signal.
But it’s strange that it started with OS v. 14.

Thanks for updating the wiki, indeed it makes sense for me now.
Maybe there is still a change i’ll be understanding some of this squirrel in the end :slight_smile:

Hi, I have just been working on Cosm and it seems to default to expecting json.
For csv I have got working the following:
local req = http.put(“”,
{“X-ApiKey”: “API_KEY”, “Content-Type”: “text/csv”},
Hope that helps

The wiki doesn’t work for me. This does. Thanks strider34:

function reportsuccess(response){device.send(“success”, response.statuscode);}
function sendtocosm(value){
local v=value.tostring();
//local req = http.put(“”, … “Temp,”+v);
local req = http.put(“”,
{“X-ApiKey”:“31DmvkEz1g”, “Content-Type”:“text/csv”}, //same for both methods

Thanks to strider34 and sbright33, I was able to collect some code to publish 2 datastreams. I know I’m a horrible coder, so any enhancements are more than welcome