Add Home Assistant Auto Discovery buttons
This commit is contained in:
67
Network.cpp
67
Network.cpp
@@ -942,6 +942,55 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
|||||||
{ "pl_off", "0" },
|
{ "pl_off", "0" },
|
||||||
{ "state_on", "1" },
|
{ "state_on", "1" },
|
||||||
{ "state_off", "0" }});
|
{ "state_off", "0" }});
|
||||||
|
|
||||||
|
// Lock 'n' Go
|
||||||
|
publishHassTopic("button",
|
||||||
|
"lockngo",
|
||||||
|
uidString,
|
||||||
|
"_lock_n_go_button",
|
||||||
|
"Lock 'n' Go",
|
||||||
|
name,
|
||||||
|
baseTopic,
|
||||||
|
mqtt_topic_mqtt_connection_state,
|
||||||
|
deviceType,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
mqtt_topic_lock_action,
|
||||||
|
{ { "pl_prs", "lockNgo" }});
|
||||||
|
|
||||||
|
// Lock 'n' Go with unlatch
|
||||||
|
publishHassTopic("button",
|
||||||
|
"lockngounlatch",
|
||||||
|
uidString,
|
||||||
|
"_lock_n_go_unlatch_button",
|
||||||
|
"Lock 'n' Go with unlatch",
|
||||||
|
name,
|
||||||
|
baseTopic,
|
||||||
|
mqtt_topic_mqtt_connection_state,
|
||||||
|
deviceType,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
mqtt_topic_lock_action,
|
||||||
|
{ { "pl_prs", "lockNgoUnlatch" }});
|
||||||
|
|
||||||
|
// Unlatch
|
||||||
|
publishHassTopic("button",
|
||||||
|
"unlatch",
|
||||||
|
uidString,
|
||||||
|
"_unlatch_button",
|
||||||
|
"Unlatch",
|
||||||
|
name,
|
||||||
|
baseTopic,
|
||||||
|
mqtt_topic_mqtt_connection_state,
|
||||||
|
deviceType,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
mqtt_topic_lock_action,
|
||||||
|
{ { "pl_prs", "unlatch" }});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//json["cmd_t"] = String("~") + String(mqtt_topic_lock_action);
|
//json["cmd_t"] = String("~") + String(mqtt_topic_lock_action);
|
||||||
@@ -1272,6 +1321,24 @@ void Network::removeHASSConfig(char* uidString)
|
|||||||
path.concat("/battery_low/config");
|
path.concat("/battery_low/config");
|
||||||
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||||
|
|
||||||
|
path = discoveryTopic;
|
||||||
|
path.concat("/button/");
|
||||||
|
path.concat(uidString);
|
||||||
|
path.concat("/lockngo/config");
|
||||||
|
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||||
|
|
||||||
|
path = discoveryTopic;
|
||||||
|
path.concat("/button/");
|
||||||
|
path.concat(uidString);
|
||||||
|
path.concat("/lockngounlatch/config");
|
||||||
|
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||||
|
|
||||||
|
path = discoveryTopic;
|
||||||
|
path.concat("/button/");
|
||||||
|
path.concat(uidString);
|
||||||
|
path.concat("/unlatch/config");
|
||||||
|
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||||
|
|
||||||
path = discoveryTopic;
|
path = discoveryTopic;
|
||||||
path.concat("/sensor/");
|
path.concat("/sensor/");
|
||||||
path.concat(uidString);
|
path.concat(uidString);
|
||||||
|
|||||||
Reference in New Issue
Block a user