/****************************************************************/ // https://myhomethings.eu // NodeMCU 1.0(ESP-12E Module) // Flash size: 4M (1M SPIFFS) /****************************************************************/ #include #include #include #include const char* ssid = "Meine-SSID"; const char* password = "Mein-WLAN-Passwot"; const char* mqtt_server = "192.168.178.27"; // meine ioBroker ip addresse int IrLed = D2; WiFiClient espClient; PubSubClient client(espClient); IRsend irsend(IrLed); void setup() { WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); } client.setServer(mqtt_server, 1883); client.setCallback(callback); irsend.begin(); } void loop() { if (!client.connected()) { reconnect(); } client.loop(); } void callback(char* topic, byte* payload, unsigned int length) { payload[length] = '\0'; String strTopic = String(topic); String strPayload = String((char * ) payload); if(strTopic == "Infrared_topic") { if(strPayload == "0") { irsend.sendSAMSUNG (0xE0E08877); //entsprechenden IR-Code einfügen } if (strPayload == "1") { irsend.sendSAMSUNG (0xE0E020DF); //entsprechenden IR-Code einfügen } if (strPayload == "2") { irsend.sendSAMSUNG (0xE0E0A05F); } if (strPayload == "3") { irsend.sendSAMSUNG (0xE0E0609F); } if (strPayload == "4") { irsend.sendSAMSUNG (0xE0E010EF); } if (strPayload == "5") { irsend.sendSAMSUNG (0xE0E0906F); } if (strPayload == "6") { irsend.sendSAMSUNG (0xE0E050AF); } if (strPayload == "7") { irsend.sendSAMSUNG (0xE0E030CF); } if (strPayload == "8") { irsend.sendSAMSUNG (0xE0E0B04F); } if (strPayload == "9") { irsend.sendSAMSUNG (0xE0E0708F); } if (strPayload == "laut") { irsend.sendSAMSUNG (0xE0E0E01F); } if (strPayload == "leise") { irsend.sendSAMSUNG (0xE0E0D02F); } if (strPayload == "crauf") { irsend.sendSAMSUNG (0xE0E048B7); } if (strPayload == "crunter") { irsend.sendSAMSUNG (0xE0E008F7); } if (strPayload == "ein_aus") { irsend.sendSAMSUNG (0xE0E06798); } if (strPayload == "up") { irsend.sendSAMSUNG (0xE0E006F9); } if (strPayload == "down") { irsend.sendSAMSUNG (0xE0E08679); } if (strPayload == "left") { irsend.sendSAMSUNG (0xE0E0A659); } if (strPayload == "right") { irsend.sendSAMSUNG (0xE0E046B9); } if (strPayload == "ok") { irsend.sendSAMSUNG (0xE0E016E9); } if (strPayload == "chlist") { irsend.sendSAMSUNG (0xE0E0D629); } if (strPayload == "haus") { irsend.sendSAMSUNG (0xE0E09E61); } if (strPayload == "prech") { irsend.sendSAMSUNG (0xE0E0C837); } if (strPayload == "guide") { irsend.sendSAMSUNG (0xE0E0F20D); } if (strPayload == "exit") { irsend.sendSAMSUNG (0xE0E0B44B); } if (strPayload == "return") { irsend.sendSAMSUNG (0xE0E01AE5); } if (strPayload == "play") { irsend.sendSAMSUNG (0xE0E0E21D); } if (strPayload == "pause") { irsend.sendSAMSUNG (0xE0E052AD); } if (strPayload == "vor") { irsend.sendSAMSUNG (0xE0E012ED); } if (strPayload == "zurueck") { irsend.sendSAMSUNG (0xE0E0A25D); } if (strPayload == "stopp") { irsend.sendSAMSUNG (0xE0E0629D); } if (strPayload == "rot") { irsend.sendSAMSUNG (0xE0E036C9); } if (strPayload == "gruen") { irsend.sendSAMSUNG (0xE0E028D7); } if (strPayload == "gelb") { irsend.sendSAMSUNG (0xE0E0A857); } if (strPayload == "blau") { irsend.sendSAMSUNG (0xE0E06897); } } } void reconnect() { while (!client.connected()) { String clientId = "ESP8266_IR"; if (client.connect(clientId.c_str())) { client.subscribe("Infrared_topic"); } else { delay(6000); } } }