I must be missing something.
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#define WIFI_SSID "lemainemachon"
#define WIFI_PASS "jibajaba"
#define REMOTE_BTN_1 4 //up (D2)
#define REMOTE_BTN_2 14//down (D5)
#define REMOTE_BTN_3 12 //select (D6)
#define REMOTE_BTN_4 5//stop (D1)
#define UP "blinds Up"
#define Down "blinds Down"
#define Light_Block "Blinds light Block"
fauxmoESP fauxmo;
void setup() {
// Init serial port and clean garbage
Serial.begin(115200);
Serial.println();
// Wi-Fi connection
wifiSetup();
// Set Buttons
pinMode(REMOTE_BTN_1, OUTPUT); //up
digitalWrite(REMOTE_BTN_1, HIGH);
pinMode(REMOTE_BTN_2, OUTPUT); //down
digitalWrite(REMOTE_BTN_2, HIGH);
pinMode(REMOTE_BTN_3, OUTPUT); //select
digitalWrite(REMOTE_BTN_3, HIGH);
pinMode(REMOTE_BTN_4, OUTPUT); //stop
digitalWrite(REMOTE_BTN_4, HIGH);
fauxmo.createServer(true); // not needed, this is the default value
fauxmo.setPort(80); // This is required for gen3 devices
fauxmo.enable(true);
fauxmo.addDevice(UP);
fauxmo.addDevice(Down);
fauxmo.addDevice(Light_Block);
fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) { //command recieved
// Callback when a command from Alexa is received.
Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
if ( (strcmp(device_name, UP) == 0) ) {
Serial.println("calling up() sub funct ");//blinds up
up();
}
if ( (strcmp(device_name, Down) == 0) ) { //blinds down
Serial.println("calling down() sub funct ");//blinds down
down();
}
});
}
void loop() {
fauxmo.handle();
}
void up() {
Serial.println("sub funct called");
digitalWrite(REMOTE_BTN_1, LOW);
delay(1000);//1 second
Serial.println("low");
digitalWrite(REMOTE_BTN_1, HIGH);
Serial.println("high");
}
void down() {
Serial.println("BtnDown 2 called by Alexa");
digitalWrite(REMOTE_BTN_2, LOW);
delay(1000);//1 second
Serial.println("low");
digitalWrite(REMOTE_BTN_2, HIGH);
Serial.println("high");
}
// Wi-Fi Connection
void wifiSetup() {
WiFi.mode(WIFI_STA);
Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.print("attempting to connect to wifi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println();
Serial.printf("Connected to - SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}