Calling fibaro Quick App Buttons API from ESP8266

Viewed 26

Here what I try to do I have quickapp in HC3 that have some buttons I want to call from ESP8266 with it's URL All buttons API is working fine in browser the project consist of {ESP8266, IR Receiver} that is it I want to make conditions for the buttons that IR receive I will get it's code from serial monitor and every button it's condition come true is calling Certain button in fibaro quickapp through API How can I make API call under every (condition) OR (case) from arduino

1 Answers

I am trying to call button in quick app, if IR receive any code from AC remote it will call the API of this button the arduino code is this

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>

#define ssid "Name"
#define password "Passsword"

const char * servername = "http://User:Password@IPAdress/api/plugins/callUIEvent?deviceID=1639&elementName=Cool22&eventType=onReleased";
int  MyData;
IRrecv irrecv(14);
decode_results results;
void setup()
{
  MyData = 0;
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid,password);
  Serial.begin(9600);
  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }
    Serial.println("");
    Serial.print("connected to ");
    Serial.println(ssid);
    Serial.print("IP Adress: ");
    Serial.println(WiFi.localIP());
    irrecv.enableIRIn();  // Start the receiver
  }
   /*while (!Serial){  // Wait for the serial connection to be establised.
      delay(50);
  Serial.println();
  Serial.print("IRrecv is now running and waiting for IR message on Pin ");
  Serial.println(14);
  }*/
void loop()
{
    HTTPClient http;
    WiFiClient client;
    if (irrecv.decode(&results)) {
    Serial.println("You Receive This:");
       MyData = (results.value);
       Serial.println(MyData);
       if (MyData == 11714416 ){ 
            http.begin(client, servername);
            http.addHeader("Content-Type", "application/json");
            int httpcode = http.POST(servername);
            String payload =(http.getString());
            Serial.println(payload);
            Serial.print("HTTP Response code: ");
            Serial.println(httpcode);
// Disconnect
            http.end(); 
    }
    else {
      Serial.println("No HTTP");
    }
     irrecv.resume();
    }
}

the output tell me

You Receive This: 11714416

HTTP Response code: -1 and sometimes it give me Exception(28)

Related