New IFTTT apps: Do Button, Do Camera, Do Note

The folks at IFTTT have done it again. :smile: They have new iOS/Android apps released today and the one named Do Button is perfect for IoT.

While IFTTT is for automating background tasks, the Do Button is for when you want manual control over your (for example) Spark Core. It will allow you to create a recipe that does one of two things:

  • Publish a private event
  • Call a function

Then this is wrapped into a single button. And even better, you can put this in Notification Center on iOS so it’s always a flick away. Similarly, on Android it can be a widget on your homescreen.

Create a recipe:

Completed Do Button in the app:

Do Buttons in Notification Center:

5 Likes

Nice, but only 3 buttons :frowning:
Should be without limit…

1 Like

True, more would be nice. The 3 you do get couldn’t be any easier to set up and use. I didn’t even have to login since it was smart enough to recognize my account from the IF (formerly IFTTT) app. Very slick.

2 Likes

agreed... very slick.

Now we are talking about IFTTT channels, I really can’t seem to understand the ‘Yo’ channel. I tried to search it but that gives bs results. Anyone here that understands it?

It serves the same purpose as the “do” app. If you “yo” the IFTTT account, then your specified trigger will be triggered.

I saw that too, but it didn’t quite make things understandable. Sure, a button is understandable but “Yo IFTTT” or “add IFTTT to your Yo contacts”. Searching for Yo in the app store isn’t really helpfull and shouting Yo at my phone doesn’t work either :wink:

This is a great addition to the Spark universe of compatibility.

so a practical use of the do button… toggle a lamp on/off… but you don’t know its present state?

create a function that toggles the powerState of your device:


int devicePower(String powerState)
{
  int value = powerState.toInt();  //for example params=2  //(toggles the state versus zero or one which sets it)
  Serial.println(value);
  if (value == 0 || value == 1)
  {
    deviceState = value;
    return value;
  }
  else if (value == 2)
  {
    deviceState = !deviceState;
    return deviceState;
  }
  else return -1;
}

and then use Pushingbox to return to you a notification with the present state!

void notification()
{
  if (client.connect("api.pushingbox.com", 80))
  {
    if (phoneyState == true)
    //"http://api.pushingbox.com/pushingbox?devid=<DEVICE_ID>"
      out("GET /pushingbox?devid=<DEVICE_ID> HTTP/1.1\r\n");
    else
    //"http://api.pushingbox.com/pushingbox?devid=<DEVICE_ID_2>"
    out("GET /pushingbox?devid=<DEVICE_ID_2> HTTP/1.1\r\n");
    out("Host: api.pushingbox.com\r\n");
    out("User-Agent: Spark/1.0\r\n");
    out("Content-Type: text/html\r\n");
    out("Connection: close\r\n\r\n");
    //DEBUG_PRINTLN("Closing Connection...");
    in(reply, 3000);
  }
  //
}

void out(const char *s)
{
  client.write( (const uint8_t*)s, strlen(s) );
  //Serial.write( (const uint8_t*)s, strlen(s) );
}

void in(char *ptr, uint8_t timeout)
{
  int pos = 0;
  unsigned long lastTime = millis();
  while( client.available()==0 && millis()-lastTime<timeout)
  {
  }  //do nothing
  lastTime = millis();
  unsigned long lastdata = millis();
  while ( client.available() || (millis()-lastdata < 500))
  {
    if (client.available())
    {
      char c = client.read();
      //DEBUG_PRINTLN(c);
      lastdata = millis();
      ptr[pos] = c;
      pos++;
    }
    if (pos >= 512 - 1)
      break;
  }
  ptr[pos] = '\0'; //end the char array
  while (client.available()) client.read(); // makeshift client.flush()
  client.flush();  //for safety
  delay(400);
  client.stop();
}

1 Like

it would be nice however, to be able to add a little label to the do button in notification center…

but it is great to not to have to unlock your phone to affect your spark!

2 Likes

It’s really weird, but while my ifttt recipes work to close my window shutters in combination with my spark core hacked to a shutter remote, the Ifttt do button app doesn’t work and gives errors. The only thing my script is doing is creating three functions (open, close and stop) and map those to digital writes to 3 pins. While my jawbone up + spark core recipe works (closing the shutters when I go to sleep), the button does nothing and I get an error message in my email from ifttt. Anybody else having these issues?

