diff --git a/User_config.h b/User_config.h index 5a9f2e2..187864b 100644 --- a/User_config.h +++ b/User_config.h @@ -113,6 +113,7 @@ RF supported protocols #define repeatIRwMQTT false // do we repeat a received signal by using mqtt #define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol) +#define PanasonicAddress 0x4004 // Panasonic address (Pre data) #ifdef ESP8266 //IR supported protocols on ESP8266, all supported per default #define IR_GC @@ -125,6 +126,8 @@ RF supported protocols #define IR_RC5 #define IR_Sharp #define IR_SAMSUNG + #define IR_PANASONIC + #define IR_RCMM #else //IR supported protocols on arduino uncomment if you want to send with this protocol, NEC protocol is available per default //#define IR_COOLIX //#define IR_Whynter @@ -135,6 +138,7 @@ RF supported protocols //#define IR_Sharp //#define IR_SAMSUNG //#define IR_Raw + //#define IR_PANASONIC #endif /*----------------------BT topics-------------------------*/ diff --git a/ZgatewayIR.ino b/ZgatewayIR.ino index 4a8e778..b73f973 100644 --- a/ZgatewayIR.ino +++ b/ZgatewayIR.ino @@ -67,9 +67,9 @@ boolean IRtoMQTT(){ trc(rawCode); irrecv.resume(); // Receive the next value if (pubIRunknownPrtcl == false && MQTTprotocol == "-1"){ // don't publish unknown IR protocol - trc(F("---don't publish the code unknown protocol---")); + trc(F("---no publish unknown protocol---")); } else if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT - trc(F("Sending adv data to MQTT")); + trc(F("Adv data IRtoMQTT")); client.publish(subjectIRtoMQTTprotocol,(char *)MQTTprotocol.c_str()); client.publish(subjectIRtoMQTTbits,(char *)MQTTbits.c_str()); client.publish(subjectIRtoMQTTRaw,(char *)rawCode.c_str()); @@ -78,7 +78,7 @@ boolean IRtoMQTT(){ trc(value); boolean result = client.publish(subjectIRtoMQTT,(char *)value.c_str()); if (repeatIRwMQTT){ - trc(F("Publishing IR so as to repeat it")); + trc(F("Publishing IR for repeat")); client.publish(subjectMQTTtoIR,(char *)value.c_str()); } return result; @@ -238,10 +238,23 @@ void MQTTtoIR(char * topicOri, char * datacallback) { signalSent = true; } #endif + #ifdef IR_PANASONIC + if (strstr(topicOri, "IR_PANASONIC") != NULL){ + irsend.sendPanasonic(PanasonicAddress, data); + signalSent = true; + } + #endif + #ifdef IR_RCMM + if (strstr(topicOri, "IR_RCMM") != NULL){ + if (valueBITS == 0) valueBITS = 32; + irsend.sendRCMM(data, valueBITS); + signalSent = true; + } + #endif if (signalSent){ // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also boolean result = client.publish(subjectGTWIRtoMQTT, datacallback); if (result){ - trc(F("Signal sent by IR ack published")); + trc(F("MQTTtoIR OK ack published")); trc(String(data)); }; } diff --git a/ZgatewayRF.ino b/ZgatewayRF.ino index c805b68..e8c93b5 100644 --- a/ZgatewayRF.ino +++ b/ZgatewayRF.ino @@ -43,7 +43,7 @@ void setupRF(){ boolean RFtoMQTT(){ if (mySwitch.available()){ - trc(F("Receiving 433Mhz")); + trc(F("Receiving RF")); unsigned long MQTTvalue = 0; String MQTTprotocol; String MQTTbits; @@ -54,7 +54,7 @@ boolean RFtoMQTT(){ MQTTlength = String(mySwitch.getReceivedDelay()); mySwitch.resetAvailable(); if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT - trc(F("Sending advanced signal to MQTT")); + trc(F("Adv data RFtoMQTT")); client.publish(subjectRFtoMQTTprotocol,(char *)MQTTprotocol.c_str()); client.publish(subjectRFtoMQTTbits,(char *)MQTTbits.c_str()); client.publish(subjectRFtoMQTTlength,(char *)MQTTlength.c_str()); @@ -63,7 +63,7 @@ boolean RFtoMQTT(){ trc(value); boolean result = client.publish(subjectRFtoMQTT,(char *)value.c_str()); if (repeatRFwMQTT){ - trc(F("Publishing IR signal so as to repeat it")); + trc(F("Publishing RF for repeat")); client.publish(subjectMQTTtoRF,(char *)value.c_str()); } return result; @@ -86,7 +86,7 @@ void MQTTtoRF(char * topicOri, char * datacallback) { if (pos != -1){ pos = pos + +strlen(RFprotocolKey); valuePRT = (topic.substring(pos,pos + 1)).toInt(); - trc(F("RF Protocol number:")); + trc(F("RF Protocol:")); trc(String(valuePRT)); } //We look into the subject to see if a special RF pulselength is defined @@ -101,12 +101,12 @@ void MQTTtoRF(char * topicOri, char * datacallback) { if (pos3 != -1){ pos3 = pos3 + strlen(RFbitsKey); valueBITS = (topic.substring(pos3,pos3 + 2)).toInt(); - trc(F("Bits number:")); + trc(F("Bits nb:")); trc(String(valueBITS)); } if ((topic == subjectMQTTtoRF) && (valuePRT == 0) && (valuePLSL == 0) && (valueBITS == 0)){ - trc(F("MQTTtoRF default parameters")); + trc(F("MQTTtoRF default")); mySwitch.setProtocol(1,350); mySwitch.send(data, 24); // Acknowledgement to the GTWRF topic @@ -126,7 +126,7 @@ void MQTTtoRF(char * topicOri, char * datacallback) { // Acknowledgement to the GTWRF topic boolean result = client.publish(subjectGTWRFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also if (result){ - trc(F("MQTTtoRF OK and ack published")); + trc(F("MQTTtoRF OK ack published")); trc(String(data)); }; }