Jump to content









Photo

Listener Event for Device Status change?

Listener Event

  • Please log in to reply
27 replies to this topic

#21 jpastor

jpastor

    Development leader

  • Administrators
  • 159 posts

Posted 14 July 2014 - 07:28 AM

Hello jlanton

 

We didn't have detected any problem with the listener. Could you share with us the listener you are trying to run?
 
Thanks!


#22 jlanton

jlanton

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 15 July 2014 - 10:58 AM

I've changed it already, but it was as follow:

hope you can use for troubleshooting

thanks


 
if expression:

context.data.reason.status == 'ok'
 
then expression: (executed properly when the status change to OK)
 
import com.carriots.sdk.utils.Email;

def email = new Email();
email.to="******@***";
email.subject="Problema arreglado, ya se reciben datos de "+context.data.name;
email.message="Se han vuelto a recibir datos del sensor \nContext Data: "+context.data;
email.send();


else expression (never executed, nor alarm triggered when the status change to disconnected or the like)
 
import com.carriots.sdk.utils.SMS;
def sms = new Sms();
sms.to="00346******";
sms.message="No recibo datos del sensor!!!!!!! haz algo!!";
sms.send();



#23 jlanton

jlanton

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 15 July 2014 - 11:02 AM

now the listener is as follow, I stop using the "else" and put the logic in the then expression:
 
if expression: TRUE
 
then expression:
import com.carriots.sdk.utils.Email;

def email = new Email();
email.to="***@***";

if (context.data.reason.status == 'ok')
{
email.subject="Problema arreglado, ya se reciben datos de "+context.data.name;
email.message="Se han vuelto a recibir datos del sensor\nContext Data: "+context.data;
}
else
{
email.subject="no se ha recibido datos del sensor en los ultimos minutos";
email.message="Parece que hay un problema de conexion de "+context.data.name+" \n Context Data: "+context
}

email.send();

 

 

ELSE Expression :empty



#24 alvaro

alvaro

    Carriots CTO

  • Administrators
  • 72 posts

Posted 15 July 2014 - 03:33 PM

Hi jlanton.

 

It seems that your else expression contains a typo:

 

import com.carriots.sdk.utils.SMS;

 

should be

 

import com.carriots.sdk.utils.Sms;

 

You should have an alarm in your alarm list with a compilation error with something like "unable to resolve class com.carriots.sdk.utils.SMS"

 

You can use the Console to test your code: https://cpanel.carriots.com/terminal/

 

Hope it helps.

 

Enjoy Carriots!


Alvaro Everlet

Carriots CTO


#25 jlanton

jlanton

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 16 July 2014 - 10:25 AM

thanks Alvaro. I'll try that feature (I didn't know)

but It seems that the problem is elsewhere because no alarm was recorded in the alarm log and even I put some typos in the "else expression" on purpose to trigger the alarm and nothing happened, the code wasn't executed and no alarm triggered.

I'll try it again and let you know

thanks!



#26 jlanton

jlanton

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 16 July 2014 - 10:41 AM

Alvaro, I've put the code in the two sections (then and else) and now the code is executed correctly, the typo migth be preventing the code to be exectued, the alarm triggered and written in the log

now it is ok!

 

thanks for your help 



#27 alvaro

alvaro

    Carriots CTO

  • Administrators
  • 72 posts

Posted 16 July 2014 - 11:06 AM

Great! Thank you for reporting.

 

Enjoy Carriots!


Alvaro Everlet

Carriots CTO


#28 snehal.jabade

snehal.jabade

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 09 March 2016 - 03:48 AM

   I have implemented the use case where user enter his name, mail id & temperature on a form using PHP & on the click of submit button data is getting inserted into carriot.On other side Arduino-yun is sending temperature sensor's data continuously to carriots which is also working fine.Now I want to create a listener which will compare the user specific temperature with the temperature sensed by temperature sensor.If the temperature of Arduino's temerature sensor is greater then the user specific temperature then I am sending mail to that perticular user.
 
  I have created the listener as follow:
 
  If expression: context.data.Temperature > context.data.UserTemperature (Temperature is send by arduino-yun & UserTemperature is user   entered value on the form)
 
  Then expression:
import com.carriots.sdk.utils.Email;
def email = new Email ();
email.to= context.data.UserEmail; //UserEmail is userspecificemail
email.subject="Temperature Status";
email.message="Current temperature is  "+context.data.UserTemperature + "˚C.Please Switch on the AC";
email.send();
 
I am getting an Alarm which says:"Listener UserSpecificListener@**:Cannot invoke method tokenize on null object"
 
Would you please help me out to solve this issue?
 
-Snehal






Also tagged with one or more of these keywords: Listener, Event

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users