Moved dim level to MQTT payload for RF2 (#114)

This commit is contained in:
Lars Englund authored and Florian committed 2017-09-22 20:57:49 +02:00
1 parent 348edf458c
commit c576bd7171
2 files changed
+16 -7

No files matched your search

+15 -6
View File
@@ -109,6 +109,7 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
String topic = topicOri;
bool boolSWITCHTYPE;
boolSWITCHTYPE = to_bool(datacallback);
bool isDimCommand = false;
long valueCODE = 0;
int valueUNIT = -1;
@@ -146,8 +147,8 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
}
int pos5 = topic.lastIndexOf(RF2dimKey);
if (pos5 != -1) {
pos5 = pos5 + strlen(RF2dimKey);
valueDIM = (topic.substring(pos5, topic.indexOf("/", pos5))).toInt();
isDimCommand = true;
valueDIM = atoi(datacallback);
trc(F("RF2 Dim:"));
trc(String(valueDIM));
}
@@ -168,7 +169,7 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
trc(F("Sending data"));
if (valueGROUP) {
if (valueDIM >= 0) {
if (isDimCommand) {
transmitter.sendGroupDim(valueDIM);
}
else {
@@ -176,7 +177,7 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
}
}
else {
if (valueDIM >= 0) {
if (isDimCommand) {
transmitter.sendDim(valueUNIT, valueDIM);
}
else {
@@ -192,16 +193,24 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
String MQTTunit;
String MQTTgroupBit;
String MQTTswitchType;
String MQTTdimLevel;
MQTTAddress = String(valueCODE);
MQTTperiod = String(valuePERIOD);
MQTTunit = String(valueUNIT);
MQTTgroupBit = String(rf2rd.groupBit);
MQTTswitchType = String(boolSWITCHTYPE);
MQTTdimLevel = String(valueDIM);
String MQTTRF2string;
MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2periodKey+MQTTperiod;
trc(F("Adv data MQTTtoRF2 push state via RF2toMQTT"));
client.publish((char *)MQTTRF2string.c_str(),(char *)MQTTswitchType.c_str());
if (isDimCommand) {
MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2dimKey+String("/")+RF2periodKey+MQTTperiod;
client.publish((char *)MQTTRF2string.c_str(),(char *)MQTTdimLevel.c_str());
}
else {
MQTTRF2string = subjectRF2toMQTT+String("/")+RF2codeKey+MQTTAddress+String("/")+RF2unitKey+MQTTunit+String("/")+RF2groupKey+MQTTgroupBit+String("/")+RF2periodKey+MQTTperiod;
client.publish((char *)MQTTRF2string.c_str(),(char *)MQTTswitchType.c_str());
}
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ RF supported protocols
#define RF2periodKey "PERIOD_" // period will be defined if a subject contains RF2periodKey followed by a value of 3 digits
#define RF2unitKey "UNIT_" // number of your unit value will be defined if a subject contains RF2unitKey followed by a value of 1-2 digits
#define RF2groupKey "GROUP_" // number of your group value will be defined if a subject contains RF2groupKey followed by a value of 1 digit
#define RF2dimKey "DIM_" // number of your dim value will be defined if a subject contains RF2dimKey followed by a value of 1-3 digits
#define RF2dimKey "DIM" // number of your dim value will be defined if a subject contains RF2dimKey and the payload contains the dim value as digits
/*-------------------PIN DEFINITIONS----------------------*/
#ifdef I2C_Wiring // With Support for I2C Modules