Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
hearbeat in JSON - #217
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Oct 21, 2019
1 parent ce28424 commit 31d1f4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Report # TCP dropouts in the `system` command. These could be due to WiFI or MQTT disconnected.
- Added temp and mode to the MQTT `thermostat_cmd` topic

### Fixed

### Changed

- Heartbeat MQTT payload is now in JSON

### Removed

## [1.9.2] 2019-10-19
Expand Down Expand Up @@ -41,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- All MQTT topics for the Thermostat have the Heating Circuit appended (e.g. `thermostat_data1`). This includes the commands.
- Shower timer and shower alert and not MQTT published at boot up
- Heating Active logic change to use Selected Flow Temp of min 30 instead of 70 (https://github.com/proddy/EMS-ESP/issues/193)
- Cleaned up Telnet messages during bootup to only show key information.

### Removed

Expand Down
33 changes: 16 additions & 17 deletions src/MyESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,23 +1379,22 @@ void MyESP::_heartbeatCheck(bool force = false) {
uint32_t free_memory = ESP.getFreeHeap();
uint8_t mem_available = 100 * free_memory / total_memory; // as a %

char payload[300] = {0};
char s[10];
strlcpy(payload, "version=", sizeof(payload));
strlcat(payload, _app_version, sizeof(payload)); // version
strlcat(payload, ", IP=", sizeof(payload));
strlcat(payload, WiFi.localIP().toString().c_str(), sizeof(payload)); // IP address
strlcat(payload, ", rssid=", sizeof(payload));
strlcat(payload, itoa(getWifiQuality(), s, 10), sizeof(payload)); // rssi %
strlcat(payload, "%, load=", sizeof(payload));
strlcat(payload, ltoa(getSystemLoadAverage(), s, 10), sizeof(payload)); // load
strlcat(payload, "%, uptime=", sizeof(payload));
strlcat(payload, ltoa(_getUptime(), s, 10), sizeof(payload)); // uptime in secs
strlcat(payload, "secs, freemem=", sizeof(payload));
strlcat(payload, itoa(mem_available, s, 10), sizeof(payload)); // free mem as a %
strlcat(payload, "%", sizeof(payload));

mqttPublish(MQTT_TOPIC_HEARTBEAT, payload, false); // send to MQTT with retain off
StaticJsonDocument<200> doc;
JsonObject rootHeartbeat = doc.to<JsonObject>();

rootHeartbeat["version"] = _app_version;
rootHeartbeat["IP"] = WiFi.localIP().toString().c_str();
rootHeartbeat["rssid"] = getWifiQuality();
rootHeartbeat["load"] = getSystemLoadAverage();
rootHeartbeat["uptime"] = _getUptime();
rootHeartbeat["freemem"] = mem_available;

char data[300] = {0};
serializeJson(doc, data, sizeof(data));

// myDebugLog("Publishing hearbeat via MQTT");

(void)mqttPublish(MQTT_TOPIC_HEARTBEAT, data, false); // send to MQTT with retain off
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define APP_VERSION "1.9.3b2"
#define APP_VERSION "1.9.3b3"

0 comments on commit 31d1f4c

Please sign in to comment.