Browse Source

Adding description field to web UI, reporting it via MQTT (#1523)

sensors
Xose Pérez 5 years ago
parent
commit
f6b8baf37d
16 changed files with 18067 additions and 17969 deletions
  1. +5
    -0
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.all.html.gz
  3. BIN
      code/espurna/data/index.light.html.gz
  4. BIN
      code/espurna/data/index.rfbridge.html.gz
  5. BIN
      code/espurna/data/index.rfm69.html.gz
  6. BIN
      code/espurna/data/index.sensor.html.gz
  7. BIN
      code/espurna/data/index.small.html.gz
  8. +3145
    -3133
      code/espurna/static/index.all.html.gz.h
  9. +2997
    -2985
      code/espurna/static/index.light.html.gz.h
  10. +2602
    -2590
      code/espurna/static/index.rfbridge.html.gz.h
  11. +4079
    -4067
      code/espurna/static/index.rfm69.html.gz.h
  12. +2660
    -2648
      code/espurna/static/index.sensor.html.gz.h
  13. +2557
    -2545
      code/espurna/static/index.small.html.gz.h
  14. +9
    -1
      code/espurna/utils.ino
  15. +2
    -0
      code/espurna/ws.ino
  16. +11
    -0
      code/html/index.html

+ 5
- 0
code/espurna/config/general.h View File

@ -235,6 +235,10 @@
#define HEARTBEAT_REPORT_HOSTNAME 1
#endif
#ifndef HEARTBEAT_REPORT_DESCRITION
#define HEARTBEAT_REPORT_DESCRITION 1
#endif
#ifndef HEARTBEAT_REPORT_APP
#define HEARTBEAT_REPORT_APP 1
#endif
@ -802,6 +806,7 @@
#define MQTT_TOPIC_APP "app"
#define MQTT_TOPIC_INTERVAL "interval"
#define MQTT_TOPIC_HOSTNAME "host"
#define MQTT_TOPIC_DESCRIPTION "desc"
#define MQTT_TOPIC_TIME "time"
#define MQTT_TOPIC_RFOUT "rfout"
#define MQTT_TOPIC_RFIN "rfin"


BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


+ 3145
- 3133
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2997
- 2985
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2602
- 2590
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 4079
- 4067
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 2660
- 2648
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 2557
- 2545
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 9
- 1
code/espurna/utils.ino View File

@ -164,7 +164,8 @@ namespace Heartbeat {
Version = 1 << 14,
Board = 1 << 15,
Loadavg = 1 << 16,
Interval = 1 << 17
Interval = 1 << 17,
Description = 1 << 18
};
constexpr uint32_t defaultValue() {
@ -180,6 +181,7 @@ namespace Heartbeat {
(Relay * (HEARTBEAT_REPORT_RELAY)) | \
(Light * (HEARTBEAT_REPORT_LIGHT)) | \
(Hostname * (HEARTBEAT_REPORT_HOSTNAME)) | \
(Description * (HEARTBEAT_REPORT_DESCRITION)) | \
(App * (HEARTBEAT_REPORT_APP)) | \
(Version * (HEARTBEAT_REPORT_VERSION)) | \
(Board * (HEARTBEAT_REPORT_BOARD)) | \
@ -247,6 +249,12 @@ void heartbeat() {
if (hb_cfg & Heartbeat::Hostname)
mqttSend(MQTT_TOPIC_HOSTNAME, getSetting("hostname", getIdentifier()).c_str());
if (hb_cfg & Heartbeat::Description) {
if (hasSetting("desc")) {
mqttSend(MQTT_TOPIC_DESCRIPTION, getSetting("desc").c_str());
}
}
if (hb_cfg & Heartbeat::Ssid)
mqttSend(MQTT_TOPIC_SSID, WiFi.SSID().c_str());


+ 2
- 0
code/espurna/ws.ino View File

@ -293,6 +293,7 @@ bool _wsOnReceive(const char * key, JsonVariant& value) {
if (strncmp(key, "ws", 2) == 0) return true;
if (strncmp(key, "admin", 5) == 0) return true;
if (strncmp(key, "hostname", 8) == 0) return true;
if (strncmp(key, "desc", 4) == 0) return true;
if (strncmp(key, "webPort", 7) == 0) return true;
return false;
}
@ -335,6 +336,7 @@ void _wsOnStart(JsonObject& root) {
root["channel"] = WiFi.channel();
root["device"] = DEVICE;
root["hostname"] = getSetting("hostname");
root["desc"] = getSetting("desc");
root["network"] = getNetwork();
root["deviceip"] = getIP();
root["sketch_size"] = ESP.getSketchSize();


+ 11
- 0
code/html/index.html View File

@ -84,6 +84,7 @@
<span class="pure-menu-heading" name="hostname">HOSTNAME</span>
<span class="pure-menu-heading small" name="title">ESPurna 0.0.0</span>
<span class="pure-menu-heading small" name="desc"></span>
<ul class="pure-menu-list">
@ -342,6 +343,16 @@
</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Description</label>
<input name="desc" class="pure-u-1 pure-u-lg-3-4" maxlength="64" type="text" tabindex="2" />
<div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">
Human-friendly name for your device. Will be reported with the heartbeat.<br />
You can use this to specify the location or some other identification information.
</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Double click delay</label>
<input name="btnDelay" class="pure-u-1 pure-u-lg-1-4" type="number" action="reboot" min="0" step="100" max="1000" tabindex="6" />


Loading…
Cancel
Save