Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MQTT cmds with values #3416

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion code/components/jomjol_mqtt/server_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ bool sendHomeAssistantDiscoveryTopic(std::string group, std::string field,
else if (field == "flowstart") { // Special case: Button
topicFull = "homeassistant/button/" + node_id + "/" + configTopic + "/config";
}
else if (field == "set_prevalue") { // Special case: Command with payload
topicFull = "homeassistant/number/" + node_id + "/" + configTopic + "/config";
}
else {
topicFull = "homeassistant/sensor/" + node_id + "/" + configTopic + "/config";
}
Expand Down Expand Up @@ -119,7 +122,11 @@ bool sendHomeAssistantDiscoveryTopic(std::string group, std::string field,
}
else if (field == "flowstart") { // Special case: Button
payload += "\"cmd_t\":\"~/ctrl/flow_start\","; // Add command topic
payload += "\"pl_prs\":\"1\",";
// payload += "\"pl_prs\":\"1\",";
}
else if (field == "set_prevalue") { // Special case: Command with value
payload += "\"cmd_t\":\"~/ctrl/set_prevalue\","; // Add command topic
payload += "\"pl_prs\":\"0\",";
}
else {
payload += "\"state_topic\": \"~/" + field + "\",";
Expand Down Expand Up @@ -184,6 +191,7 @@ bool MQTThomeassistantDiscovery(int qos) {
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic("", "IP", "IP", "network-outline", "", "", "", "diagnostic", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic("", "status", "Status", "list-status", "", "", "", "diagnostic", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic("", "flowstart", "Manual Flow Start", "timer-play-outline", "", "", "", "", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic("", "set_prevalue", "Set Pre-Value", "swap-vertical", "", "", "", "", qos);


for (int i = 0; i < (*NUMBERS).size(); ++i) {
Expand Down
Loading