mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
web and shell printing share common functions - refactor how device values are printed to shell #632
This commit is contained in:
@@ -85,17 +85,17 @@ void Boiler::register_mqtt_ha_config() {
|
||||
|
||||
// Create the Master device
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_HA_CONFIG> doc;
|
||||
doc["name"] = F("Service Code");
|
||||
doc["uniq_id"] = F("boiler");
|
||||
doc["ic"] = F("mdi:home-thermometer-outline");
|
||||
doc["name"] = FJSON("Service Code");
|
||||
doc["uniq_id"] = FJSON("boiler");
|
||||
doc["ic"] = FJSON("mdi:home-thermometer-outline");
|
||||
|
||||
char stat_t[50];
|
||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/boiler_data"), System::hostname().c_str());
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
doc["val_tpl"] = F("{{value_json.serviceCode}}");
|
||||
doc["val_tpl"] = FJSON("{{value_json.serviceCode}}");
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = F("EMS-ESP Boiler");
|
||||
dev["name"] = FJSON("EMS-ESP Boiler");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = name();
|
||||
@@ -191,43 +191,47 @@ void Boiler::device_info_web(JsonArray & root) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
print_value_json(root, F("heatingActive"), nullptr, F_(heatingActive), nullptr, json);
|
||||
print_value_json(root, F("tapwaterActive"), nullptr, F_(tapwaterActive), nullptr, json);
|
||||
print_value_json(root, F("serviceCode"), nullptr, F_(serviceCode), nullptr, json);
|
||||
print_value_json(root, F("serviceCodeNumber"), nullptr, F_(serviceCodeNumber), nullptr, json);
|
||||
print_value_json(root, F("lastCode"), nullptr, F_(lastCode), nullptr, json);
|
||||
print_value_json(root, F("selFlowTemp"), nullptr, F_(selFlowTemp), F_(degrees), json);
|
||||
print_value_json(root, F("selBurnPow"), nullptr, F_(selBurnPow), F_(percent), json);
|
||||
print_value_json(root, F("curBurnPow"), nullptr, F_(curBurnPow), F_(percent), json);
|
||||
print_value_json(root, F("pumpMod"), nullptr, F_(pumpMod), F_(percent), json);
|
||||
print_value_json(root, F("pumpMod2"), nullptr, F_(pumpMod2), F_(percent), json);
|
||||
print_value_json(root, F("outdoorTemp"), nullptr, F_(outdoorTemp), F_(degrees), json);
|
||||
print_value_json(root, F("curFlowTemp"), nullptr, F_(curFlowTemp), F_(degrees), json);
|
||||
print_value_json(root, F("retTemp"), nullptr, F_(retTemp), F_(degrees), json);
|
||||
print_value_json(root, F("switchTemp"), nullptr, F_(switchTemp), F_(degrees), json);
|
||||
print_value_json(root, F("sysPress"), nullptr, F_(sysPress), nullptr, json);
|
||||
print_value_json(root, F("boilTemp"), nullptr, F_(boilTemp), F_(degrees), json);
|
||||
print_value_json(root, F("burnGas"), nullptr, F_(burnGas), nullptr, json);
|
||||
print_value_json(root, F("flameCurr"), nullptr, F_(flameCurr), F_(uA), json);
|
||||
print_value_json(root, F("heatPump"), nullptr, F_(heatPump), nullptr, json);
|
||||
print_value_json(root, F("fanWork"), nullptr, F_(fanWork), nullptr, json);
|
||||
print_value_json(root, F("ignWork"), nullptr, F_(ignWork), nullptr, json);
|
||||
print_value_json(root, F("heatingActivated"), nullptr, F_(heatingActivated), nullptr, json);
|
||||
print_value_json(root, F("heatingTemp"), nullptr, F_(heatingTemp), F_(degrees), json);
|
||||
print_value_json(root, F("pumpModMax"), nullptr, F_(pumpModMax), F_(percent), json);
|
||||
print_value_json(root, F("pumpModMin"), nullptr, F_(pumpModMin), F_(percent), json);
|
||||
print_value_json(root, F("pumpDelay"), nullptr, F_(pumpDelay), F_(min), json);
|
||||
print_value_json(root, F("burnMinPeriod"), nullptr, F_(burnMinPeriod), F_(min), json);
|
||||
print_value_json(root, F("burnMinPower"), nullptr, F_(burnMinPower), F_(percent), json);
|
||||
print_value_json(root, F("burnMaxPower"), nullptr, F_(burnMaxPower), F_(percent), json);
|
||||
print_value_json(root, F("boilHystOn"), nullptr, F_(boilHystOn), F_(degrees), json);
|
||||
print_value_json(root, F("boilHystOff"), nullptr, F_(boilHystOff), F_(degrees), json);
|
||||
print_value_json(root, F("setFlowTemp"), nullptr, F_(setFlowTemp), F_(degrees), json);
|
||||
print_value_json(root, F("setBurnPow"), nullptr, F_(setBurnPow), F_(percent), json);
|
||||
print_value_json(root, F("burnStarts"), nullptr, F_(burnStarts), nullptr, json);
|
||||
print_value_json(root, F("burnWorkMin"), nullptr, F_(burnWorkMin), F_(min), json);
|
||||
print_value_json(root, F("heatWorkMin"), nullptr, F_(heatWorkMin), F_(min), json);
|
||||
print_value_json(root, F("UBAuptime"), nullptr, F_(UBAuptime), F_(min), json);
|
||||
create_value_json(root, F("heatingActive"), nullptr, F_(heatingActive), nullptr, json);
|
||||
create_value_json(root, F("tapwaterActive"), nullptr, F_(tapwaterActive), nullptr, json);
|
||||
create_value_json(root, F("serviceCode"), nullptr, F_(serviceCode), nullptr, json);
|
||||
create_value_json(root, F("serviceCodeNumber"), nullptr, F_(serviceCodeNumber), nullptr, json);
|
||||
create_value_json(root, F("lastCode"), nullptr, F_(lastCode), nullptr, json);
|
||||
create_value_json(root, F("selFlowTemp"), nullptr, F_(selFlowTemp), F_(degrees), json);
|
||||
create_value_json(root, F("selBurnPow"), nullptr, F_(selBurnPow), F_(percent), json);
|
||||
create_value_json(root, F("curBurnPow"), nullptr, F_(curBurnPow), F_(percent), json);
|
||||
create_value_json(root, F("pumpMod"), nullptr, F_(pumpMod), F_(percent), json);
|
||||
create_value_json(root, F("pumpMod2"), nullptr, F_(pumpMod2), F_(percent), json);
|
||||
create_value_json(root, F("outdoorTemp"), nullptr, F_(outdoorTemp), F_(degrees), json);
|
||||
create_value_json(root, F("curFlowTemp"), nullptr, F_(curFlowTemp), F_(degrees), json);
|
||||
create_value_json(root, F("retTemp"), nullptr, F_(retTemp), F_(degrees), json);
|
||||
create_value_json(root, F("switchTemp"), nullptr, F_(switchTemp), F_(degrees), json);
|
||||
create_value_json(root, F("sysPress"), nullptr, F_(sysPress), nullptr, json);
|
||||
create_value_json(root, F("boilTemp"), nullptr, F_(boilTemp), F_(degrees), json);
|
||||
create_value_json(root, F("burnGas"), nullptr, F_(burnGas), nullptr, json);
|
||||
create_value_json(root, F("flameCurr"), nullptr, F_(flameCurr), F_(uA), json);
|
||||
create_value_json(root, F("heatPump"), nullptr, F_(heatPump), nullptr, json);
|
||||
create_value_json(root, F("fanWork"), nullptr, F_(fanWork), nullptr, json);
|
||||
create_value_json(root, F("ignWork"), nullptr, F_(ignWork), nullptr, json);
|
||||
create_value_json(root, F("heatingActivated"), nullptr, F_(heatingActivated), nullptr, json);
|
||||
create_value_json(root, F("heatingTemp"), nullptr, F_(heatingTemp), F_(degrees), json);
|
||||
create_value_json(root, F("pumpModMax"), nullptr, F_(pumpModMax), F_(percent), json);
|
||||
create_value_json(root, F("pumpModMin"), nullptr, F_(pumpModMin), F_(percent), json);
|
||||
create_value_json(root, F("pumpDelay"), nullptr, F_(pumpDelay), F_(min), json);
|
||||
create_value_json(root, F("burnMinPeriod"), nullptr, F_(burnMinPeriod), F_(min), json);
|
||||
create_value_json(root, F("burnMinPower"), nullptr, F_(burnMinPower), F_(percent), json);
|
||||
create_value_json(root, F("burnMaxPower"), nullptr, F_(burnMaxPower), F_(percent), json);
|
||||
create_value_json(root, F("boilHystOn"), nullptr, F_(boilHystOn), F_(degrees), json);
|
||||
create_value_json(root, F("boilHystOff"), nullptr, F_(boilHystOff), F_(degrees), json);
|
||||
create_value_json(root, F("setFlowTemp"), nullptr, F_(setFlowTemp), F_(degrees), json);
|
||||
create_value_json(root, F("setBurnPow"), nullptr, F_(setBurnPow), F_(percent), json);
|
||||
create_value_json(root, F("burnStarts"), nullptr, F_(burnStarts), nullptr, json);
|
||||
create_value_json(root, F("burnWorkMin"), nullptr, F_(burnWorkMin), F_(min), json);
|
||||
create_value_json(root, F("heatWorkMin"), nullptr, F_(heatWorkMin), F_(min), json);
|
||||
create_value_json(root, F("UBAuptime"), nullptr, F_(UBAuptime), F_(min), json);
|
||||
|
||||
create_value_json(root, F("burnWorkMintxt"), nullptr, F_(burnWorkMintxt), nullptr, json);
|
||||
create_value_json(root, F("heatWorkMintxt"), nullptr, F_(heatWorkMintxt), nullptr, json);
|
||||
create_value_json(root, F("UBAuptimetxt"), nullptr, F_(UBAuptimetxt), nullptr, json);
|
||||
|
||||
doc.clear();
|
||||
if (!export_values_ww(json)) { // append ww values
|
||||
@@ -235,33 +239,35 @@ void Boiler::device_info_web(JsonArray & root) {
|
||||
}
|
||||
|
||||
// ww
|
||||
print_value_json(root, F("wWSelTemp"), nullptr, F_(wWSelTemp), F_(degrees), json);
|
||||
print_value_json(root, F("wWSetTemp"), nullptr, F_(wWSetTemp), F_(degrees), json);
|
||||
print_value_json(root, F("wWDisinfectionTemp"), nullptr, F_(wWDisinfectionTemp), F_(degrees), json);
|
||||
print_value_json(root, F("wWType"), nullptr, F_(wWType), nullptr, json);
|
||||
print_value_json(root, F("wWChargeType"), nullptr, F_(wWChargeType), nullptr, json);
|
||||
print_value_json(root, F("wWCircPump"), nullptr, F_(wWCircPump), nullptr, json);
|
||||
print_value_json(root, F("wWCircPumpMode"), nullptr, F_(wWCircPumpMode), nullptr, json);
|
||||
print_value_json(root, F("wWCirc"), nullptr, F_(wWCirc), nullptr, json);
|
||||
print_value_json(root, F("wWCurTemp"), nullptr, F_(wWCurTemp), F_(degrees), json);
|
||||
print_value_json(root, F("wWCurTemp2"), nullptr, F_(wWCurTemp2), F_(degrees), json);
|
||||
print_value_json(root, F("wWCurFlow"), nullptr, F_(wWCurFlow), F("l/min"), json);
|
||||
print_value_json(root, F("wwStorageTemp1"), nullptr, F_(wwStorageTemp1), F_(degrees), json);
|
||||
print_value_json(root, F("wwStorageTemp2"), nullptr, F_(wwStorageTemp2), F_(degrees), json);
|
||||
print_value_json(root, F("exhaustTemp"), nullptr, F_(exhaustTemp), F_(degrees), json);
|
||||
print_value_json(root, F("wWActivated"), nullptr, F_(wWActivated), nullptr, json);
|
||||
print_value_json(root, F("wWOneTime"), nullptr, F_(wWOneTime), nullptr, json);
|
||||
print_value_json(root, F("wWDisinfecting"), nullptr, F_(wWDisinfecting), nullptr, json);
|
||||
print_value_json(root, F("wWCharging"), nullptr, F_(wWCharging), nullptr, json);
|
||||
print_value_json(root, F("wWRecharging"), nullptr, F_(wWRecharging), nullptr, json);
|
||||
print_value_json(root, F("wWTempOK"), nullptr, F_(wWTempOK), nullptr, json);
|
||||
print_value_json(root, F("wWActive"), nullptr, F_(wWActive), nullptr, json);
|
||||
print_value_json(root, F("wWHeat"), nullptr, F_(wWHeat), nullptr, json);
|
||||
print_value_json(root, F("wWSetPumpPower"), nullptr, F_(wWSetPumpPower), F_(percent), json);
|
||||
print_value_json(root, F("wwMixTemperature"), nullptr, F_(wwMixTemperature), F_(degrees), json);
|
||||
print_value_json(root, F("wwBufferTemperature"), nullptr, F_(wwBufferTemperature), F_(degrees), json);
|
||||
print_value_json(root, F("wWStarts"), nullptr, F_(wWStarts), nullptr, json);
|
||||
print_value_json(root, F("wWWorkM"), nullptr, F_(wWWorkM), F_(min), json);
|
||||
create_value_json(root, F("wWSelTemp"), nullptr, F_(wWSelTemp), F_(degrees), json);
|
||||
create_value_json(root, F("wWSetTemp"), nullptr, F_(wWSetTemp), F_(degrees), json);
|
||||
create_value_json(root, F("wWDisinfectionTemp"), nullptr, F_(wWDisinfectionTemp), F_(degrees), json);
|
||||
create_value_json(root, F("wWType"), nullptr, F_(wWType), nullptr, json);
|
||||
create_value_json(root, F("wWChargeType"), nullptr, F_(wWChargeType), nullptr, json);
|
||||
create_value_json(root, F("wWCircPump"), nullptr, F_(wWCircPump), nullptr, json);
|
||||
create_value_json(root, F("wWCircPumpMode"), nullptr, F_(wWCircPumpMode), nullptr, json);
|
||||
create_value_json(root, F("wWCirc"), nullptr, F_(wWCirc), nullptr, json);
|
||||
create_value_json(root, F("wWCurTemp"), nullptr, F_(wWCurTemp), F_(degrees), json);
|
||||
create_value_json(root, F("wWCurTemp2"), nullptr, F_(wWCurTemp2), F_(degrees), json);
|
||||
create_value_json(root, F("wWCurFlow"), nullptr, F_(wWCurFlow), F("l/min"), json);
|
||||
create_value_json(root, F("wwStorageTemp1"), nullptr, F_(wwStorageTemp1), F_(degrees), json);
|
||||
create_value_json(root, F("wwStorageTemp2"), nullptr, F_(wwStorageTemp2), F_(degrees), json);
|
||||
create_value_json(root, F("exhaustTemp"), nullptr, F_(exhaustTemp), F_(degrees), json);
|
||||
create_value_json(root, F("wWActivated"), nullptr, F_(wWActivated), nullptr, json);
|
||||
create_value_json(root, F("wWOneTime"), nullptr, F_(wWOneTime), nullptr, json);
|
||||
create_value_json(root, F("wWDisinfecting"), nullptr, F_(wWDisinfecting), nullptr, json);
|
||||
create_value_json(root, F("wWCharging"), nullptr, F_(wWCharging), nullptr, json);
|
||||
create_value_json(root, F("wWRecharging"), nullptr, F_(wWRecharging), nullptr, json);
|
||||
create_value_json(root, F("wWTempOK"), nullptr, F_(wWTempOK), nullptr, json);
|
||||
create_value_json(root, F("wWActive"), nullptr, F_(wWActive), nullptr, json);
|
||||
create_value_json(root, F("wWHeat"), nullptr, F_(wWHeat), nullptr, json);
|
||||
create_value_json(root, F("wWSetPumpPower"), nullptr, F_(wWSetPumpPower), F_(percent), json);
|
||||
create_value_json(root, F("wwMixTemperature"), nullptr, F_(wwMixTemperature), F_(degrees), json);
|
||||
create_value_json(root, F("wwBufferTemperature"), nullptr, F_(wwBufferTemperature), F_(degrees), json);
|
||||
create_value_json(root, F("wWStarts"), nullptr, F_(wWStarts), nullptr, json);
|
||||
create_value_json(root, F("wWWorkM"), nullptr, F_(wWWorkM), F_(min), json);
|
||||
|
||||
create_value_json(root, F("wWWorkMtxt"), nullptr, F_(wWWorkMtxt), nullptr, json);
|
||||
}
|
||||
|
||||
bool Boiler::export_values(JsonObject & json) {
|
||||
@@ -280,11 +286,11 @@ bool Boiler::export_values_ww(JsonObject & json) {
|
||||
// Warm Water comfort setting
|
||||
if (Helpers::hasValue(wWComfort_)) {
|
||||
if (wWComfort_ == 0x00) {
|
||||
json["wWComfort"] = F("Hot");
|
||||
json["wWComfort"] = FJSON("Hot");
|
||||
} else if (wWComfort_ == 0xD8) {
|
||||
json["wWComfort"] = F("Eco");
|
||||
json["wWComfort"] = FJSON("Eco");
|
||||
} else if (wWComfort_ == 0xEC) {
|
||||
json["wWComfort"] = F("Intelligent");
|
||||
json["wWComfort"] = FJSON("Intelligent");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,20 +311,20 @@ bool Boiler::export_values_ww(JsonObject & json) {
|
||||
|
||||
// Warm Water type
|
||||
if (wWType_ == 0) { // no json if not set
|
||||
json["wWType"] = F("off");
|
||||
json["wWType"] = FJSON("off");
|
||||
} else if (wWType_ == 1) {
|
||||
json["wWType"] = F("flow");
|
||||
json["wWType"] = FJSON("flow");
|
||||
} else if (wWType_ == 2) {
|
||||
json["wWType"] = F("buffered flow");
|
||||
json["wWType"] = FJSON("buffered flow");
|
||||
} else if (wWType_ == 3) {
|
||||
json["wWType"] = F("buffer");
|
||||
json["wWType"] = FJSON("buffer");
|
||||
} else if (wWType_ == 4) {
|
||||
json["wWType"] = F("layered buffer");
|
||||
json["wWType"] = FJSON("layered buffer");
|
||||
}
|
||||
|
||||
// Warm Water charging type
|
||||
if (Helpers::hasValue(wWChargeType_, EMS_VALUE_BOOL)) {
|
||||
json["wWChargeType"] = wWChargeType_ ? F("3-way valve") : F("charge pump");
|
||||
json["wWChargeType"] = wWChargeType_ ? FJSON("3-way valve") : FJSON("charge pump");
|
||||
}
|
||||
|
||||
// Warm Water circulation pump available bool
|
||||
@@ -329,7 +335,7 @@ bool Boiler::export_values_ww(JsonObject & json) {
|
||||
// Warm Water circulation pump freq
|
||||
if (Helpers::hasValue(wWCircPumpMode_)) {
|
||||
if (wWCircPumpMode_ == 7) {
|
||||
json["wWCircPumpMode"] = F("continuous");
|
||||
json["wWCircPumpMode"] = FJSON("continuous");
|
||||
} else {
|
||||
char s[7];
|
||||
char buffer[2];
|
||||
@@ -434,6 +440,8 @@ bool Boiler::export_values_ww(JsonObject & json) {
|
||||
// Warm Water active time
|
||||
if (Helpers::hasValue(wWWorkM_)) {
|
||||
json["wWWorkM"] = wWWorkM_;
|
||||
char slong[40];
|
||||
json["wWWorkMtxt"] = Helpers::render_value(slong, wWWorkM_, EMS_VALUE_TIME); // Warm Water active time (full text)
|
||||
}
|
||||
|
||||
return (json.size());
|
||||
@@ -594,11 +602,7 @@ bool Boiler::export_values_main(JsonObject & json) {
|
||||
json["setFlowTemp"] = setFlowTemp_;
|
||||
}
|
||||
|
||||
// Total UBA working time
|
||||
if (Helpers::hasValue(UBAuptime_)) {
|
||||
json["UBAuptime"] = UBAuptime_;
|
||||
}
|
||||
|
||||
// burn power %
|
||||
if (Helpers::hasValue(setBurnPow_)) {
|
||||
json["setBurnPow"] = setBurnPow_;
|
||||
}
|
||||
@@ -611,15 +615,25 @@ bool Boiler::export_values_main(JsonObject & json) {
|
||||
// Total burner operating time
|
||||
if (Helpers::hasValue(burnWorkMin_)) {
|
||||
json["burnWorkMin"] = burnWorkMin_;
|
||||
char slong[40];
|
||||
json["burnWorkMintxt"] = Helpers::render_value(slong, burnWorkMin_, EMS_VALUE_TIME);
|
||||
}
|
||||
|
||||
// Total heat operating time
|
||||
if (Helpers::hasValue(heatWorkMin_)) {
|
||||
json["heatWorkMin"] = heatWorkMin_;
|
||||
char slong[40];
|
||||
json["heatWorkMintxt"] = Helpers::render_value(slong, heatWorkMin_, EMS_VALUE_TIME);
|
||||
}
|
||||
|
||||
// Service Code
|
||||
// Service Code Number
|
||||
// Total UBA working time
|
||||
if (Helpers::hasValue(UBAuptime_)) {
|
||||
json["UBAuptime"] = UBAuptime_;
|
||||
char slong[40];
|
||||
json["UBAuptimetxt"] = Helpers::render_value(slong, UBAuptime_, EMS_VALUE_TIME);
|
||||
}
|
||||
|
||||
// Service Code & Service Code Number
|
||||
if (Helpers::hasValue(serviceCodeNumber_)) {
|
||||
json["serviceCode"] = serviceCode_;
|
||||
json["serviceCodeNumber"] = serviceCodeNumber_;
|
||||
@@ -630,7 +644,7 @@ bool Boiler::export_values_main(JsonObject & json) {
|
||||
}
|
||||
|
||||
return (json.size());
|
||||
}
|
||||
} // namespace emsesp
|
||||
|
||||
// publish values via MQTT
|
||||
void Boiler::publish_values(JsonObject & json, bool force) {
|
||||
@@ -674,103 +688,6 @@ bool Boiler::updated_values() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// print values to shell console
|
||||
void Boiler::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // for showing the header
|
||||
|
||||
// fetch the values into a JSON document
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_LARGE> doc;
|
||||
JsonObject json = doc.to<JsonObject>();
|
||||
if (!export_values_main(json)) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
print_value_json(shell, F("heatingActive"), nullptr, F_(heatingActive), nullptr, json);
|
||||
print_value_json(shell, F("tapwaterActive"), nullptr, F_(tapwaterActive), nullptr, json);
|
||||
print_value_json(shell, F("serviceCode"), nullptr, F_(serviceCode), nullptr, json);
|
||||
print_value_json(shell, F("serviceCodeNumber"), nullptr, F_(serviceCodeNumber), nullptr, json);
|
||||
print_value_json(shell, F("lastCode"), nullptr, F_(lastCode), nullptr, json);
|
||||
print_value_json(shell, F("selFlowTemp"), nullptr, F_(selFlowTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("selBurnPow"), nullptr, F_(selBurnPow), F_(percent), json);
|
||||
print_value_json(shell, F("curBurnPow"), nullptr, F_(curBurnPow), F_(percent), json);
|
||||
print_value_json(shell, F("pumpMod"), nullptr, F_(pumpMod), F_(percent), json);
|
||||
print_value_json(shell, F("pumpMod2"), nullptr, F_(pumpMod2), F_(percent), json);
|
||||
print_value_json(shell, F("outdoorTemp"), nullptr, F_(outdoorTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("curFlowTemp"), nullptr, F_(curFlowTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("retTemp"), nullptr, F_(retTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("switchTemp"), nullptr, F_(switchTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("sysPress"), nullptr, F_(sysPress), nullptr, json);
|
||||
print_value_json(shell, F("boilTemp"), nullptr, F_(boilTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("exhaustTemp"), nullptr, F_(exhaustTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("burnGas"), nullptr, F_(burnGas), nullptr, json);
|
||||
print_value_json(shell, F("flameCurr"), nullptr, F_(flameCurr), F_(uA), json);
|
||||
print_value_json(shell, F("heatPump"), nullptr, F_(heatPump), nullptr, json);
|
||||
print_value_json(shell, F("fanWork"), nullptr, F_(fanWork), nullptr, json);
|
||||
print_value_json(shell, F("ignWork"), nullptr, F_(ignWork), nullptr, json);
|
||||
print_value_json(shell, F("heatingActivated"), nullptr, F_(heatingActivated), nullptr, json);
|
||||
print_value_json(shell, F("heatingTemp"), nullptr, F_(heatingTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("pumpModMax"), nullptr, F_(pumpModMax), F_(percent), json);
|
||||
print_value_json(shell, F("pumpModMin"), nullptr, F_(pumpModMin), F_(percent), json);
|
||||
print_value_json(shell, F("pumpDelay"), nullptr, F_(pumpDelay), F_(min), json);
|
||||
print_value_json(shell, F("burnMinPeriod"), nullptr, F_(burnMinPeriod), F_(min), json);
|
||||
print_value_json(shell, F("burnMinPower"), nullptr, F_(burnMinPower), F_(percent), json);
|
||||
print_value_json(shell, F("burnMaxPower"), nullptr, F_(burnMaxPower), F_(percent), json);
|
||||
print_value_json(shell, F("boilHystOn"), nullptr, F_(boilHystOn), F_(degrees), json);
|
||||
print_value_json(shell, F("boilHystOff"), nullptr, F_(boilHystOff), F_(degrees), json);
|
||||
print_value_json(shell, F("setFlowTemp"), nullptr, F_(setFlowTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("setBurnPow"), nullptr, F_(setBurnPow), F_(percent), json);
|
||||
print_value_json(shell, F("burnStarts"), nullptr, F_(burnStarts), nullptr, json);
|
||||
|
||||
if (Helpers::hasValue(burnWorkMin_)) {
|
||||
shell.printfln(F(" Total burner operating time: %d days %d hours %d minutes"), burnWorkMin_ / 1440, (burnWorkMin_ % 1440) / 60, burnWorkMin_ % 60);
|
||||
}
|
||||
if (Helpers::hasValue(heatWorkMin_)) {
|
||||
shell.printfln(F(" Total heat operating time: %d days %d hours %d minutes"), heatWorkMin_ / 1440, (heatWorkMin_ % 1440) / 60, heatWorkMin_ % 60);
|
||||
}
|
||||
if (Helpers::hasValue(UBAuptime_)) {
|
||||
shell.printfln(F(" Total UBA working time: %d days %d hours %d minutes"), UBAuptime_ / 1440, (UBAuptime_ % 1440) / 60, UBAuptime_ % 60);
|
||||
}
|
||||
|
||||
doc.clear();
|
||||
if (!export_values_ww(json)) { // append ww values
|
||||
shell.println();
|
||||
return;
|
||||
}
|
||||
|
||||
// ww
|
||||
print_value_json(shell, F("wWSelTemp"), nullptr, F_(wWSelTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("wWSetTemp"), nullptr, F_(wWSetTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("wWDisinfectionTemp"), nullptr, F_(wWDisinfectionTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("wWType"), nullptr, F_(wWType), nullptr, json);
|
||||
print_value_json(shell, F("wWChargeType"), nullptr, F_(wWChargeType), nullptr, json);
|
||||
print_value_json(shell, F("wWCircPump"), nullptr, F_(wWCircPump), nullptr, json);
|
||||
print_value_json(shell, F("wWCircPumpMode"), nullptr, F_(wWCircPumpMode), nullptr, json);
|
||||
print_value_json(shell, F("wWCirc"), nullptr, F_(wWCirc), nullptr, json);
|
||||
print_value_json(shell, F("wWCurTemp"), nullptr, F_(wWCurTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("wWCurTemp2"), nullptr, F_(wWCurTemp2), F_(degrees), json);
|
||||
print_value_json(shell, F("wWCurFlow"), nullptr, F_(wWCurFlow), F("l/min"), json);
|
||||
print_value_json(shell, F("wwStorageTemp1"), nullptr, F_(wwStorageTemp1), F_(degrees), json);
|
||||
print_value_json(shell, F("wwStorageTemp2"), nullptr, F_(wwStorageTemp2), F_(degrees), json);
|
||||
print_value_json(shell, F("wWActivated"), nullptr, F_(wWActivated), nullptr, json);
|
||||
print_value_json(shell, F("wWOneTime"), nullptr, F_(wWOneTime), nullptr, json);
|
||||
print_value_json(shell, F("wWDisinfecting"), nullptr, F_(wWDisinfecting), nullptr, json);
|
||||
print_value_json(shell, F("wWCharging"), nullptr, F_(wWCharging), nullptr, json);
|
||||
print_value_json(shell, F("wWRecharging"), nullptr, F_(wWRecharging), nullptr, json);
|
||||
print_value_json(shell, F("wWTempOK"), nullptr, F_(wWTempOK), nullptr, json);
|
||||
print_value_json(shell, F("wWActive"), nullptr, F_(wWActive), nullptr, json);
|
||||
print_value_json(shell, F("wWHeat"), nullptr, F_(wWHeat), nullptr, json);
|
||||
print_value_json(shell, F("wWSetPumpPower"), nullptr, F_(wWSetPumpPower), F_(percent), json);
|
||||
print_value_json(shell, F("wwMixTemperature"), nullptr, F_(wwMixTemperature), F_(degrees), json);
|
||||
print_value_json(shell, F("wwBufferTemperature"), nullptr, F_(wwBufferTemperature), F_(degrees), json);
|
||||
print_value_json(shell, F("wWStarts"), nullptr, F_(wWStarts), nullptr, json);
|
||||
|
||||
if (Helpers::hasValue(wWWorkM_)) {
|
||||
shell.printfln(F(" Warm Water active time: %d days %d hours %d minutes"), wWWorkM_ / 1440, (wWWorkM_ % 1440) / 60, wWWorkM_ % 60);
|
||||
}
|
||||
|
||||
shell.println();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if hot tap water or heating is active
|
||||
* If a value has changed, post it immediately to MQTT so we get real time data
|
||||
|
||||
@@ -38,7 +38,6 @@ class Boiler : public EMSdevice {
|
||||
public:
|
||||
Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -31,11 +31,6 @@ Connect::Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, con
|
||||
void Connect::device_info_web(JsonArray & root) {
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Connect::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Connect::publish_values(JsonObject & json, bool force) {
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ class Connect : public EMSdevice {
|
||||
public:
|
||||
Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -31,11 +31,6 @@ Controller::Controller(uint8_t device_type, uint8_t device_id, uint8_t product_i
|
||||
void Controller::device_info_web(JsonArray & root) {
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Controller::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Controller::publish_values(JsonObject & json, bool force) {
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ class Controller : public EMSdevice {
|
||||
public:
|
||||
Controller(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -31,11 +31,6 @@ Gateway::Gateway(uint8_t device_type, uint8_t device_id, uint8_t product_id, con
|
||||
void Gateway::device_info_web(JsonArray & root) {
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Gateway::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Gateway::publish_values(JsonObject & json, bool force) {
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ class Gateway : public EMSdevice {
|
||||
public:
|
||||
Gateway(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -31,11 +31,6 @@ Generic::Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, con
|
||||
void Generic::device_info_web(JsonArray & root) {
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Generic::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Generic::publish_values(JsonObject & json, bool force) {
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ class Generic : public EMSdevice {
|
||||
public:
|
||||
Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -55,23 +55,8 @@ void Heatpump::device_info_web(JsonArray & root) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
print_value_json(root, F("airHumidity"), nullptr, F_(airHumidity), F_(percent), json);
|
||||
print_value_json(root, F("dewTemperature"), nullptr, F_(dewTemperature), F_(degrees), json);
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Heatpump::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
|
||||
// fetch the values into a JSON document
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||
JsonObject json = doc.to<JsonObject>();
|
||||
if (!export_values(json)) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
print_value_json(shell, F("airHumidity"), nullptr, F_(airHumidity), F_(percent), json);
|
||||
print_value_json(shell, F("dewTemperature"), nullptr, F_(dewTemperature), F_(degrees), json);
|
||||
create_value_json(root, F("airHumidity"), nullptr, F_(airHumidity), F_(percent), json);
|
||||
create_value_json(root, F("dewTemperature"), nullptr, F_(dewTemperature), F_(degrees), json);
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
@@ -106,10 +91,10 @@ void Heatpump::register_mqtt_ha_config() {
|
||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/heatpump_data"), System::hostname().c_str());
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
doc["val_tpl"] = F("{{value_json.airHumidity}}");
|
||||
doc["val_tpl"] = FJSON("{{value_json.airHumidity}}");
|
||||
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = F("EMS-ESP Heat Pump");
|
||||
dev["name"] = FJSON("EMS-ESP Heat Pump");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = this->name();
|
||||
|
||||
@@ -36,7 +36,6 @@ class Heatpump : public EMSdevice {
|
||||
public:
|
||||
Heatpump(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -72,15 +72,15 @@ void Mixer::device_info_web(JsonArray & root) {
|
||||
char prefix_str[10];
|
||||
if (type() == Type::HC) {
|
||||
snprintf_P(prefix_str, sizeof(prefix_str), PSTR("(hc %d) "), hc_);
|
||||
print_value_json(root, F("flowTemp"), FPSTR(prefix_str), F_(flowTemp), F_(degrees), json);
|
||||
print_value_json(root, F("flowSetTemp"), FPSTR(prefix_str), F_(flowSetTemp), F_(degrees), json);
|
||||
print_value_json(root, F("pumpStatus"), FPSTR(prefix_str), F_(pumpStatus), nullptr, json);
|
||||
print_value_json(root, F("valveStatus"), FPSTR(prefix_str), F_(valveStatus), F_(percent), json);
|
||||
create_value_json(root, F("flowTemp"), FPSTR(prefix_str), F_(flowTemp), F_(degrees), json);
|
||||
create_value_json(root, F("flowSetTemp"), FPSTR(prefix_str), F_(flowSetTemp), F_(degrees), json);
|
||||
create_value_json(root, F("pumpStatus"), FPSTR(prefix_str), F_(pumpStatus), nullptr, json);
|
||||
create_value_json(root, F("valveStatus"), FPSTR(prefix_str), F_(valveStatus), F_(percent), json);
|
||||
} else {
|
||||
snprintf_P(prefix_str, sizeof(prefix_str), PSTR("(wwc %d) "), hc_);
|
||||
print_value_json(root, F("wwTemp"), FPSTR(prefix_str), F_(wwTemp), F_(degrees), json);
|
||||
print_value_json(root, F("pumpStatus"), FPSTR(prefix_str), F_(pumpStatus), nullptr, json);
|
||||
print_value_json(root, F("tempStatus"), FPSTR(prefix_str), F_(tempStatus), nullptr, json);
|
||||
create_value_json(root, F("wwTemp"), FPSTR(prefix_str), F_(wwTemp), F_(degrees), json);
|
||||
create_value_json(root, F("pumpStatus"), FPSTR(prefix_str), F_(pumpStatus), nullptr, json);
|
||||
create_value_json(root, F("tempStatus"), FPSTR(prefix_str), F_(tempStatus), nullptr, json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,38 +93,6 @@ bool Mixer::updated_values() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Mixer::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
|
||||
if (type() == Type::NONE) {
|
||||
return; // don't have any values yet
|
||||
}
|
||||
|
||||
// fetch the values into a JSON document
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||
JsonObject json = doc.to<JsonObject>();
|
||||
|
||||
if (!export_values_format(Mqtt::Format::SINGLE, json)) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
if (type() == Type::HC) {
|
||||
shell.printfln(F_(hc), hc_);
|
||||
print_value_json(shell, F("flowTemp"), F_(2spaces), F_(flowTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("flowSetTemp"), F_(2spaces), F_(flowSetTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("pumpStatus"), F_(2spaces), F_(pumpStatus), nullptr, json);
|
||||
print_value_json(shell, F("valveStatus"), F_(2spaces), F_(valveStatus), F_(percent), json);
|
||||
} else {
|
||||
shell.printfln(F_(ww_hc), hc_);
|
||||
print_value_json(shell, F("wwTemp"), F_(2spaces), F_(wwTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("pumpStatus"), F_(2spaces), F_(pumpStatus), nullptr, json);
|
||||
print_value_json(shell, F("tempStatus"), F_(2spaces), F_(tempStatus), nullptr, json);
|
||||
}
|
||||
|
||||
shell.println();
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
// topic is mixer_data<id>
|
||||
void Mixer::publish_values(JsonObject & json, bool force) {
|
||||
@@ -176,16 +144,16 @@ void Mixer::register_mqtt_ha_config() {
|
||||
snprintf_P(uniq_id, sizeof(uniq_id), PSTR("mixer%02X"), device_id() - 0x20 + 1);
|
||||
doc["uniq_id"] = uniq_id;
|
||||
|
||||
doc["ic"] = F("mdi:home-thermometer-outline");
|
||||
doc["ic"] = FJSON("mdi:home-thermometer-outline");
|
||||
|
||||
char stat_t[50];
|
||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/mixer_data"), System::hostname().c_str());
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
doc["val_tpl"] = F("{{value_json.type}}"); // HA needs a single value. We take the type which is wwc or hc
|
||||
doc["val_tpl"] = FJSON("{{value_json.type}}"); // HA needs a single value. We take the type which is wwc or hc
|
||||
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = F("EMS-ESP Mixer");
|
||||
dev["name"] = FJSON("EMS-ESP Mixer");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = this->name();
|
||||
@@ -235,10 +203,10 @@ bool Mixer::export_values_format(uint8_t mqtt_format, JsonObject & json) {
|
||||
snprintf_P(hc_name, sizeof(hc_name), PSTR("hc%d"), hc_);
|
||||
if (mqtt_format == Mqtt::Format::SINGLE) {
|
||||
json_hc = json;
|
||||
json["type"] = F("hc");
|
||||
json["type"] = FJSON("hc");
|
||||
} else if (mqtt_format == Mqtt::Format::HA) {
|
||||
json_hc = json.createNestedObject(hc_name);
|
||||
json_hc["type"] = F("hc");
|
||||
json_hc["type"] = FJSON("hc");
|
||||
} else {
|
||||
json_hc = json.createNestedObject(hc_name);
|
||||
}
|
||||
@@ -263,10 +231,10 @@ bool Mixer::export_values_format(uint8_t mqtt_format, JsonObject & json) {
|
||||
snprintf_P(hc_name, sizeof(hc_name), PSTR("wwc%d"), hc_);
|
||||
if (mqtt_format == Mqtt::Format::SINGLE) {
|
||||
json_hc = json;
|
||||
json["type"] = F("wwc");
|
||||
json["type"] = FJSON("wwc");
|
||||
} else if (mqtt_format == Mqtt::Format::HA) {
|
||||
json_hc = json.createNestedObject(hc_name);
|
||||
json_hc["type"] = F("wwc");
|
||||
json_hc["type"] = FJSON("wwc");
|
||||
} else {
|
||||
json_hc = json.createNestedObject(hc_name);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ class Mixer : public EMSdevice {
|
||||
public:
|
||||
Mixer(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -70,65 +70,22 @@ void Solar::device_info_web(JsonArray & root) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
print_value_json(root, F("collectorTemp"), nullptr, F_(collectorTemp), F_(degrees), json);
|
||||
print_value_json(root, F("tankBottomTemp"), nullptr, F_(tankBottomTemp), F_(degrees), json);
|
||||
print_value_json(root, F("tankBottomTemp2"), nullptr, F_(tankBottomTemp2), F_(degrees), json);
|
||||
print_value_json(root, F("tank1MaxTempCurrent"), nullptr, F_(tank1MaxTempCurrent), F_(degrees), json);
|
||||
print_value_json(root, F("heatExchangerTemp"), nullptr, F_(heatExchangerTemp), F_(degrees), json);
|
||||
print_value_json(root, F("solarPumpModulation"), nullptr, F_(solarPumpModulation), F_(percent), json);
|
||||
print_value_json(root, F("cylinderPumpModulation"), nullptr, F_(cylinderPumpModulation), F_(percent), json);
|
||||
print_value_json(root, F("valveStatus"), nullptr, F_(valveStatus), nullptr, json);
|
||||
print_value_json(root, F("solarPump"), nullptr, F_(solarPump), nullptr, json);
|
||||
print_value_json(root, F("tankHeated"), nullptr, F_(tankHeated), nullptr, json);
|
||||
print_value_json(root, F("collectorShutdown"), nullptr, F_(collectorShutdown), nullptr, json);
|
||||
print_value_json(root, F("energyLastHour"), nullptr, F_(energyLastHour), F_(wh), json);
|
||||
print_value_json(root, F("energyToday"), nullptr, F_(energyToday), F_(wh), json);
|
||||
print_value_json(root, F("energyTotal"), nullptr, F_(energyTotal), F_(kwh), json);
|
||||
print_value_json(root, F("pumpWorkMin"), nullptr, F_(pumpWorkMin), F_(min), json);
|
||||
|
||||
if (Helpers::hasValue(pumpWorkMin_)) {
|
||||
JsonObject dataElement = root.createNestedObject();
|
||||
dataElement["n"] = F_(pumpWorkMin);
|
||||
char time_str[60];
|
||||
snprintf_P(time_str, sizeof(time_str), PSTR("%d days %d hours %d minutes"), pumpWorkMin_ / 1440, (pumpWorkMin_ % 1440) / 60, pumpWorkMin_ % 60);
|
||||
dataElement["v"] = time_str;
|
||||
}
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Solar::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
|
||||
// fetch the values into a JSON document
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
JsonObject json = doc.to<JsonObject>();
|
||||
if (!export_values(json)) {
|
||||
return; // empty
|
||||
}
|
||||
|
||||
print_value_json(shell, F("collectorTemp"), nullptr, F_(collectorTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("tankBottomTemp"), nullptr, F_(tankBottomTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("tankBottomTemp2"), nullptr, F_(tankBottomTemp2), F_(degrees), json);
|
||||
print_value_json(shell, F("tank1MaxTempCurrent"), nullptr, F_(tank1MaxTempCurrent), F_(degrees), json);
|
||||
print_value_json(shell, F("heatExchangerTemp"), nullptr, F_(heatExchangerTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("solarPumpModulation"), nullptr, F_(solarPumpModulation), F_(percent), json);
|
||||
print_value_json(shell, F("cylinderPumpModulation"), nullptr, F_(cylinderPumpModulation), F_(percent), json);
|
||||
print_value_json(shell, F("valveStatus"), nullptr, F_(valveStatus), nullptr, json);
|
||||
print_value_json(shell, F("solarPump"), nullptr, F_(solarPump), nullptr, json);
|
||||
print_value_json(shell, F("tankHeated"), nullptr, F_(tankHeated), nullptr, json);
|
||||
print_value_json(shell, F("collectorShutdown"), nullptr, F_(collectorShutdown), nullptr, json);
|
||||
print_value_json(shell, F("energyLastHour"), nullptr, F_(energyLastHour), F_(wh), json);
|
||||
print_value_json(shell, F("energyToday"), nullptr, F_(energyToday), F_(wh), json);
|
||||
print_value_json(shell, F("energyTotal"), nullptr, F_(energyTotal), F_(kwh), json);
|
||||
print_value_json(shell, F("pumpWorkMin"), nullptr, F_(pumpWorkMin), F_(min), json);
|
||||
|
||||
if (Helpers::hasValue(pumpWorkMin_)) {
|
||||
shell.printfln(F(" %s: %d days %d hours %d minutes"),
|
||||
uuid::read_flash_string(F_(pumpWorkMin)).c_str(),
|
||||
pumpWorkMin_ / 1440,
|
||||
(pumpWorkMin_ % 1440) / 60,
|
||||
pumpWorkMin_ % 60);
|
||||
}
|
||||
create_value_json(root, F("collectorTemp"), nullptr, F_(collectorTemp), F_(degrees), json);
|
||||
create_value_json(root, F("tankBottomTemp"), nullptr, F_(tankBottomTemp), F_(degrees), json);
|
||||
create_value_json(root, F("tankBottomTemp2"), nullptr, F_(tankBottomTemp2), F_(degrees), json);
|
||||
create_value_json(root, F("tank1MaxTempCurrent"), nullptr, F_(tank1MaxTempCurrent), F_(degrees), json);
|
||||
create_value_json(root, F("heatExchangerTemp"), nullptr, F_(heatExchangerTemp), F_(degrees), json);
|
||||
create_value_json(root, F("solarPumpModulation"), nullptr, F_(solarPumpModulation), F_(percent), json);
|
||||
create_value_json(root, F("cylinderPumpModulation"), nullptr, F_(cylinderPumpModulation), F_(percent), json);
|
||||
create_value_json(root, F("valveStatus"), nullptr, F_(valveStatus), nullptr, json);
|
||||
create_value_json(root, F("solarPump"), nullptr, F_(solarPump), nullptr, json);
|
||||
create_value_json(root, F("tankHeated"), nullptr, F_(tankHeated), nullptr, json);
|
||||
create_value_json(root, F("collectorShutdown"), nullptr, F_(collectorShutdown), nullptr, json);
|
||||
create_value_json(root, F("energyLastHour"), nullptr, F_(energyLastHour), F_(wh), json);
|
||||
create_value_json(root, F("energyToday"), nullptr, F_(energyToday), F_(wh), json);
|
||||
create_value_json(root, F("energyTotal"), nullptr, F_(energyTotal), F_(kwh), json);
|
||||
create_value_json(root, F("pumpWorkMin"), nullptr, F_(pumpWorkMin), F_(min), json);
|
||||
create_value_json(root, F("pumpWorkMintxt"), nullptr, F_(pumpWorkMintxt), F_(min), json);
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
@@ -168,9 +125,9 @@ void Solar::register_mqtt_ha_config() {
|
||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/solar_data"), System::hostname().c_str());
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
doc["val_tpl"] = F("{{value_json.solarPump}}");
|
||||
doc["val_tpl"] = FJSON("{{value_json.solarPump}}");
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = F("EMS-ESP Solar");
|
||||
dev["name"] = FJSON("EMS-ESP Solar");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = name();
|
||||
@@ -240,6 +197,8 @@ bool Solar::export_values(JsonObject & json) {
|
||||
|
||||
if (Helpers::hasValue(pumpWorkMin_)) {
|
||||
json["pumpWorkMin"] = pumpWorkMin_;
|
||||
char slong[40];
|
||||
json["pumpWorkMintxt"] = Helpers::render_value(slong, pumpWorkMin_, EMS_VALUE_TIME);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(tankHeated_, EMS_VALUE_BOOL)) {
|
||||
|
||||
@@ -36,7 +36,6 @@ class Solar : public EMSdevice {
|
||||
public:
|
||||
Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -39,20 +39,9 @@ void Switch::device_info_web(JsonArray & root) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||
JsonObject json = doc.to<JsonObject>();
|
||||
if (export_values(json)) {
|
||||
print_value_json(root, F("activated"), nullptr, F_(activated), nullptr, json);
|
||||
print_value_json(root, F("flowTemp"), nullptr, F_(flowTemp), F_(degrees), json);
|
||||
print_value_json(root, F("status"), nullptr, F_(status), nullptr, json);
|
||||
}
|
||||
}
|
||||
|
||||
// display all values into the shell console
|
||||
void Switch::show_values(uuid::console::Shell & shell) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||
JsonObject json = doc.to<JsonObject>();
|
||||
if (export_values(json)) {
|
||||
print_value_json(shell, F("activated"), nullptr, F_(activated), nullptr, json);
|
||||
print_value_json(shell, F("flowTemp"), F_(2spaces), F_(flowTemp), F_(degrees), json);
|
||||
print_value_json(shell, F("status"), nullptr, F_(status), nullptr, json);
|
||||
create_value_json(root, F("activated"), nullptr, F_(activated), nullptr, json);
|
||||
create_value_json(root, F("flowTemp"), nullptr, F_(flowTemp), F_(degrees), json);
|
||||
create_value_json(root, F("status"), nullptr, F_(status), nullptr, json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,16 +110,16 @@ void Switch::register_mqtt_ha_config() {
|
||||
snprintf_P(uniq_id, sizeof(uniq_id), PSTR("switch"));
|
||||
doc["uniq_id"] = uniq_id;
|
||||
|
||||
doc["ic"] = F("mdi:home-thermometer-outline");
|
||||
doc["ic"] = FJSON("mdi:home-thermometer-outline");
|
||||
|
||||
char stat_t[50];
|
||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/switch_data"), System::hostname().c_str());
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
doc["val_tpl"] = F("{{value_json.type}}"); // HA needs a single value. We take the type which is wwc or hc
|
||||
doc["val_tpl"] = FJSON("{{value_json.type}}"); // HA needs a single value. We take the type which is wwc or hc
|
||||
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = F("EMS-ESP Switch");
|
||||
dev["name"] = FJSON("EMS-ESP Switch");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = this->name();
|
||||
|
||||
@@ -36,7 +36,6 @@ class Switch : public EMSdevice {
|
||||
public:
|
||||
Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
@@ -185,25 +185,25 @@ void Thermostat::device_info_web(JsonArray & root) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_LARGE> doc;
|
||||
JsonObject json_main = doc.to<JsonObject>();
|
||||
if (export_values_main(json_main)) {
|
||||
print_value_json(root, F("time"), nullptr, F_(time), nullptr, json_main);
|
||||
print_value_json(root, F("errorcode"), nullptr, F_(error), nullptr, json_main);
|
||||
print_value_json(root, F("lastcode"), nullptr, F_(lastCode), nullptr, json_main);
|
||||
print_value_json(root, F("display"), nullptr, F_(display), nullptr, json_main);
|
||||
print_value_json(root, F("language"), nullptr, F_(language), nullptr, json_main);
|
||||
print_value_json(root, F("offsetclock"), nullptr, F_(offsetclock), nullptr, json_main);
|
||||
print_value_json(root, F("dampedtemp"), nullptr, F_(dampedtemp), F_(degrees), json_main);
|
||||
print_value_json(root, F("inttemp1"), nullptr, F_(inttemp1), F_(degrees), json_main);
|
||||
print_value_json(root, F("inttemp2"), nullptr, F_(inttemp2), F_(degrees), json_main);
|
||||
print_value_json(root, F("intoffset"), nullptr, F_(intoffset), nullptr, json_main);
|
||||
print_value_json(root, F("minexttemp"), nullptr, F_(minexttemp), F_(degrees), json_main);
|
||||
print_value_json(root, F("building"), nullptr, F_(building), nullptr, json_main);
|
||||
print_value_json(root, F("floordry"), nullptr, F_(floordry), nullptr, json_main);
|
||||
print_value_json(root, F("floordrytemp"), nullptr, F_(floordrytemp), F_(degrees), json_main);
|
||||
print_value_json(root, F("wwmode"), nullptr, F_(wwmode), nullptr, json_main);
|
||||
print_value_json(root, F("wwtemp"), nullptr, F_(wwtemp), nullptr, json_main);
|
||||
print_value_json(root, F("wwtemplow"), nullptr, F_(wwtemplow), nullptr, json_main);
|
||||
print_value_json(root, F("wwextra1"), nullptr, F_(wwextra1), nullptr, json_main);
|
||||
print_value_json(root, F("wwcircmode"), nullptr, F_(wwcircmode), nullptr, json_main);
|
||||
create_value_json(root, F("time"), nullptr, F_(time), nullptr, json_main);
|
||||
create_value_json(root, F("errorcode"), nullptr, F_(error), nullptr, json_main);
|
||||
create_value_json(root, F("lastcode"), nullptr, F_(lastCode), nullptr, json_main);
|
||||
create_value_json(root, F("display"), nullptr, F_(display), nullptr, json_main);
|
||||
create_value_json(root, F("language"), nullptr, F_(language), nullptr, json_main);
|
||||
create_value_json(root, F("offsetclock"), nullptr, F_(offsetclock), nullptr, json_main);
|
||||
create_value_json(root, F("dampedtemp"), nullptr, F_(dampedtemp), F_(degrees), json_main);
|
||||
create_value_json(root, F("inttemp1"), nullptr, F_(inttemp1), F_(degrees), json_main);
|
||||
create_value_json(root, F("inttemp2"), nullptr, F_(inttemp2), F_(degrees), json_main);
|
||||
create_value_json(root, F("intoffset"), nullptr, F_(intoffset), nullptr, json_main);
|
||||
create_value_json(root, F("minexttemp"), nullptr, F_(minexttemp), F_(degrees), json_main);
|
||||
create_value_json(root, F("building"), nullptr, F_(building), nullptr, json_main);
|
||||
create_value_json(root, F("floordry"), nullptr, F_(floordry), nullptr, json_main);
|
||||
create_value_json(root, F("floordrytemp"), nullptr, F_(floordrytemp), F_(degrees), json_main);
|
||||
create_value_json(root, F("wwmode"), nullptr, F_(wwmode), nullptr, json_main);
|
||||
create_value_json(root, F("wwtemp"), nullptr, F_(wwtemp), nullptr, json_main);
|
||||
create_value_json(root, F("wwtemplow"), nullptr, F_(wwtemplow), nullptr, json_main);
|
||||
create_value_json(root, F("wwextra1"), nullptr, F_(wwextra1), nullptr, json_main);
|
||||
create_value_json(root, F("wwcircmode"), nullptr, F_(wwcircmode), nullptr, json_main);
|
||||
}
|
||||
doc.clear();
|
||||
JsonObject json_hc = doc.to<JsonObject>();
|
||||
@@ -218,28 +218,28 @@ void Thermostat::device_info_web(JsonArray & root) {
|
||||
|
||||
snprintf_P(prefix_str, sizeof(prefix_str), PSTR("(hc %d) "), hc->hc_num());
|
||||
|
||||
print_value_json(root, F("seltemp"), FPSTR(prefix_str), F_(seltemp), F_(degrees), json);
|
||||
print_value_json(root, F("currtemp"), FPSTR(prefix_str), F_(currtemp), F_(degrees), json);
|
||||
print_value_json(root, F("heattemp"), FPSTR(prefix_str), F_(heattemp), F_(degrees), json);
|
||||
print_value_json(root, F("comforttemp"), FPSTR(prefix_str), F_(comforttemp), F_(degrees), json);
|
||||
print_value_json(root, F("daytemp"), FPSTR(prefix_str), F_(daytemp), F_(degrees), json);
|
||||
print_value_json(root, F("ecotemp"), FPSTR(prefix_str), F_(ecotemp), F_(degrees), json);
|
||||
print_value_json(root, F("nighttemp"), FPSTR(prefix_str), F_(nighttemp), F_(degrees), json);
|
||||
print_value_json(root, F("manualtemp"), FPSTR(prefix_str), F_(manualtemp), F_(degrees), json);
|
||||
print_value_json(root, F("holidaytemp"), FPSTR(prefix_str), F_(holidaytemp), F_(degrees), json);
|
||||
print_value_json(root, F("nofrosttemp"), FPSTR(prefix_str), F_(nofrosttemp), F_(degrees), json);
|
||||
print_value_json(root, F("heatingtype"), FPSTR(prefix_str), F_(heatingtype), nullptr, json);
|
||||
print_value_json(root, F("targetflowtemp"), FPSTR(prefix_str), F_(targetflowtemp), F_(degrees), json);
|
||||
print_value_json(root, F("offsettemp"), FPSTR(prefix_str), F_(offsettemp), F_(degrees), json);
|
||||
print_value_json(root, F("designtemp"), FPSTR(prefix_str), F_(designtemp), F_(degrees), json);
|
||||
print_value_json(root, F("roominfluence"), FPSTR(prefix_str), F_(roominfluence), F_(degrees), json);
|
||||
print_value_json(root, F("flowtempoffset"), FPSTR(prefix_str), F_(flowtempoffset), F_(degrees), json);
|
||||
print_value_json(root, F("minflowtemp"), FPSTR(prefix_str), F_(minflowtemp), F_(degrees), json);
|
||||
print_value_json(root, F("maxflowtemp"), FPSTR(prefix_str), F_(maxflowtemp), F_(degrees), json);
|
||||
print_value_json(root, F("summertemp"), FPSTR(prefix_str), F_(summertemp), F_(degrees), json);
|
||||
print_value_json(root, F("summermode"), FPSTR(prefix_str), F_(summermode), F_(degrees), json);
|
||||
print_value_json(root, F("mode"), FPSTR(prefix_str), F_(mode), nullptr, json);
|
||||
print_value_json(root, F("modetype"), FPSTR(prefix_str), F_(modetype), nullptr, json);
|
||||
create_value_json(root, F("seltemp"), FPSTR(prefix_str), F_(seltemp), F_(degrees), json);
|
||||
create_value_json(root, F("currtemp"), FPSTR(prefix_str), F_(currtemp), F_(degrees), json);
|
||||
create_value_json(root, F("heattemp"), FPSTR(prefix_str), F_(heattemp), F_(degrees), json);
|
||||
create_value_json(root, F("comforttemp"), FPSTR(prefix_str), F_(comforttemp), F_(degrees), json);
|
||||
create_value_json(root, F("daytemp"), FPSTR(prefix_str), F_(daytemp), F_(degrees), json);
|
||||
create_value_json(root, F("ecotemp"), FPSTR(prefix_str), F_(ecotemp), F_(degrees), json);
|
||||
create_value_json(root, F("nighttemp"), FPSTR(prefix_str), F_(nighttemp), F_(degrees), json);
|
||||
create_value_json(root, F("manualtemp"), FPSTR(prefix_str), F_(manualtemp), F_(degrees), json);
|
||||
create_value_json(root, F("holidaytemp"), FPSTR(prefix_str), F_(holidaytemp), F_(degrees), json);
|
||||
create_value_json(root, F("nofrosttemp"), FPSTR(prefix_str), F_(nofrosttemp), F_(degrees), json);
|
||||
create_value_json(root, F("heatingtype"), FPSTR(prefix_str), F_(heatingtype), nullptr, json);
|
||||
create_value_json(root, F("targetflowtemp"), FPSTR(prefix_str), F_(targetflowtemp), F_(degrees), json);
|
||||
create_value_json(root, F("offsettemp"), FPSTR(prefix_str), F_(offsettemp), F_(degrees), json);
|
||||
create_value_json(root, F("designtemp"), FPSTR(prefix_str), F_(designtemp), F_(degrees), json);
|
||||
create_value_json(root, F("roominfluence"), FPSTR(prefix_str), F_(roominfluence), F_(degrees), json);
|
||||
create_value_json(root, F("flowtempoffset"), FPSTR(prefix_str), F_(flowtempoffset), F_(degrees), json);
|
||||
create_value_json(root, F("minflowtemp"), FPSTR(prefix_str), F_(minflowtemp), F_(degrees), json);
|
||||
create_value_json(root, F("maxflowtemp"), FPSTR(prefix_str), F_(maxflowtemp), F_(degrees), json);
|
||||
create_value_json(root, F("summertemp"), FPSTR(prefix_str), F_(summertemp), F_(degrees), json);
|
||||
create_value_json(root, F("summermode"), FPSTR(prefix_str), F_(summermode), F_(degrees), json);
|
||||
create_value_json(root, F("mode"), FPSTR(prefix_str), F_(mode), nullptr, json);
|
||||
create_value_json(root, F("modetype"), FPSTR(prefix_str), F_(modetype), nullptr, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,75 +265,6 @@ bool Thermostat::export_values(JsonObject & json) {
|
||||
return has_value;
|
||||
}
|
||||
|
||||
// display all thermostat values into the shell console
|
||||
void Thermostat::show_values(uuid::console::Shell & shell) {
|
||||
EMSdevice::show_values(shell); // always call this to show header
|
||||
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_LARGE> doc;
|
||||
JsonObject json_main = doc.to<JsonObject>();
|
||||
if (export_values_main(json_main)) {
|
||||
print_value_json(shell, F("time"), nullptr, F_(time), nullptr, json_main);
|
||||
print_value_json(shell, F("errorcode"), nullptr, F_(error), nullptr, json_main);
|
||||
print_value_json(shell, F("lastcode"), nullptr, F_(lastCode), nullptr, json_main);
|
||||
print_value_json(shell, F("display"), nullptr, F_(display), nullptr, json_main);
|
||||
print_value_json(shell, F("language"), nullptr, F_(language), nullptr, json_main);
|
||||
print_value_json(shell, F("offsetclock"), nullptr, F_(offsetclock), nullptr, json_main);
|
||||
print_value_json(shell, F("dampedtemp"), nullptr, F_(dampedtemp), F_(degrees), json_main);
|
||||
print_value_json(shell, F("inttemp1"), nullptr, F_(inttemp1), F_(degrees), json_main);
|
||||
print_value_json(shell, F("inttemp2"), nullptr, F_(inttemp2), F_(degrees), json_main);
|
||||
print_value_json(shell, F("intoffset"), nullptr, F_(intoffset), nullptr, json_main);
|
||||
print_value_json(shell, F("minexttemp"), nullptr, F_(minexttemp), F_(degrees), json_main);
|
||||
print_value_json(shell, F("building"), nullptr, F_(building), nullptr, json_main);
|
||||
print_value_json(shell, F("floordry"), nullptr, F_(floordry), nullptr, json_main);
|
||||
print_value_json(shell, F("floordrytemp"), nullptr, F_(floordrytemp), F_(degrees), json_main);
|
||||
print_value_json(shell, F("wwmode"), nullptr, F_(wwmode), nullptr, json_main);
|
||||
print_value_json(shell, F("wwtemp"), nullptr, F_(wwtemp), nullptr, json_main);
|
||||
print_value_json(shell, F("wwtemplow"), nullptr, F_(wwtemplow), nullptr, json_main);
|
||||
print_value_json(shell, F("wwextra1"), nullptr, F_(wwextra1), nullptr, json_main);
|
||||
print_value_json(shell, F("wwcircmode"), nullptr, F_(wwcircmode), nullptr, json_main);
|
||||
}
|
||||
|
||||
doc.clear(); // reuse the doc
|
||||
JsonObject json_hc = doc.to<JsonObject>();
|
||||
// e.g. {"hc1":{"seltemp":849.4,"currtemp":819.2,"mode":"unknown","modetype":"day"},"hc2":{"seltemp":875.1,"currtemp":409.6,"mode":"unknown","modetype":"day"},"hc3":{"seltemp":0,"currtemp":0,"mode":"unknown","modetype":"day"}}
|
||||
|
||||
if (export_values_hc(Mqtt::Format::NESTED, json_hc)) {
|
||||
// display for each active heating circuit
|
||||
for (const auto & hc : heating_circuits_) {
|
||||
if (hc->is_active()) {
|
||||
shell.printfln(F_(hc), hc->hc_num());
|
||||
|
||||
char hc_name[10]; // hc{1-4}
|
||||
snprintf_P(hc_name, sizeof(hc_name), PSTR("hc%d"), hc->hc_num());
|
||||
JsonObject json = json_hc[hc_name];
|
||||
|
||||
print_value_json(shell, F("seltemp"), F_(2spaces), F_(seltemp), F_(degrees), json);
|
||||
print_value_json(shell, F("currtemp"), F_(2spaces), F_(currtemp), F_(degrees), json);
|
||||
print_value_json(shell, F("heattemp"), F_(2spaces), F_(heattemp), F_(degrees), json);
|
||||
print_value_json(shell, F("comforttemp"), F_(2spaces), F_(comforttemp), F_(degrees), json);
|
||||
print_value_json(shell, F("daytemp"), F_(2spaces), F_(daytemp), F_(degrees), json);
|
||||
print_value_json(shell, F("ecotemp"), F_(2spaces), F_(ecotemp), F_(degrees), json);
|
||||
print_value_json(shell, F("nighttemp"), F_(2spaces), F_(nighttemp), F_(degrees), json);
|
||||
print_value_json(shell, F("manualtemp"), F_(2spaces), F_(manualtemp), F_(degrees), json);
|
||||
print_value_json(shell, F("holidaytemp"), F_(2spaces), F_(holidaytemp), F_(degrees), json);
|
||||
print_value_json(shell, F("nofrosttemp"), F_(2spaces), F_(nofrosttemp), F_(degrees), json);
|
||||
print_value_json(shell, F("targetflowtemp"), F_(2spaces), F_(targetflowtemp), F_(degrees), json);
|
||||
print_value_json(shell, F("offsettemp"), F_(2spaces), F_(offsettemp), F_(degrees), json);
|
||||
print_value_json(shell, F("designtemp"), F_(2spaces), F_(designtemp), F_(degrees), json);
|
||||
print_value_json(shell, F("roominfluence"), F_(2spaces), F_(roominfluence), F_(degrees), json);
|
||||
print_value_json(shell, F("flowtempoffset"), F_(2spaces), F_(flowtempoffset), F_(degrees), json);
|
||||
print_value_json(shell, F("minflowtemp"), F_(2spaces), F_(minflowtemp), F_(degrees), json);
|
||||
print_value_json(shell, F("maxflowtemp"), F_(2spaces), F_(maxflowtemp), F_(degrees), json);
|
||||
print_value_json(shell, F("summertemp"), F_(2spaces), F_(summertemp), F_(degrees), json);
|
||||
print_value_json(shell, F("summermode"), F_(2spaces), F_(summermode), F_(degrees), json);
|
||||
print_value_json(shell, F("mode"), F_(2spaces), F_(mode), nullptr, json);
|
||||
print_value_json(shell, F("modetype"), F_(2spaces), F_(modetype), nullptr, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
shell.println();
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Thermostat::publish_values(JsonObject & json, bool force) {
|
||||
if (EMSESP::actual_master_thermostat() != device_id()) {
|
||||
@@ -394,36 +325,36 @@ bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
||||
// Display
|
||||
if (Helpers::hasValue(ibaMainDisplay_)) {
|
||||
if (ibaMainDisplay_ == 0) {
|
||||
rootThermostat["display"] = F("internal temperature");
|
||||
rootThermostat["display"] = FJSON("internal temperature");
|
||||
} else if (ibaMainDisplay_ == 1) {
|
||||
rootThermostat["display"] = F("internal setpoint");
|
||||
rootThermostat["display"] = FJSON("internal setpoint");
|
||||
} else if (ibaMainDisplay_ == 2) {
|
||||
rootThermostat["display"] = F("external temperature");
|
||||
rootThermostat["display"] = FJSON("external temperature");
|
||||
} else if (ibaMainDisplay_ == 3) {
|
||||
rootThermostat["display"] = F("burner temperature");
|
||||
rootThermostat["display"] = FJSON("burner temperature");
|
||||
} else if (ibaMainDisplay_ == 4) {
|
||||
rootThermostat["display"] = F("WW temperature");
|
||||
rootThermostat["display"] = FJSON("WW temperature");
|
||||
} else if (ibaMainDisplay_ == 5) {
|
||||
rootThermostat["display"] = F("functioning mode");
|
||||
rootThermostat["display"] = FJSON("functioning mode");
|
||||
} else if (ibaMainDisplay_ == 6) {
|
||||
rootThermostat["display"] = F("time");
|
||||
rootThermostat["display"] = FJSON("time");
|
||||
} else if (ibaMainDisplay_ == 7) {
|
||||
rootThermostat["display"] = F("date");
|
||||
rootThermostat["display"] = FJSON("date");
|
||||
} else if (ibaMainDisplay_ == 8) {
|
||||
rootThermostat["display"] = F("smoke temperature");
|
||||
rootThermostat["display"] = FJSON("smoke temperature");
|
||||
}
|
||||
}
|
||||
|
||||
// Language
|
||||
if (Helpers::hasValue(ibaLanguage_)) {
|
||||
if (ibaLanguage_ == 0) {
|
||||
rootThermostat["language"] = F("German");
|
||||
rootThermostat["language"] = FJSON("German");
|
||||
} else if (ibaLanguage_ == 1) {
|
||||
rootThermostat["language"] = F("Dutch");
|
||||
rootThermostat["language"] = FJSON("Dutch");
|
||||
} else if (ibaLanguage_ == 2) {
|
||||
rootThermostat["language"] = F("French");
|
||||
rootThermostat["language"] = FJSON("French");
|
||||
} else if (ibaLanguage_ == 3) {
|
||||
rootThermostat["language"] = F("Italian");
|
||||
rootThermostat["language"] = FJSON("Italian");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,9 +618,9 @@ bool Thermostat::export_values_hc(uint8_t mqtt_format, JsonObject & rootThermost
|
||||
// https://github.com/proddy/EMS-ESP/issues/373#issuecomment-619810209
|
||||
// Mode Type
|
||||
if (Helpers::hasValue(hc->summer_mode) && hc->summer_mode) {
|
||||
dataThermostat["modetype"] = F("summer");
|
||||
dataThermostat["modetype"] = FJSON("summer");
|
||||
} else if (Helpers::hasValue(hc->holiday_mode) && hc->holiday_mode) {
|
||||
dataThermostat["modetype"] = F("holiday");
|
||||
dataThermostat["modetype"] = FJSON("holiday");
|
||||
} else if (Helpers::hasValue(hc->mode_type)) {
|
||||
dataThermostat["modetype"] = mode_tostring(hc->get_mode_type(model));
|
||||
}
|
||||
@@ -867,17 +798,17 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
|
||||
// homeassistant/sensor/ems-esp/thermostat/config
|
||||
void Thermostat::register_mqtt_ha_config() {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_HA_CONFIG> doc;
|
||||
doc["uniq_id"] = F("thermostat");
|
||||
doc["ic"] = F("mdi:home-thermometer-outline");
|
||||
doc["uniq_id"] = FJSON("thermostat");
|
||||
doc["ic"] = FJSON("mdi:home-thermometer-outline");
|
||||
|
||||
char stat_t[50];
|
||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/thermostat_data"), System::hostname().c_str());
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
doc["name"] = F("Thermostat Status");
|
||||
doc["val_tpl"] = F("{{value_json.errorcode}}"); // default value - must have one, so we use errorcode
|
||||
doc["name"] = FJSON("Thermostat Status");
|
||||
doc["val_tpl"] = FJSON("{{value_json.errorcode}}"); // default value - must have one, so we use errorcode
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = F("EMS-ESP Thermostat");
|
||||
dev["name"] = FJSON("EMS-ESP Thermostat");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = name();
|
||||
@@ -936,9 +867,9 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||
doc["mode_cmd_t"] = str3;
|
||||
doc["temp_cmd_t"] = str3;
|
||||
doc["~"] = System::hostname(); // ems-esp
|
||||
doc["mode_stat_t"] = "~/thermostat_data";
|
||||
doc["temp_stat_t"] = "~/thermostat_data";
|
||||
doc["curr_temp_t"] = "~/thermostat_data";
|
||||
doc["mode_stat_t"] = FJSON("~/thermostat_data");
|
||||
doc["temp_stat_t"] = FJSON("~/thermostat_data");
|
||||
doc["curr_temp_t"] = FJSON("~/thermostat_data");
|
||||
|
||||
char mode_str[30];
|
||||
snprintf_P(mode_str, sizeof(mode_str), PSTR("{{value_json.hc%d.mode}}"), hc_num);
|
||||
@@ -952,9 +883,9 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||
snprintf_P(currtemp_str, sizeof(currtemp_str), PSTR("{{value_json.hc%d.currtemp}}"), hc_num);
|
||||
doc["curr_temp_tpl"] = currtemp_str;
|
||||
|
||||
doc["min_temp"] = "5";
|
||||
doc["max_temp"] = "30";
|
||||
doc["temp_step"] = "0.5";
|
||||
doc["min_temp"] = FJSON("5");
|
||||
doc["max_temp"] = FJSON("30");
|
||||
doc["temp_step"] = FJSON("0.5");
|
||||
|
||||
// the HA climate component only responds to auto, heat and off
|
||||
JsonArray modes = doc.createNestedArray("modes");
|
||||
@@ -963,7 +894,7 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||
modes.add("off");
|
||||
|
||||
JsonObject dev = doc.createNestedObject("dev");
|
||||
dev["name"] = "EMS-ESP Thermostat";
|
||||
dev["name"] = FJSON("EMS-ESP Thermostat");
|
||||
dev["sw"] = EMSESP_APP_VERSION;
|
||||
dev["mf"] = brand_to_string();
|
||||
dev["mdl"] = name();
|
||||
|
||||
@@ -121,7 +121,6 @@ class Thermostat : public EMSdevice {
|
||||
|
||||
static std::string mode_tostring(uint8_t mode);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values(JsonObject & json, bool force);
|
||||
virtual bool export_values(JsonObject & json);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
|
||||
Reference in New Issue
Block a user