|
|
@ -630,7 +630,7 @@ void _relayWebSocketSendRelay(unsigned char i) { |
|
|
|
line["pulse_ms"] = _relays[i].pulse_ms / 1000.0; |
|
|
|
#if MQTT_SUPPORT
|
|
|
|
line["group"] = getSetting("mqttGroup", i, ""); |
|
|
|
line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt(); |
|
|
|
line["group_sync"] = getSetting("mqttGroupSync", i, RELAY_GROUP_SYNC_NORMAL).toInt(); |
|
|
|
line["on_disc"] = getSetting("relayOnDisc", i, 0).toInt(); |
|
|
|
#endif
|
|
|
|
|
|
|
@ -794,6 +794,18 @@ void relaySetupAPI() { |
|
|
|
|
|
|
|
#if MQTT_SUPPORT
|
|
|
|
|
|
|
|
void _relayMQTTGroup(unsigned char id) { |
|
|
|
String topic = getSetting("mqttGroup", id, ""); |
|
|
|
if (!topic.length()) return; |
|
|
|
|
|
|
|
unsigned char mode = getSetting("mqttGroupSync", id, RELAY_GROUP_SYNC_NORMAL).toInt(); |
|
|
|
if (mode == RELAY_GROUP_SYNC_RECEIVEONLY) return; |
|
|
|
|
|
|
|
bool status = relayStatus(id); |
|
|
|
if (mode == RELAY_GROUP_SYNC_INVERSE) status = !status; |
|
|
|
mqttSendRaw(topic.c_str(), status ? RELAY_MQTT_ON : RELAY_MQTT_OFF); |
|
|
|
} |
|
|
|
|
|
|
|
void relayMQTT(unsigned char id) { |
|
|
|
|
|
|
|
if (id >= _relays.size()) return; |
|
|
@ -807,12 +819,7 @@ void relayMQTT(unsigned char id) { |
|
|
|
// Check group topic
|
|
|
|
if (_relays[id].group_report) { |
|
|
|
_relays[id].group_report = false; |
|
|
|
String t = getSetting("mqttGroup", id, ""); |
|
|
|
if (t.length() > 0) { |
|
|
|
bool status = relayStatus(id); |
|
|
|
if (getSetting("mqttGroupInv", id, 0).toInt() == 1) status = !status; |
|
|
|
mqttSendRaw(t.c_str(), status ? RELAY_MQTT_ON : RELAY_MQTT_OFF); |
|
|
|
} |
|
|
|
_relayMQTTGroup(id); |
|
|
|
} |
|
|
|
|
|
|
|
// Send speed for IFAN02
|
|
|
@ -939,7 +946,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo |
|
|
|
if (value == 0xFF) return; |
|
|
|
|
|
|
|
if (value < 2) { |
|
|
|
if (getSetting("mqttGroupInv", i, 0).toInt() == 1) { |
|
|
|
if (getSetting("mqttGroupSync", i, RELAY_GROUP_SYNC_NORMAL).toInt() == RELAY_GROUP_SYNC_INVERSE) { |
|
|
|
value = 1 - value; |
|
|
|
} |
|
|
|
} |
|
|
|