Skip to content

Commit

Permalink
correction bug HA switch
Browse files Browse the repository at this point in the history
  • Loading branch information
xlyric committed Nov 19, 2024
1 parent 1234ab6 commit 8ed4c3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/function/ha.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ private: String HA_sensor_type() {
"\"value_template\": \"{{ value_json."+ object_id +" }}\",";
}
else if (entity_type == "switch") {
info = "\"val_tpl\": \"{{ value_json."+ object_id +" }}\","
"\"pl\": \"{{ value_json."+ object_id +" }}\","
"\"pl_on\": \"{ \\\""+object_id+"\\\" : \\\"1\\\" } \","
"\"pl_off\": \"{ \\\""+object_id+"\\\" : \\\"0\\\" } \","
"\"stat_on\":1,"
"\"stat_off\":0,"
"\"qos\":1,"
"\"cmd_t\": \""+ topic_Xlyric + "command/" + entity_type + "/" + object_id + "\",";
info = R"(
"value_template": "{{ value_json.)" + object_id + R"( }}",
"payload_on": "{ \")" + object_id + R"(\" : 1 }",
"payload_off": "{ \")" + object_id + R"(\" : 0 }",
"stat_on": "1",
"stat_off": "0",
"qos": 1,
"command_topic": ")" + topic_Xlyric + R"(command/)" + entity_type + R"(/)" + object_id + R"(",
)";
}
else if (entity_type == "number") {
info = "\"val_tpl\": \"{{ value_json."+ object_id +" }}\","
Expand Down
1 change: 1 addition & 0 deletions src/function/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void callback(char* topic, byte* payload, unsigned int length) {

/// @brief Enregistrement des requetes de commandes
if (strstr( topic, command_switch.c_str() ) != nullptr) {
logging.Set_log_init("MQTT command switch ",true);
#ifdef RELAY1
if (doc2["relay1"].is<int>()) {
int relay = doc2["relay1"];
Expand Down

0 comments on commit 8ed4c3f

Please sign in to comment.