I’m 90% completed on a garage door project using my Particle (Spark Core) and IFTTT and need some assistance with the final 10%. I am new to all of this but since tackling this project, I have learned so much.
What specific code needs to be included in my sketch for IFTTT and/or DO Button to determine and return the current status of my garage door? Ideally, I’d like to formulate a recipe whereas I press the icon and it returns the status of OPEN or CLOSED. By looking at my current code, I believe I need to add a function or the like for IFTTT and/or DO Button to “read” and indicate the status.
My current Particle IDE code (below) does the following:
(1) Opens/Closes my garage via DO Button
(2) Opens/Closes my garage via IFTTT based on my iOS location
From a physical wiring perspective, I have the reed switch (magnetic sensor) connected or near each other when the garage is open. When the garage is closed, the magnetic switch is separated.
int relay = D1;
int delayRelay = D3;
int reed = D6;
int relayPulse(String command){
digitalWrite(relay, HIGH);
delay(1000);
digitalWrite(relay, LOW);
return 1;
}
int statusCheck(String command){
int status = digitalRead(reed);
if(status == HIGH){
return 1;
}
else if(status == LOW){
return 0;
}
else{
return -1;
}
}
void setup() {
Spark.function("relay", relayPulse);
Spark.function("status", statusCheck);
pinMode(relay, OUTPUT);
pinMode(delayRelay, OUTPUT);
pinMode(reed, INPUT);
digitalWrite(relay, LOW);
digitalWrite(delayRelay, LOW);
}
void loop() {
}
Please and thank you in advance! Very much appreciated.
I am working on pretty much the exact same project and I think I am exactly where you are.
It may be a little convoluted…but I was thinking of publishing a function “IsDoorOpen” and connecting a Do button to that.
IsDoorOpen could then publish an event “DoorOpen/DoorClosed” or “DoorStatus” or something like that…then IFTTT could listen to that and send me an appropriate text.
Another thing I was thinking of doing was setting up a dashboard on io.adafruit and just having the photon publish the status every minute or so to the dashboard.
I kind of wish there was a more elegant way to capture the output of a function but I’m not sure if there is.
Do button calls a function and I get a text a few moments later. It requires 1 Do and 1 IFTTT recipe but not so bad. I reuse the IFTTT recipe anyway to alert me if it’s been open for more than an hour.
I am not as familiar with what you are working with but going off of Bulldog’s comment Id try to do a local push notification over a server push notification, but i tend to roll my own. (still do a webhook that the phone gets info pyshed to but you dont need a service to manage local push notifications as its something you set in your apps code its self.
Also depending on how much flexibility you have with the app code you are working with id use geofencing to help with my location and have it cause an action based on when i get to a certain GPS coordinate and the door is in the closed state. Perhaps you can do something similar to what is done in the video.
The one thing I am not seeing that I am thinking about is with your code, what happens if i hit the button while the door is opening?
Glad to see some replies on this. Currently I’m out of the country but will be back to the states on Saturday. I’ll check it out (the DO/IFTTT changes).
Also, I’ll be posting up my project here in a day or two. As I said, it’s 90% done with the 10% being the “double check” on the garage door opened or closed. I think you’ll like the project, it’s really cool not having to use anything other than the phone to open/close the garage. And when I say other than the phone, you don’t even have to touch it, just have it with you!
I’m going to also incorporate my Amazon Echo into the project. As I’m walking out the door with coffee in one hand, keys in the other, ideally all I;ll have to say is “Alexa, open garage” to have it open!
Going 100% touch free is really cool, I have my neighbors that are now interested!!
I’ll send this topic an update when the final project has been posted. Thanks again for your replies.