mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-06 19:46:54 +03:00
Added parameter to enable/disable Homeassistant Discovery
This commit is contained in:
@@ -24,6 +24,7 @@ extern const char* libfive_git_revision(void);
|
||||
extern const char* libfive_git_branch(void);
|
||||
|
||||
std::vector<NumberPost*>* NUMBERS;
|
||||
bool HomeassistantDiscovery = false;
|
||||
|
||||
void sendHomeAssistantDiscoveryTopic(std::string maintopic, std::string group, std::string field,
|
||||
std::string name, std::string icon, std::string unit, std::string deviceClass, std::string stateClass) {
|
||||
@@ -151,7 +152,9 @@ void publishRuntimeData(std::string maintopic, int SetRetainFlag) {
|
||||
}
|
||||
|
||||
void GotConnected(std::string maintopic, int SetRetainFlag) {
|
||||
MQTThomeassistantDiscovery(maintopic);
|
||||
if (HomeassistantDiscovery) {
|
||||
MQTThomeassistantDiscovery(maintopic);
|
||||
}
|
||||
|
||||
MQTTPublish(maintopic + "/" + "MAC", getMac(), SetRetainFlag);
|
||||
MQTTPublish(maintopic + "/" + "IP", *getIPAddress(), SetRetainFlag);
|
||||
@@ -268,6 +271,11 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
if (toUpper(zerlegt[1]) == "TRUE")
|
||||
SetRetainFlag = 1;
|
||||
}
|
||||
if ((toUpper(zerlegt[0]) == "HOMEASSISTANTDISCOVERY") && (zerlegt.size() > 1))
|
||||
{
|
||||
if (toUpper(zerlegt[1]) == "TRUE")
|
||||
HomeassistantDiscovery = true;
|
||||
}
|
||||
|
||||
if ((toUpper(zerlegt[0]) == "CLIENTID") && (zerlegt.size() > 1))
|
||||
{
|
||||
|
||||
@@ -625,6 +625,22 @@ textarea {
|
||||
Enable or disable the retain flag for all MQTT entries
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="indent1">
|
||||
<input type="checkbox" id="MQTT_HomeassistantDiscovery_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "HomeassistantDiscovery")' unchecked >
|
||||
<label for=MQTT_HomeassistantDiscovery_enabled><class id="MQTT_HomeassistantDiscovery_text" style="color:black;">Enable Homeassistant Discovery</class></label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="MQTT_HomeassistantDiscovery_value1">
|
||||
<option value="true" selected>true</option>
|
||||
<option value="false" >false</option>
|
||||
</select>
|
||||
</td>
|
||||
<td style="font-size: 80%;">
|
||||
Enable or disable the <a href=https://www.home-assistant.io/docs/mqtt/discovery/ target=_blank>Homeassistand Discovery</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="3" style="padding-left: 20px;">
|
||||
@@ -1715,6 +1731,7 @@ function UpdateInput() {
|
||||
WriteParameter(param, category, "MQTT", "user", true);
|
||||
WriteParameter(param, category, "MQTT", "password", true);
|
||||
WriteParameter(param, category, "MQTT", "SetRetainFlag", true);
|
||||
WriteParameter(param, category, "MQTT", "HomeassistantDiscovery", true);
|
||||
|
||||
WriteParameter(param, category, "InfluxDB", "Uri", true);
|
||||
WriteParameter(param, category, "InfluxDB", "Database", true);
|
||||
@@ -1831,6 +1848,7 @@ function ReadParameterAll()
|
||||
ReadParameter(param, "MQTT", "user", true);
|
||||
ReadParameter(param, "MQTT", "password", true);
|
||||
ReadParameter(param, "MQTT", "SetRetainFlag", true);
|
||||
ReadParameter(param, "MQTT", "HomeassistantDiscovery", true);
|
||||
|
||||
ReadParameter(param, "InfluxDB", "Uri", true);
|
||||
ReadParameter(param, "InfluxDB", "Database", true);
|
||||
|
||||
@@ -187,6 +187,7 @@ function ParseConfig() {
|
||||
ParamAddValue(param, catname, "user");
|
||||
ParamAddValue(param, catname, "password");
|
||||
ParamAddValue(param, catname, "SetRetainFlag");
|
||||
ParamAddValue(param, catname, "HomeassistantDiscovery");
|
||||
|
||||
var catname = "InfluxDB";
|
||||
category[catname] = new Object();
|
||||
|
||||
Reference in New Issue
Block a user