mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
small changes, suggestion for thermostat_data
This commit is contained in:
@@ -359,7 +359,7 @@ void EMSESPShell::add_console_commands() {
|
|||||||
ShellContext::MAIN,
|
ShellContext::MAIN,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
flash_string_vector{F_(call)},
|
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) {
|
[&](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
if (arguments.empty()) {
|
if (arguments.empty()) {
|
||||||
Command::show_all(shell); // list options
|
Command::show_all(shell); // list options
|
||||||
|
|||||||
@@ -242,7 +242,10 @@ bool Thermostat::updated_values() {
|
|||||||
// info API command
|
// info API command
|
||||||
// returns the same MQTT publish payload in Nested format
|
// returns the same MQTT publish payload in Nested format
|
||||||
bool Thermostat::command_info(const char * value, const int8_t id, JsonObject & output) {
|
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
|
// 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;
|
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc_main;
|
||||||
JsonObject output_main = doc_main.to<JsonObject>();
|
JsonObject output_main = doc_main.to<JsonObject>();
|
||||||
if (export_values_main(output_main)) {
|
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("display"), F_(display), nullptr, output_main);
|
||||||
print_value_json(shell, F("language"), F_(language), 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);
|
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("offsettemp"), F_(offsettemp), F_(degrees), output);
|
||||||
print_value_json(shell, F("designtemp"), F_(designtemp), 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("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("mode"), F_(mode), nullptr, output);
|
||||||
print_value_json(shell, F("modetype"), F_(modetype), nullptr, output);
|
print_value_json(shell, F("modetype"), F_(modetype), nullptr, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
shell.println();
|
shell.println();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish values via MQTT
|
// publish values via MQTT
|
||||||
@@ -309,7 +313,21 @@ void Thermostat::publish_values() {
|
|||||||
if (EMSESP::actual_master_thermostat() != this->device_id()) {
|
if (EMSESP::actual_master_thermostat() != this->device_id()) {
|
||||||
return;
|
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;
|
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc_main;
|
||||||
JsonObject output_main = doc_main.to<JsonObject>();
|
JsonObject output_main = doc_main.to<JsonObject>();
|
||||||
if (export_values_main(output_main)) {
|
if (export_values_main(output_main)) {
|
||||||
@@ -324,14 +342,18 @@ void Thermostat::publish_values() {
|
|||||||
Mqtt::publish(F("thermostat_data"), output_hc);
|
Mqtt::publish(F("thermostat_data"), output_hc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
||||||
|
uint8_t model = this->model();
|
||||||
|
|
||||||
// Clock time
|
// Clock time
|
||||||
if (datetime_.size()) {
|
if (datetime_.size()) {
|
||||||
rootThermostat["time"] = datetime_.c_str();
|
rootThermostat["time"] = datetime_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model == EMSdevice::EMS_DEVICE_FLAG_RC30_1) {
|
||||||
// Display
|
// Display
|
||||||
if (Helpers::hasValue(ibaMainDisplay_)) {
|
if (Helpers::hasValue(ibaMainDisplay_)) {
|
||||||
if (ibaMainDisplay_ == 0) {
|
if (ibaMainDisplay_ == 0) {
|
||||||
@@ -372,6 +394,7 @@ bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
|||||||
if (Helpers::hasValue(ibaClockOffset_)) {
|
if (Helpers::hasValue(ibaClockOffset_)) {
|
||||||
rootThermostat["offsetclock"] = ibaClockOffset_; // offset (in sec) to clock, 0xff=-1s, 0x02=2s
|
rootThermostat["offsetclock"] = ibaClockOffset_; // offset (in sec) to clock, 0xff=-1s, 0x02=2s
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Damped outdoor temperature
|
// Damped outdoor temperature
|
||||||
if (Helpers::hasValue(dampedoutdoortemp_)) {
|
if (Helpers::hasValue(dampedoutdoortemp_)) {
|
||||||
@@ -406,7 +429,6 @@ bool Thermostat::export_values_main(JsonObject & rootThermostat) {
|
|||||||
|
|
||||||
// Warm water mode
|
// Warm water mode
|
||||||
if (Helpers::hasValue(wwMode_)) {
|
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) {
|
if (model == EMS_DEVICE_FLAG_RC300 || model == EMS_DEVICE_FLAG_RC100) {
|
||||||
rootThermostat["wwmode"] = Helpers::render_enum(s, {"off", "low", "high", "auto", "own_prog"}, wwMode_);
|
rootThermostat["wwmode"] = Helpers::render_enum(s, {"off", "low", "high", "auto", "own_prog"}, wwMode_);
|
||||||
@@ -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));
|
Mqtt::register_mqtt_ha_sensor(hc_name, F_(summertemp), this->device_type(), "summertemp", F_(degrees), F_(icontemperature));
|
||||||
break;
|
break;
|
||||||
case EMS_DEVICE_FLAG_RC20_2:
|
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:
|
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_(modetype), this->device_type(), "modetype", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(nighttemp), this->device_type(), "nighttemp", F_(degrees), F_(icontemperature));
|
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(degrees, "°C")
|
||||||
MAKE_PSTR(asterisks, "********")
|
MAKE_PSTR(asterisks, "********")
|
||||||
MAKE_PSTR(n_mandatory, "<n>")
|
MAKE_PSTR(n_mandatory, "<n>")
|
||||||
MAKE_PSTR(n_optional, "[n]")
|
MAKE_PSTR(id_optional, "[id/hc]")
|
||||||
MAKE_PSTR(data_optional, "[data]")
|
MAKE_PSTR(data_optional, "[data]")
|
||||||
MAKE_PSTR(typeid_mandatory, "<type ID>")
|
MAKE_PSTR(typeid_mandatory, "<type ID>")
|
||||||
MAKE_PSTR(deviceid_mandatory, "<device ID>")
|
MAKE_PSTR(deviceid_mandatory, "<device ID>")
|
||||||
@@ -177,7 +177,7 @@ MAKE_PSTR(flameCurr, "Flame current")
|
|||||||
MAKE_PSTR(heatPump, "Boiler pump")
|
MAKE_PSTR(heatPump, "Boiler pump")
|
||||||
MAKE_PSTR(fanWork, "Fan")
|
MAKE_PSTR(fanWork, "Fan")
|
||||||
MAKE_PSTR(ignWork, "Ignition")
|
MAKE_PSTR(ignWork, "Ignition")
|
||||||
MAKE_PSTR(wWHeat, "Warm water charging")
|
MAKE_PSTR(wWHeat, "Warm water heating")
|
||||||
MAKE_PSTR(heatingActivated, "Heating activated")
|
MAKE_PSTR(heatingActivated, "Heating activated")
|
||||||
MAKE_PSTR(heatingTemp, "Heating temperature setting on the boiler")
|
MAKE_PSTR(heatingTemp, "Heating temperature setting on the boiler")
|
||||||
MAKE_PSTR(pumpModMax, "Boiler circuit pump modulation max power")
|
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")
|
MAKE_PSTR(flowSetTemp, "Setpoint flow temperature")
|
||||||
|
|
||||||
// thermostat
|
// thermostat
|
||||||
|
MAKE_PSTR(time, "Time")
|
||||||
MAKE_PSTR(display, "Display")
|
MAKE_PSTR(display, "Display")
|
||||||
MAKE_PSTR(language, "Language")
|
MAKE_PSTR(language, "Language")
|
||||||
MAKE_PSTR(offsetclock, "Offset clock")
|
MAKE_PSTR(offsetclock, "Offset clock")
|
||||||
@@ -250,5 +251,6 @@ MAKE_PSTR(targetflowtemp, "Target flow temperature")
|
|||||||
MAKE_PSTR(offsettemp, "Offset temperature")
|
MAKE_PSTR(offsettemp, "Offset temperature")
|
||||||
MAKE_PSTR(designtemp, "Design temperature")
|
MAKE_PSTR(designtemp, "Design temperature")
|
||||||
MAKE_PSTR(summertemp, "Summer temperature")
|
MAKE_PSTR(summertemp, "Summer temperature")
|
||||||
|
MAKE_PSTR(summermode, "Summer mode")
|
||||||
MAKE_PSTR(mode, "Mode")
|
MAKE_PSTR(mode, "Mode")
|
||||||
MAKE_PSTR(modetype, "Mode type")
|
MAKE_PSTR(modetype, "Mode type")
|
||||||
|
|||||||
Reference in New Issue
Block a user