Skip to content

Commit

Permalink
feat: add heater phase telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
brushknight committed May 18, 2021
1 parent e66d012 commit 18cbb41
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
6 changes: 1 addition & 5 deletions esp32/src/climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ namespace Climate

volatile byte relayState = LOW;

enum HeaterPhase
{
heating,
cooling
};

HeaterPhase heaterPhase;

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions esp32/src/climate_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ namespace Climate
float t;
float h;
};


enum HeaterPhase
{
heating,
cooling
};
}

#endif
7 changes: 7 additions & 0 deletions esp32/src/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions esp32/src/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Telemetry
ClimateData coldSide;
ClimateConfig climateConfig;
bool heater;
HeaterPhase heaterPhase;
};

void send(TelemteryData telemteryData);
Expand Down
13 changes: 7 additions & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 18cbb41

Please sign in to comment.