Skip to content

Commit 9481bcd

Browse files
committed
transmit IR raw data to MQTT
#9
1 parent 9e9a2cd commit 9481bcd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

User_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ RF supported protocols
105105
#define subjectMQTTtoIR "home/commands/MQTTtoIR"
106106
#define subjectIRtoMQTTprotocol "home/IRtoMQTT/protocol"
107107
#define subjectIRtoMQTTbits "home/IRtoMQTT/bits"
108+
#define subjectIRtoMQTTRaw "home/IRtoMQTT/raw"
108109
// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple
109110
#define subjectMultiGTWIR "+/IRtoMQTT"
110111
#define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits

ZgatewayIR.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,21 @@ boolean IRtoMQTT(){
5858
MQTTvalue = results.value;
5959
MQTTprotocol = String(results.decode_type);
6060
MQTTbits = String(results.bits);
61+
String rawCode = "";
62+
// Dump data
63+
for (int i = 1; i < results.rawlen; i++) {
64+
rawCode = rawCode + (results.rawbuf[i] * USECPERTICK);
65+
if ( i < results.rawlen-1 ) rawCode = rawCode + ","; // ',' not needed on last one
66+
}
67+
trc(rawCode);
6168
irrecv.resume(); // Receive the next value
6269
if (pubIRunknownPrtcl == false && MQTTprotocol == "-1"){ // don't publish unknown IR protocol
6370
trc(F("--------------don't publish the received code unknown protocol--------------"));
6471
} else if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
6572
trc(F("Sending adv data to MQTT"));
6673
client.publish(subjectIRtoMQTTprotocol,(char *)MQTTprotocol.c_str());
67-
client.publish(subjectIRtoMQTTbits,(char *)MQTTbits.c_str());
74+
client.publish(subjectIRtoMQTTbits,(char *)MQTTbits.c_str());
75+
client.publish(subjectIRtoMQTTRaw,(char *)rawCode.c_str());
6876
trc(F("Sending IR to MQTT"));
6977
String value = String(MQTTvalue);
7078
trc(value);

0 commit comments

Comments
 (0)