Jump to content


How to use Console ?

  • Please log in to reply
2 replies to this topic

#1 jcodatalog



  • Members
  • Pip
  • 3 posts

Posted 16 March 2018 - 09:07 PM

Hello Carriots users,


I would appreciate to have some examples of the console use :


For example, when I write in 'Write your code here:'




the answer in 'SDK engine response:' is


Message: exception
Details: 'Cannot get property \'device\' on null object'


I have the same error for all similar commands :





answer :


Message: exception
Details: 'Cannot get property \'Vbat\' on null object'


Could you please help me to write the missing command to access the stream data  ('Vbat' for example) ?


What I want to do is to send an Email alert when the low battery voltage of my Arduino sending data to Carriots is detected.

To do that I use the if expression :



The Email is sent. That works.


I need also to add in the Email message an old data from my stream :


For example :

At 09:00 I send "Vbat":3.1

At 10:00 I send "test":"Ok"

At 10:30 I send "Vbat":3.1

At 11:00 I send "Vbat":2.9


At this moment, The Email alert is sent because Vbat<3.0 ,

In the email.message , I added these lines :


email.message+="Data 'test' = ";




But I get in the Email :

Data 'test'=null


How can I access to 'old' data in the stream ?







#2 jpastor


    Development leader

  • Administrators
  • 176 posts

Posted 26 March 2018 - 09:55 AM

Hi Friend


In the console you could run all the operations that you want, but keep in mind that you do not have context (because there is no stream). So you will have to replace this context with real values.


Regarding your question, you can get the stored data, an example would be:


import com.carriots.sdk.Stream

def streams = Stream.findBy(["_t": "str", "device": "defaultDevice@userdemo.userdemo", "max": "3", "order": "-1"])
//return streams[1].data
return streams



Run this example in the console to check the results

Hope it helps!

#3 jcodatalog



  • Members
  • Pip
  • 3 posts

Posted Yesterday, 06:57 PM

Hi jpastor,


Thanks for your answer.

I will try the console again asap !




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users