Publish advanced RF received data

#21 fixed
This commit is contained in:
1technophile committed 2017-03-15 21:58:08 +01:00
1 parent 77a7cd5d6e
commit f14d4f3245
2 files changed
+11 -1

No files matched your search

+9 -1
View File
@@ -198,16 +198,24 @@ unsigned long MQTTvalue = 0;
if (mySwitch.available()||irrecv.decode(&results)){
trc(F("Signal detected"));
String subject;
String subjectAdvanced;
String valueAdvanced;
if (mySwitch.available()){
MQTTvalue = mySwitch.getReceivedValue();
mySwitch.resetAvailable();
subject = subject433toMQTT;
subjectAdvanced = subject433toMQTTAdvanced;
valueAdvanced = "Value " + String(MQTTvalue)+" Bit " + String(mySwitch.getReceivedBitlength()) + " Delay " + String(mySwitch.getReceivedDelay()) + " Protocol " + String(mySwitch.getReceivedProtocol());
}else if (irrecv.decode(&results)){
MQTTvalue=results.value;
irrecv.resume(); // Receive the next value
subject = subjectIRtoMQTT;
subjectAdvanced = subjectIRtoMQTTAdvanced;
valueAdvanced = "Not available";
}
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF or IR -->MQTT
trc(F("Sending advanced signal to MQTT"));
client.publish((char *)subjectAdvanced.c_str(),(char *)valueAdvanced.c_str());
trc(F("Sending signal to MQTT"));
String value = String(MQTTvalue);
trc(value);
+2
View File
@@ -65,10 +65,12 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
//433Mhz MQTT Subjects and keys
#define subjectMQTTto433 "home/commands/MQTTto433"
#define subject433toMQTT "home/433toMQTT"
#define subject433toMQTTAdvanced "home/433toMQTTAdvanced"
#define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit
#define RFpulselengthKey "PLSL_" // pulselength will be defined if a subject contains RFprotocolKey followed by a value of 3 digits
//IR MQTT Subjects
#define subjectIRtoMQTT "home/sensors/ir"
#define subjectIRtoMQTTAdvanced "home/sensors/irAdvanced"
#define subjectMQTTtoIR "home/commands/MQTTtoIR"
/*
RF supported protocols