1 parent
ef81dd2f5b
commit
bdb968e097
2 files changed
+10
-5
No files matched your search
+9
-5
@@ -214,22 +214,24 @@ unsigned long MQTTvalue = 0;
|
|||||||
if (mySwitch.available()||irrecv.decode(&results)){
|
if (mySwitch.available()||irrecv.decode(&results)){
|
||||||
trc(F("Signal detected"));
|
trc(F("Signal detected"));
|
||||||
String subject;
|
String subject;
|
||||||
String valueAdvanced ="";
|
String valueAdvanced;
|
||||||
|
String subjectAdvanced;
|
||||||
if (mySwitch.available()){
|
if (mySwitch.available()){
|
||||||
MQTTvalue = mySwitch.getReceivedValue();
|
MQTTvalue = mySwitch.getReceivedValue();
|
||||||
valueAdvanced = "Value " + String(MQTTvalue)+" Bit " + String(mySwitch.getReceivedBitlength()) + " Delay " + String(mySwitch.getReceivedDelay()) + " Protocol " + String(mySwitch.getReceivedProtocol());
|
valueAdvanced = "Value " + String(MQTTvalue)+" Bit " + String(mySwitch.getReceivedBitlength()) + " Delay " + String(mySwitch.getReceivedDelay()) + " Protocol " + String(mySwitch.getReceivedProtocol());
|
||||||
mySwitch.resetAvailable();
|
mySwitch.resetAvailable();
|
||||||
subject = subject433toMQTT;
|
subject = subject433toMQTT;
|
||||||
|
subjectAdvanced = subject433toMQTTAdvanced;
|
||||||
}else if (irrecv.decode(&results)){
|
}else if (irrecv.decode(&results)){
|
||||||
MQTTvalue=results.value;
|
MQTTvalue=results.value;
|
||||||
|
valueAdvanced = "Value " + String(MQTTvalue)+" Bit " + String(results.bits) + " Protocol " + String(results.decode_type);
|
||||||
irrecv.resume(); // Receive the next value
|
irrecv.resume(); // Receive the next value
|
||||||
subject = subjectIRtoMQTT;
|
subject = subjectIRtoMQTT;
|
||||||
|
subjectAdvanced = subjectIRtoMQTTAdvanced;
|
||||||
}
|
}
|
||||||
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
|
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
|
||||||
if (valueAdvanced != ""){
|
trc(F("Sending advanced signal to MQTT"));
|
||||||
trc(F("Sending advanced signal to MQTT"));
|
client.publish((char *)subjectAdvanced.c_str(),(char *)valueAdvanced.c_str());
|
||||||
client.publish(subject433toMQTTAdvanced,(char *)valueAdvanced.c_str());
|
|
||||||
}
|
|
||||||
trc(F("Sending signal to MQTT"));
|
trc(F("Sending signal to MQTT"));
|
||||||
String value = String(MQTTvalue);
|
String value = String(MQTTvalue);
|
||||||
trc(value);
|
trc(value);
|
||||||
@@ -387,6 +389,8 @@ void receivingMQTT(char * topicOri, char * datacallback) {
|
|||||||
irrecv.enableIRIn(); // ReStart the IR receiver (if not restarted it is not able to receive data)
|
irrecv.enableIRIn(); // ReStart the IR receiver (if not restarted it is not able to receive data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//trace
|
//trace
|
||||||
void trc(String msg){
|
void trc(String msg){
|
||||||
if (TRACE) {
|
if (TRACE) {
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip adress
|
|||||||
#define subjectGTWIRtoMQTT "home/sensors/ir"
|
#define subjectGTWIRtoMQTT "home/sensors/ir"
|
||||||
#define subjectIRtoMQTT "home/sensors/ir"
|
#define subjectIRtoMQTT "home/sensors/ir"
|
||||||
#define subjectMQTTtoIR "home/commands/MQTTtoIR"
|
#define subjectMQTTtoIR "home/commands/MQTTtoIR"
|
||||||
|
#define subjectIRtoMQTTAdvanced "home/IRtoMQTTAdvanced"
|
||||||
/*
|
/*
|
||||||
RF supported protocols
|
RF supported protocols
|
||||||
433_1
|
433_1
|
||||||
|
|||||||
Reference in new issue
Block a user