I have same problem with IFTTT + Webhooks and Google Assistant.
I use a normal relay, but I need similar function (one command for start request, and same command for stop request).
I tryed code writed above, was fine with Blynk, but when IFTTT triggered comand (voice comand), relay go ON (and remain ON), and Blynk do nothing. If I want to stop relay, need use voice command (applet with [“0”] at BODY).
Any thoughts?
code:
#define BLYNK_PRINT Serial
#include "ESP8266WiFi.h"
#include "BlynkSimpleEsp8266.h"
#include <SimpleTimer.h>
SimpleTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "aaaa2";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "aaa";
char pass[] = "aaa";
#define outputPin 15
#define inputPin V1
// pin 2= D4(Placa) = V1(Aplicatie)
void setup()
{
// Debug console
Serial.begin(9600);
pinMode( 15, OUTPUT); //2->5 placa
digitalWrite( 15, HIGH);
Blynk.begin(auth, ssid, pass);
}
BLYNK_WRITE(V1) {
if (param.asInt()==1){ // act only on the HIGH and not the LOW of the momentary
digitalWrite(15, !digitalRead(15)); // invert pin state just once
timer.setTimeout(1000L, [](){
digitalWrite(15, !digitalRead(15)); // then invert it back after 1000ms
Blynk.virtualWrite(V1, LOW); // sau HIGH
});
}
}
void loop()
{
Blynk.run();
timer.run();
}
Well, that one was over 3 months old… and if we allowed that, then this forum would only have a about a dozen topics… but each going back a few years and consisting of hundreds of “Me Toos”
Sorry, but I am a little confused by your question.
Are you trying to pulse the relay for 1 second when a Google command is given, or are you trying to keep it on until another google command is given to turn it off?
1 - remove the “digitalWrite( 15, HIGH);” on your Void setup()
2 - Reduce the time it takes for toggling the state, substituting the “1000L” with “200L”
Then, your webhooks url should look like: http://IP adress for your region/Your Token/update/v1
The method “PUT”, the Content Type “application/json” and on the Body you should put [“1”]
Glad it worked !! you will see how its amazing to command devices like that through the google assistant ! I am addicted right now! every day, when its time to sleep it just takes one Ok google!..