Browse Source

Merge pull request #1645 from Niek/relay-mqtt-reporting

Add option to disable relay reporting to MQTT
rules-rpn
Xose Pérez 5 years ago
committed by GitHub
parent
commit
fe67fb61af
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions
  1. +4
    -0
      code/espurna/config/general.h
  2. +1
    -1
      code/espurna/mqtt.ino
  3. +2
    -2
      code/espurna/relay.ino

+ 4
- 0
code/espurna/config/general.h View File

@ -356,6 +356,10 @@
#define RELAY_SAVE_DELAY 1000 #define RELAY_SAVE_DELAY 1000
#endif #endif
#ifndef RELAY_REPORT_STATUS
#define RELAY_REPORT_STATUS 1
#endif
// Configure the MQTT payload for ON/OFF // Configure the MQTT payload for ON/OFF
#ifndef RELAY_MQTT_ON #ifndef RELAY_MQTT_ON
#define RELAY_MQTT_ON "1" #define RELAY_MQTT_ON "1"


+ 1
- 1
code/espurna/mqtt.ino View File

@ -237,7 +237,7 @@ void _mqttConfigure() {
// Getters and setters // Getters and setters
_mqtt_setter = getSetting("mqttSetter", MQTT_SETTER); _mqtt_setter = getSetting("mqttSetter", MQTT_SETTER);
_mqtt_getter = getSetting("mqttGetter", MQTT_GETTER); _mqtt_getter = getSetting("mqttGetter", MQTT_GETTER);
_mqtt_forward = !_mqtt_getter.equals(_mqtt_setter);
_mqtt_forward = !_mqtt_getter.equals(_mqtt_setter) && RELAY_REPORT_STATUS;
// MQTT options // MQTT options
_mqtt_qos = getSetting("mqttQoS", MQTT_QOS).toInt(); _mqtt_qos = getSetting("mqttQoS", MQTT_QOS).toInt();


+ 2
- 2
code/espurna/relay.ino View File

@ -339,7 +339,7 @@ bool relayStatus(unsigned char id, bool status, bool report, bool group_report)
} }
bool relayStatus(unsigned char id, bool status) { bool relayStatus(unsigned char id, bool status) {
return relayStatus(id, status, true, true);
return relayStatus(id, status, mqttForward(), true);
} }
bool relayStatus(unsigned char id) { bool relayStatus(unsigned char id) {
@ -436,7 +436,7 @@ void relayToggle(unsigned char id, bool report, bool group_report) {
} }
void relayToggle(unsigned char id) { void relayToggle(unsigned char id) {
relayToggle(id, true, true);
relayToggle(id, mqttForward(), true);
} }
unsigned char relayCount() { unsigned char relayCount() {


Loading…
Cancel
Save