mirror of https://github.com/arendst/Tasmota.git
Enabled forced local operation when button- or switchtopic is set
This commit is contained in:
parent
dc63d0f91c
commit
a65041fee5
|
@ -96,6 +96,7 @@
|
|||
#define MQTT_BUTTON_RETAIN 0 // [ButtonRetain] Button may send retain flag (0 = off, 1 = on)
|
||||
#define MQTT_POWER_RETAIN 0 // [PowerRetain] Power status message may send retain flag (0 = off, 1 = on)
|
||||
#define MQTT_SWITCH_RETAIN 0 // [SwitchRetain] Switch may send retain flag (0 = off, 1 = on)
|
||||
#define MQTT_BUTTON_SWITCH_FORCE_LOCAL 0 // [SetOption61] Force local operation when button/switch topic is set (0 = off, 1 = on)
|
||||
|
||||
#define MQTT_STATUS_OFF "OFF" // [StateText1] Command or Status result when turned off (needs to be a string like "0" or "Off")
|
||||
#define MQTT_STATUS_ON "ON" // [StateText2] Command or Status result when turned on (needs to be a string like "1" or "On")
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
|
|||
uint32_t receive_raw : 1; // bit 8 (v6.3.0.11)
|
||||
uint32_t hass_tele_on_power : 1; // bit 9 (v6.3.0.13)
|
||||
uint32_t sleep_normal : 1; // bit 10 (v6.3.0.15) - SetOption60 - Enable normal sleep instead of dynamic sleep
|
||||
uint32_t spare11 : 1;
|
||||
uint32_t button_switch_force_local : 1;// bit 11
|
||||
uint32_t spare12 : 1;
|
||||
uint32_t spare13 : 1;
|
||||
uint32_t spare14 : 1;
|
||||
|
|
|
@ -486,6 +486,7 @@ void SettingsDefaultSet2(void)
|
|||
Settings.flag.mqtt_power_retain = MQTT_POWER_RETAIN;
|
||||
Settings.flag.mqtt_button_retain = MQTT_BUTTON_RETAIN;
|
||||
Settings.flag.mqtt_switch_retain = MQTT_SWITCH_RETAIN;
|
||||
Settings.flag3.button_switch_force_local = MQTT_BUTTON_SWITCH_FORCE_LOCAL;
|
||||
// Settings.flag.mqtt_sensor_retain = 0;
|
||||
// Settings.flag.mqtt_offline = 0;
|
||||
// Settings.flag.mqtt_serial = 0;
|
||||
|
|
|
@ -1316,7 +1316,7 @@ boolean SendKey(byte key, byte device, byte state)
|
|||
if (9 == state) {
|
||||
mqtt_data[0] = '\0';
|
||||
} else {
|
||||
if ((!strcmp(mqtt_topic, key_topic) || !strcmp(Settings.mqtt_grptopic, key_topic)) && (2 == state)) {
|
||||
if ((Settings.flag3.button_switch_force_local || !strcmp(mqtt_topic, key_topic) || !strcmp(Settings.mqtt_grptopic, key_topic)) && (2 == state)) {
|
||||
state = ~(power >> (device -1)) &1;
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), GetStateText(state));
|
||||
|
@ -1328,7 +1328,7 @@ boolean SendKey(byte key, byte device, byte state)
|
|||
#else
|
||||
MqttPublishDirect(stopic, (key) ? Settings.flag.mqtt_switch_retain : Settings.flag.mqtt_button_retain);
|
||||
#endif // USE_DOMOTICZ
|
||||
result = true;
|
||||
result = !Settings.flag3.button_switch_force_local;
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s%d\":{\"State\":%d}}"), (key) ? "Switch" : "Button", device, state);
|
||||
result = XdrvRulesProcess();
|
||||
|
|
Loading…
Reference in New Issue