From 18cbb41a7f1f44e333dacacb7d47d34cd782a286 Mon Sep 17 00:00:00 2001 From: Grigorii Merkushev Date: Tue, 18 May 2021 09:02:35 +0200 Subject: [PATCH] feat: add heater phase telemetry --- esp32/src/climate.cpp | 6 +----- esp32/src/climate_data.h | 7 +++++++ esp32/src/telemetry.cpp | 7 +++++++ esp32/src/telemetry.h | 1 + server/server.go | 13 +++++++------ 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/esp32/src/climate.cpp b/esp32/src/climate.cpp index 6517afc..05067f6 100644 --- a/esp32/src/climate.cpp +++ b/esp32/src/climate.cpp @@ -39,11 +39,6 @@ namespace Climate volatile byte relayState = LOW; - enum HeaterPhase - { - heating, - cooling - }; HeaterPhase heaterPhase; @@ -166,6 +161,7 @@ namespace Climate telemetryData.hotCenter = hotCenter; telemetryData.coldCenter = coldCenter; telemetryData.coldSide = coldSide; + telemetryData.heaterPhase = heaterPhase; telemetryData.climateConfig.dayMaxTemp = DAY_MAX_TEMP; telemetryData.climateConfig.nightMaxTemp = NIGHT_MAX_TEMP; diff --git a/esp32/src/climate_data.h b/esp32/src/climate_data.h index 78e72ce..c336a58 100644 --- a/esp32/src/climate_data.h +++ b/esp32/src/climate_data.h @@ -11,6 +11,13 @@ namespace Climate float t; float h; }; + + + enum HeaterPhase + { + heating, + cooling + }; } #endif \ No newline at end of file diff --git a/esp32/src/telemetry.cpp b/esp32/src/telemetry.cpp index 959f7de..31965f3 100644 --- a/esp32/src/telemetry.cpp +++ b/esp32/src/telemetry.cpp @@ -19,6 +19,13 @@ namespace Telemetry StaticJsonDocument<400> doc; doc["heater"] = telemteryData.heater; + if (telemteryData.heaterPhase == cooling){ + doc["heater_phase"] = "cooling"; + }else{ + doc["heater_phase"] = "heating"; + } + + doc.createNestedObject("hot_side"); doc["hot_side"]["H"] = telemteryData.hotSide.h; diff --git a/esp32/src/telemetry.h b/esp32/src/telemetry.h index eae40b5..18d3fdb 100644 --- a/esp32/src/telemetry.h +++ b/esp32/src/telemetry.h @@ -26,6 +26,7 @@ namespace Telemetry ClimateData coldSide; ClimateConfig climateConfig; bool heater; + HeaterPhase heaterPhase; }; void send(TelemteryData telemteryData); diff --git a/server/server.go b/server/server.go index 5332751..4fd3db7 100644 --- a/server/server.go +++ b/server/server.go @@ -24,12 +24,13 @@ type ClimateConfig struct { } type Data struct { - HotSide ClimateData `json:"hot_side"` - HotCenter ClimateData `json:"hot_center"` - ColdCenter ClimateData `json:"cold_center"` - ColdSide ClimateData `json:"cold_side"` - Heater bool `json:"heater"` - Config ClimateConfig `json:"climate_config"` + HotSide ClimateData `json:"hot_side"` + HotCenter ClimateData `json:"hot_center"` + ColdCenter ClimateData `json:"cold_center"` + ColdSide ClimateData `json:"cold_side"` + Heater bool `json:"heater"` + Config ClimateConfig `json:"climate_config"` + HeaterPhase string `json:"heater_phase"` } var errResponse struct {