 */
 
 /*
- modified by chaeplin @ gmail.com
- */
+  modified by chaeplin @ gmail.com
+*/
 
 #include <Arduino.h>
 #include <ESP8266WiFi.h>
 #include <WiFiClientSecure.h>
 #include <ESP8266HTTPClient.h>
+// https://github.com/Links2004/arduinoWebSockets
 #include <WebSocketsClient.h>
+// https://github.com/bblanchon/ArduinoJson
 #include <ArduinoJson.h>
+// https://github.com/chaeplin/lgwhisen
+#include <lgWhisen.h>
+// https://github.com/markszabo/IRremoteESP8266
+#include <IRremoteESP8266.h>
 
 #include "/usr/local/src/ap_setting.h"
 #include "/usr/local/src/slack_setting.h"

const char* api_fingerprint = "AB F0 5B A9 1A E0 AE 5F CE 32 2E 7C 66 67 49 EC DD 6D 6A 38";

//#define SLACK_BOT_TOKEN "put-your-slack-token-here"
//#define WIFI_SSID       "wifi-name"
//#define WIFI_PASSWORD   "wifi-password"



long nextCmdId = 1;
bool connected = false;

unsigned long nextTimercheck;

// AC
#define IR_RX_PIN 14
#define IR_TX_PIN 2
#define AC_TYPE 1
#define AC_HEATING 0
#define AC_ON_MIN 5
#define AC_OFF_MIN 3

volatile struct
{
  uint8_t ac_mode;
  uint8_t ac_temp;
  uint8_t ac_flow;
  bool haveData;
  bool timermode;
  bool timerfirst;
  unsigned long intervalon;  // ms
  unsigned long intervaloff; // ms
  unsigned long timerMillis;
} ir_data;

IRrecv irrecv(IR_RX_PIN);
lgWhisen lgWhisen(AC_TYPE, AC_HEATING);

void chane_ac_temp_flow()
{
  if (ir_data.ac_mode == 1)
  {
    lgWhisen.setTemp(ir_data.ac_temp);
    lgWhisen.setFlow(ir_data.ac_flow);
    lgWhisen.activate();
  }
}

/**
  Sends a ping message to Slack. Call this function immediately after establishing
  the WebSocket connection, and then every 5 seconds to keep the connection alive.
*/
void sendPing()
{
  DynamicJsonBuffer jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["type"] = "ping";
