mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-26 04:06:34 +00:00
Merge pull request #9725 from effelle/development
New topic for MQTT switches
This commit is contained in:
commit
dfd6080d96
@ -432,23 +432,18 @@ void SwitchHandler(uint8_t mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttSwitchTopic(uint8_t switch_id, uint8_t MqttAction)
|
void MqttSwitchTopic(uint32_t switch_id, uint32_t MqttAction) {
|
||||||
{
|
if (!Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
|
||||||
char scommand[CMDSZ];
|
char mqttstate_str[16];
|
||||||
char stopic[TOPSZ];
|
char *mqttstate = mqttstate_str;
|
||||||
char mqttstate[16];
|
|
||||||
|
|
||||||
if (!Settings.flag.hass_discovery) {
|
|
||||||
if (MqttAction <= 3) {
|
if (MqttAction <= 3) {
|
||||||
if (MqttAction != 3) { SendKey(KEY_SWITCH, switch_id, MqttAction); }
|
if (MqttAction != 3) { SendKey(KEY_SWITCH, switch_id, MqttAction); }
|
||||||
snprintf_P(mqttstate, sizeof(mqttstate), PSTR("%s"), SettingsText(SET_STATE_TXT1 + MqttAction));
|
mqttstate = SettingsText(SET_STATE_TXT1 + MqttAction);
|
||||||
} else {
|
} else {
|
||||||
GetTextIndexed(mqttstate, sizeof(mqttstate), MqttAction, kSwitchPressStates);
|
GetTextIndexed(mqttstate_str, sizeof(mqttstate_str), MqttAction, kSwitchPressStates);
|
||||||
}
|
}
|
||||||
snprintf_P(scommand, sizeof(scommand), PSTR("SWITCH%d"), switch_id);
|
Response_P(PSTR("{\"%s\":{\"Action\":\"%s\"}}"), GetSwitchText(switch_id -1).c_str(), mqttstate);
|
||||||
GetTopic_P(stopic, STAT, TasmotaGlobal.mqtt_topic, scommand);
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_JSON_SWITCH));
|
||||||
Response_P(S_JSON_COMMAND_SVALUE, "ACTION", mqttstate);
|
|
||||||
MqttPublish(stopic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user