Skip to content

Commit b0814fd

Browse files
committed
Make entries starting with $ as internal
1 parent 4191396 commit b0814fd

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

src/EasyMqtt.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,23 @@ class EasyMqtt : public MqttEntry {
103103
setInterval(60);
104104
setForce(10);
105105

106-
get("system").setInterval(300);
107-
get("system")["deviceId"] << [this]() {
106+
get("$system").setInterval(300);
107+
//get("$system").setInternal(true);
108+
get("$system")["deviceId"] << [this]() {
108109
return deviceId;
109110
};
110-
get("system")["mem"]["heap"] << []() {
111+
get("$system")["mem"]["heap"] << []() {
111112
return String(ESP.getFreeHeap());
112113
};
113-
get("system")["uptime"] << []() {
114+
get("$system")["uptime"] << []() {
114115
return String(millis() / 1000);
115116
};
116117

117118
// Setup wifi diag
118-
get("system")["wifi"]["rssi"] << []() {
119+
get("$system")["wifi"]["rssi"] << []() {
119120
return String(WiFi.RSSI());
120121
};
121-
get("system")["wifi"]["quality"] << []() {
122+
get("$system")["wifi"]["quality"] << []() {
122123
int rssi = WiFi.RSSI();
123124
int quality = 0;
124125
if(rssi <= -100) {
@@ -129,14 +130,14 @@ class EasyMqtt : public MqttEntry {
129130
}
130131
return String(quality);
131132
};
132-
get("system")["wifi"]["ssid"] << []() {
133+
get("$system")["wifi"]["ssid"] << []() {
133134
return WiFi.SSID();
134135
};
135-
get("system")["wifi"]["ip"] << []() {
136+
get("$system")["wifi"]["ip"] << []() {
136137
return WiFi.localIP().toString();
137138
};
138139

139-
get("system")["restart"] >> [this](String value) {
140+
get("$system")["restart"] >> [this](String value) {
140141
if(value == "restart") {
141142
debug("Restart");
142143
ESP.restart();
@@ -149,7 +150,7 @@ class EasyMqtt : public MqttEntry {
149150
Serial.println(msg);
150151
#endif
151152
if(mqttClient.connected()) {
152-
get("system/debug").publish(msg);
153+
get("$system/debug").publish(msg);
153154
}
154155
}
155156

src/MqttEntry.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class MqttEntry {
1515
int force = 0;
1616
int interval = -1;
1717
int forceUpdate = -1;
18-
bool internal = false;
1918
unsigned long lastUpdate = 0;
2019
String lastValue = "";
2120

@@ -62,11 +61,6 @@ class MqttEntry {
6261
}
6362
}
6463

65-
MqttEntry *setInternal(bool internal) {
66-
this->internal = internal;
67-
return this;
68-
}
69-
7064
MqttEntry *getParent() {
7165
return parent;
7266
}
@@ -139,6 +133,7 @@ class MqttEntry {
139133
}
140134

141135
bool isInternal() {
136+
bool internal = name[0] == '$';
142137
if (parent) {
143138
return internal || parent->isInternal();
144139
} else {

src/WebPortal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class WebPortal {
9696
});
9797
page += FPSTR(HTML_MAIN5);
9898
// About
99-
page.replace("{device_id}", mqtt->get("system/deviceId").getValue());
99+
page.replace("{device_id}", mqtt->get("$system/deviceId").getValue());
100100
page.replace("{topic}", mqtt->getTopic());
101101
webServer->send(200, "text/html", page);
102102
}

0 commit comments

Comments
 (0)