Utilizing Email End Point


#1

Email End Point - How to Send device data as JSON?

I understand thinger.io is fairly new, but I am having some difficulty finding any information on how to utilize this feature for simple email alerts on high temp to include the temperature that triggered the call.

I was able to get a reading from the DHT22 sensor.

  thing["Status"] >>[](pson& out){
out["Humidity"]=dht.readHumidity();
  };
unsigned long lastCheck = 0;

void loop() {
  delay(1000);
  thing.handle();
  unsigned long currentTS = millis();
  if(currentTS-lastCheck>=60000){
    lastCheck=currentTS;
    if(dht.readHumidity()>55){
      digitalWrite(6,HIGH);
       thing.call_endpoint("high_humidity_alert",thing["Status"]);
    }
  };

Can this reading be utilized in the Custom Body of the email endpoint?


#2

Hi, this a recent feature and it is not currently documented.

To add a value in your email body, or a HTTP endpoint, you can set the key value inside double brackets, like {{Humidity}} in your case. You can add multiple values if you want. You can also set values without a key ({{}}) if your resource or data does not define an output key.

Hope it helps! :slight_smile:


#3

Hi @alvarolb I can’t get this working, I don’t know why, I have declarated in sketch’s setup this

  thing["Level"] >> outputValue(actualRelative);

And calling the endpoint, by this:

  thing.call_endpoint("endpoint_id");

At enpoint configuration this:

The actual level is {{Level}}% 
The actual level is {{actualRelative}}% 

I putted both definitions in order to discard which is the one that works, but when I receive the email, I got this

The actual level is {{Level}}%
The actual level is {{actualRelative}}%

I’m working with cloud server.

Thanks in advance.


#4

Hi @ega, take a look to the documentation for sending data to endpoints. You need to include this information when calling the endpoint, so the back-end can use the information provided. Let me know if the following documentation solve your problem:

http://docs.thinger.io/arduino/#coding-using-endpoints-sending-data-to-endpoints


#5

Yes!! many thanks for helping me even with this obvious doubts

I’ve invoqued the endpoint by this code

thing.call_endpoint("endpoint_id",thing["Level"]);

And I’ve received the data in mail using the following code:

The actual level is {{}}% 

@alvarolb Can I help you to improve the documentation? because I think this is really easy (after get it done of course), but before that I didn’t saw it really clear how can I get this done.

I would like to add an example of how to use email endpoint, with the sketch code, and email code, I think that is more easy for a beginner to understand this seeing a complete example.


#6

Hi @ega! nice it worked! :slight_smile:

Any contribution you do to the documentation is really welcome! If you know how Github works, you can share it directly, or I can upload your docs and pictures if you want. Let me know!


#7

I tried to do it directly, I guess you should approve the modifications before they become public :wink:


#8

Hi @ega! I did not see the pull request. You probably submit the commit/push to your own fork. is it?


#9

Yes, I think that I made the pull request, let me know if you still don’t see it


#10

Hey @alvarolb, you did not tell me if you could see the github pull request dude!