mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Add index to Button and Switch action topics
This commit is contained in:
parent
9f191d9214
commit
7b68935ae3
@ -375,7 +375,9 @@ void MqttButtonTopic(uint32_t button_id, uint32_t action, uint32_t hold) {
|
|||||||
if (!Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistant automatic discovery (See SetOption59)
|
if (!Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistant automatic discovery (See SetOption59)
|
||||||
char mqttstate[7];
|
char mqttstate[7];
|
||||||
Response_P(PSTR("{\"" D_JSON_BUTTON "%d\":{\"Action\":\"%s\"}}"), button_id, (hold) ? SettingsText(SET_STATE_TXT4) : GetTextIndexed(mqttstate, sizeof(mqttstate), action, kMultiPress));
|
Response_P(PSTR("{\"" D_JSON_BUTTON "%d\":{\"Action\":\"%s\"}}"), button_id, (hold) ? SettingsText(SET_STATE_TXT4) : GetTextIndexed(mqttstate, sizeof(mqttstate), action, kMultiPress));
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_JSON_BUTTON));
|
char scommand[10];
|
||||||
|
snprintf_P(scommand, sizeof(scommand), PSTR("BUTTON%d"), button_id);
|
||||||
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, scommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +427,9 @@ void SwitchHandler(uint32_t mode) {
|
|||||||
GetTextIndexed(mqtt_state_str, sizeof(mqtt_state_str), mqtt_action, kSwitchPressStates);
|
GetTextIndexed(mqtt_state_str, sizeof(mqtt_state_str), mqtt_action, kSwitchPressStates);
|
||||||
}
|
}
|
||||||
Response_P(PSTR("{\"%s\":{\"Action\":\"%s\"}}"), GetSwitchText(i).c_str(), mqtt_state);
|
Response_P(PSTR("{\"%s\":{\"Action\":\"%s\"}}"), GetSwitchText(i).c_str(), mqtt_state);
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_JSON_SWITCH));
|
char scommand[10];
|
||||||
|
snprintf_P(scommand, sizeof(scommand), PSTR("SWITCH%d"), i +1);
|
||||||
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, scommand);
|
||||||
}
|
}
|
||||||
mqtt_action = POWER_NONE;
|
mqtt_action = POWER_NONE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user