I’ve been using IFTTT to turn on and off my room’s lighting by google assistant voice command.
After changing the hardware from Raspberry pi to Particle Photon, the delay between the voice command and actual relay turn on/off is less than a second.
So, it’s working really fine.
However, around a certain time, the relay turns on/off by itself without a voice command.
The overall system design is below.
Voice command --> Google server --> IFTTT server --> Particle server --> Photon
After looking into three servers for logs, I found that both Google server and IFTTT have no logs of executing commands, but somehow the Particle console says it’s getting event from somewhere.
Since I only have one device in my account, without any “publish” commands, I don’t know where this event is coming from.
One more note. These ghost events are thrown two or three times a day, with exact timing.
At first, I thought this was the reset issue, ( for Arduino if you use timing function, the clock goes back to 0 after around 30 days) but the time interval btw the ghost events is too short. (12hours?)
Also, I disabled the auto-update to eliminate the possibility of the device reboot.
Any advice will be really appreciated.
const int Light_main = D0;
const int Light_kitchen = D1;
bool Light_main_state;
bool Light_kitchen_state;
void setup() {
System.disableUpdates();
pinMode(Light_main,OUTPUT);
pinMode(Light_kitchen,OUTPUT);
pinSetFast(Light_main);
pinSetFast(Light_kitchen);
Light_main_state = false;
Light_kitchen_state = false;
Particle.subscribe("MainLights", mainLightsHandler);
Particle.subscribe("KitchenLights", kitchenLightsHandler);
Particle.subscribe("Lights", lightsHandler);
Particle.variable("Light_main_state", Light_main_state);
Particle.variable("Light_kitchen_state", Light_kitchen_state);
}
void loop() {
}
// IFTTT event handler
void mainLightsHandler(const char *event, const char *data){
String temp = data;
if (temp == "off") {
pinSetFast(Light_main);
Light_main_state = false;
Particle.publish("Main Lights OFF");
}
if (temp == "on") {
pinResetFast(Light_main);
Light_main_state = true;
Particle.publish("Main Lights ON");
}
}
void kitchenLightsHandler(const char *event, const char *data){
String temp = data;
if (temp == "off") {
pinSetFast(Light_kitchen);
Light_kitchen_state = false;
Particle.publish("Kitchen Lights OFF");
}
if (temp == "on") {
pinResetFast(Light_kitchen);
Light_kitchen_state = true;
Particle.publish("Kitchen Lights ON");
}
}
void lightsHandler(const char *event, const char *data){
String temp = data;
if (temp == "off") {
pinSetFast(Light_main);
pinSetFast(Light_kitchen);
Light_main_state = false;
Light_kitchen_state = false;
Particle.publish("Main & Kitchen Lights OFF");
}
if (temp == "on") {
pinResetFast(Light_main);
pinResetFast(Light_kitchen);
Light_main_state = true;
Light_kitchen_state = true;
Particle.publish("Main & Kitchen Lights ON");
}
}