Did you create the button recipes in the Do button app? I don’t think it works to run a recipe you have already created.

Yes of course, that’s the only way to create a button recipe.

This is my spark core code btw:

bool state = HIGH;

void setup() {
    pinMode(D0,OUTPUT);
    digitalWrite(D0,LOW);
    pinMode(D1,OUTPUT);
    digitalWrite(D1,LOW);
    pinMode(D2,OUTPUT);
    digitalWrite(D2,LOW);
    Spark.function("open", openFunction);
    Spark.function("stop", stopFunction);
    Spark.function("close", closeFunction);
    Spark.function("semiclose", semicloseFunction);
}

void loop() {
	// do nothing
}

int openFunction(String args) {
    state = !state;
    digitalWrite(D0, HIGH); 
        delay(100);
        digitalWrite(D0, LOW);
    return 200; 
}

int stopFunction(String args) {
    state = !state;
    digitalWrite(D1, HIGH); 
        delay(100);
        digitalWrite(D1, LOW);
    return 200; 
}

int closeFunction(String args) {
    state = !state;
    digitalWrite(D2, HIGH); 
        delay(100);
        digitalWrite(D2, LOW);
    return 200; 
}

int semicloseFunction(String args) {
    state = !state;
    digitalWrite(D2, HIGH); 
        delay(100);
        digitalWrite(D2, LOW);
        delay(16800);
        digitalWrite(D1, HIGH); 
        delay(100);
        digitalWrite(D1, LOW);
    return 200; 
}

Can you post the error message from the Do action / IFTTT?

I can, It gives a timeout:

Action Timeout Error about 16 hours ago
Spark or its API may temporarily be down. After five consecutive errors, the Recipe will automatically turn off and an email with further instructions will be sent. Adjust your email alert settings here.

I flashed your code to one of my Cores (with the small addition of an RGB blink for testing purposes). I then created a DO button for all four functions. They all seem to work here. (iPhone 5 running iOS 8.1).

Here’s the code with the RGB flashes:
Could you give it a try to see if the code is being called?

bool state = HIGH;

void setup() {
    pinMode(D0,OUTPUT);
    digitalWrite(D0,LOW);
    pinMode(D1,OUTPUT);
    digitalWrite(D1,LOW);
    pinMode(D2,OUTPUT);
    digitalWrite(D2,LOW);
    Spark.function("open", openFunction);
    Spark.function("stop", stopFunction);
    Spark.function("close", closeFunction);
    Spark.function("semiclose", semicloseFunction);
}

void loop() {
	// do nothing
}

int openFunction(String args) {
    state = !state;
    digitalWrite(D0, HIGH); 
        delay(100);
        digitalWrite(D0, LOW);
        
        RGB.control(true);
        RGB.color(255,0,0);
        delay(500);
        RGB.control(false);
    return 200; 
}

int stopFunction(String args) {
    state = !state;
    digitalWrite(D1, HIGH); 
        delay(100);
        digitalWrite(D1, LOW);
        
        RGB.control(true);
        RGB.color(0,255,0);
        delay(500);
        RGB.control(false);
    return 200; 
}

int closeFunction(String args) {
    state = !state;
    digitalWrite(D2, HIGH); 
        delay(100);
        digitalWrite(D2, LOW);
        
        RGB.control(true);
        RGB.color(0,0,255);
        delay(500);
        RGB.control(false);
    return 200; 
}

int semicloseFunction(String args) {
    state = !state;
    digitalWrite(D2, HIGH); 
        delay(100);
        digitalWrite(D2, LOW);
        delay(16800);
        digitalWrite(D1, HIGH); 
        delay(100);
        digitalWrite(D1, LOW);
        
        RGB.control(true);
        RGB.color(255,0,255);
        delay(500);
        RGB.control(false);
    return 200; 
}

Are there problems with any specific function, or are they all problematic? Seeing as the semicloseFunction has a delay of 16.8s it might time out on the IFTTT side waiting for a response.