mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
Merge pull request #535 from MichaelDvP/dev
small changes, suggestion for thermostat_data
This commit is contained in:
@@ -359,7 +359,7 @@ void EMSESPShell::add_console_commands() {
|
||||
ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(call)},
|
||||
flash_string_vector{F_(device_type_optional), F_(cmd_optional), F_(data_optional), F_(n_optional)},
|
||||
flash_string_vector{F_(device_type_optional), F_(cmd_optional), F_(data_optional), F_(id_optional)},
|
||||
[&](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.empty()) {
|
||||
Command::show_all(shell); // list options
|
||||
|
||||
@@ -242,7 +242,10 @@ bool Thermostat::updated_values() {
|
||||
// info API command
|
||||
// returns the same MQTT publish payload in Nested format
|
||||
bool Thermostat::command_info(const char * value, const int8_t id, JsonObject & output) {
|
||||
return (export_values_hc(Mqtt::Format::NESTED, output));
|
||||
bool has_value = false;
|
||||
has_value |= export_values_main(output);
|
||||
has_value |= export_values_hc(Mqtt::Format::NESTED, output);
|
||||
return has_value;
|
||||
}
|
||||
|
||||
// display all thermostat values into the shell console
|
||||
@@ -252,6 +255,7 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc_main;
|
||||
JsonObject output_main = doc_main.to<JsonObject>();
|
||||
if (export_values_main(output_main)) {
|
||||
print_value_json(shell, F("time"), F_(time), nullptr, output_main);
|
||||
print_value_json(shell, F("display"), F_(display), nullptr, output_main);
|
||||
print_value_json(shell, F("language"), F_(language), nullptr, output_main);
|
||||
print_value_json(shell, F("offsetclock"), F_(offsetclock), nullptr, output_main);
|
||||
@@ -295,13 +299,13 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
||||
print_value_json(shell, F("offsettemp"), F_(offsettemp), F_(degrees), output);
|
||||
print_value_json(shell, F("designtemp"), F_(designtemp), F_(degrees), output);
|
||||
print_value_json(shell, F("summertemp"), F_(summertemp), F_(degrees), output);
|
||||
print_value_json(shell, F("summermode"), F_(summermode), F_(degrees), output);
|
||||
print_value_json(shell, F("mode"), F_(mode), nullptr, output);
|
||||
print_value_json(shell, F("modetype"), F_(modetype), nullptr, output);
|
||||
|
||||
shell.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
shell.println();
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
@@ -309,7 +313,21 @@ void Thermostat::publish_values() {
|
||||
if (EMSESP::actual_master_thermostat() != this->device_id()) {
|
||||
return;
|
||||
}
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
JsonObject output = doc.to<JsonObject>();
|
||||
bool has_data = false;
|
||||
|
||||
has_data |= export_values_main(output);
|
||||
if (Mqtt::mqtt_format() == Mqtt::Format::SINGLE && has_data) {
|
||||
Mqtt::publish(F("thermostat_data"), output);
|
||||
output.clear();
|
||||
}
|
||||
has_data |= export_values_hc(Mqtt::mqtt_format(), output);
|
||||
// if we're in SINGLE mode the MQTT would have been published on the export_values() function for each hc
|
||||
if (Mqtt::mqtt_format() != Mqtt::Format::SINGLE && has_data) {
|
||||
Mqtt::publish(F("thermostat_data"), output);
|
||||
}
|
||||
/*
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc_main;
|
||||
JsonObject output_main = doc_main.to<JsonObject>();
|
||||
if (export_values_main(output_main)) {
|
||||
@@ -324,53 +342,58 @@ void Thermostat::publish_values() {
|
||||
Mqtt::publish(F("thermostat_data"), output_hc);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
||||
uint8_t model = this->model();
|
||||
|
||||
// Clock time
|
||||
if (datetime_.size()) {
|
||||
rootThermostat["time"] = datetime_.c_str();
|
||||
}
|
||||
|
||||
// Display
|
||||
if (Helpers::hasValue(ibaMainDisplay_)) {
|
||||
if (ibaMainDisplay_ == 0) {
|
||||
rootThermostat["display"] = F("internal temperature");
|
||||
} else if (ibaMainDisplay_ == 1) {
|
||||
rootThermostat["display"] = F("internal setpoint");
|
||||
} else if (ibaMainDisplay_ == 2) {
|
||||
rootThermostat["display"] = F("external temperature");
|
||||
} else if (ibaMainDisplay_ == 3) {
|
||||
rootThermostat["display"] = F("burner temperature");
|
||||
} else if (ibaMainDisplay_ == 4) {
|
||||
rootThermostat["display"] = F("WW temperature");
|
||||
} else if (ibaMainDisplay_ == 5) {
|
||||
rootThermostat["display"] = F("functioning mode");
|
||||
} else if (ibaMainDisplay_ == 6) {
|
||||
rootThermostat["display"] = F("time");
|
||||
} else if (ibaMainDisplay_ == 7) {
|
||||
rootThermostat["display"] = F("date");
|
||||
} else if (ibaMainDisplay_ == 8) {
|
||||
rootThermostat["display"] = F("smoke temperature");
|
||||
if (model == EMSdevice::EMS_DEVICE_FLAG_RC30_1) {
|
||||
// Display
|
||||
if (Helpers::hasValue(ibaMainDisplay_)) {
|
||||
if (ibaMainDisplay_ == 0) {
|
||||
rootThermostat["display"] = F("internal temperature");
|
||||
} else if (ibaMainDisplay_ == 1) {
|
||||
rootThermostat["display"] = F("internal setpoint");
|
||||
} else if (ibaMainDisplay_ == 2) {
|
||||
rootThermostat["display"] = F("external temperature");
|
||||
} else if (ibaMainDisplay_ == 3) {
|
||||
rootThermostat["display"] = F("burner temperature");
|
||||
} else if (ibaMainDisplay_ == 4) {
|
||||
rootThermostat["display"] = F("WW temperature");
|
||||
} else if (ibaMainDisplay_ == 5) {
|
||||
rootThermostat["display"] = F("functioning mode");
|
||||
} else if (ibaMainDisplay_ == 6) {
|
||||
rootThermostat["display"] = F("time");
|
||||
} else if (ibaMainDisplay_ == 7) {
|
||||
rootThermostat["display"] = F("date");
|
||||
} else if (ibaMainDisplay_ == 8) {
|
||||
rootThermostat["display"] = F("smoke temperature");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Language
|
||||
if (Helpers::hasValue(ibaLanguage_)) {
|
||||
if (ibaLanguage_ == 0) {
|
||||
rootThermostat["language"] = F("German");
|
||||
} else if (ibaLanguage_ == 1) {
|
||||
rootThermostat["language"] = F("Dutch");
|
||||
} else if (ibaLanguage_ == 2) {
|
||||
rootThermostat["language"] = F("French");
|
||||
} else if (ibaLanguage_ == 3) {
|
||||
rootThermostat["language"] = F("Italian");
|
||||
// Language
|
||||
if (Helpers::hasValue(ibaLanguage_)) {
|
||||
if (ibaLanguage_ == 0) {
|
||||
rootThermostat["language"] = F("German");
|
||||
} else if (ibaLanguage_ == 1) {
|
||||
rootThermostat["language"] = F("Dutch");
|
||||
} else if (ibaLanguage_ == 2) {
|
||||
rootThermostat["language"] = F("French");
|
||||
} else if (ibaLanguage_ == 3) {
|
||||
rootThermostat["language"] = F("Italian");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Offset clock
|
||||
if (Helpers::hasValue(ibaClockOffset_)) {
|
||||
rootThermostat["offsetclock"] = ibaClockOffset_; // offset (in sec) to clock, 0xff=-1s, 0x02=2s
|
||||
// Offset clock
|
||||
if (Helpers::hasValue(ibaClockOffset_)) {
|
||||
rootThermostat["offsetclock"] = ibaClockOffset_; // offset (in sec) to clock, 0xff=-1s, 0x02=2s
|
||||
}
|
||||
}
|
||||
|
||||
// Damped outdoor temperature
|
||||
@@ -406,8 +429,7 @@ bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
||||
|
||||
// Warm water mode
|
||||
if (Helpers::hasValue(wwMode_)) {
|
||||
uint8_t model = this->model();
|
||||
char s[10];
|
||||
char s[10];
|
||||
if (model == EMS_DEVICE_FLAG_RC300 || model == EMS_DEVICE_FLAG_RC100) {
|
||||
rootThermostat["wwmode"] = Helpers::render_enum(s, {"off", "low", "high", "auto", "own_prog"}, wwMode_);
|
||||
} else {
|
||||
@@ -779,6 +801,10 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(summertemp), this->device_type(), "summertemp", F_(degrees), F_(icontemperature));
|
||||
break;
|
||||
case EMS_DEVICE_FLAG_RC20_2:
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(daytemp), this->device_type(), "daytemp", F_(degrees), F_(icontemperature));
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(nighttemp), this->device_type(), "nighttemp", F_(degrees), F_(icontemperature));
|
||||
break;
|
||||
case EMS_DEVICE_FLAG_RC30_1:
|
||||
case EMS_DEVICE_FLAG_RC35:
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(modetype), this->device_type(), "modetype", nullptr, nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(nighttemp), this->device_type(), "nighttemp", F_(degrees), F_(icontemperature));
|
||||
|
||||
@@ -116,7 +116,7 @@ MAKE_PSTR(percent, "%")
|
||||
MAKE_PSTR(degrees, "°C")
|
||||
MAKE_PSTR(asterisks, "********")
|
||||
MAKE_PSTR(n_mandatory, "<n>")
|
||||
MAKE_PSTR(n_optional, "[n]")
|
||||
MAKE_PSTR(id_optional, "[id/hc]")
|
||||
MAKE_PSTR(data_optional, "[data]")
|
||||
MAKE_PSTR(typeid_mandatory, "<type ID>")
|
||||
MAKE_PSTR(deviceid_mandatory, "<device ID>")
|
||||
@@ -177,7 +177,7 @@ MAKE_PSTR(flameCurr, "Flame current")
|
||||
MAKE_PSTR(heatPump, "Boiler pump")
|
||||
MAKE_PSTR(fanWork, "Fan")
|
||||
MAKE_PSTR(ignWork, "Ignition")
|
||||
MAKE_PSTR(wWHeat, "Warm water charging")
|
||||
MAKE_PSTR(wWHeat, "Warm water heating")
|
||||
MAKE_PSTR(heatingActivated, "Heating activated")
|
||||
MAKE_PSTR(heatingTemp, "Heating temperature setting on the boiler")
|
||||
MAKE_PSTR(pumpModMax, "Boiler circuit pump modulation max power")
|
||||
@@ -223,6 +223,7 @@ MAKE_PSTR(flowTemp, "Current flow temperature")
|
||||
MAKE_PSTR(flowSetTemp, "Setpoint flow temperature")
|
||||
|
||||
// thermostat
|
||||
MAKE_PSTR(time, "Time")
|
||||
MAKE_PSTR(display, "Display")
|
||||
MAKE_PSTR(language, "Language")
|
||||
MAKE_PSTR(offsetclock, "Offset clock")
|
||||
@@ -250,5 +251,6 @@ MAKE_PSTR(targetflowtemp, "Target flow temperature")
|
||||
MAKE_PSTR(offsettemp, "Offset temperature")
|
||||
MAKE_PSTR(designtemp, "Design temperature")
|
||||
MAKE_PSTR(summertemp, "Summer temperature")
|
||||
MAKE_PSTR(summermode, "Summer mode")
|
||||
MAKE_PSTR(mode, "Mode")
|
||||
MAKE_PSTR(modetype, "Mode type")
|
||||
|
||||
Reference in New Issue
Block a user