mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
nested publish for mixing, nofrosttemp, designtemp, roominfluence
This commit is contained in:
@@ -266,12 +266,17 @@ void EMSESPShell::add_console_commands() {
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(read)},
|
||||
flash_string_vector{F_(deviceid_mandatory), F_(typeid_mandatory)},
|
||||
flash_string_vector{F_(deviceid_mandatory), F_(typeid_mandatory), F_(offset_optional)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
uint8_t device_id = Helpers::hextoint(arguments.front().c_str());
|
||||
uint16_t type_id = Helpers::hextoint(arguments.back().c_str());
|
||||
uint16_t type_id = Helpers::hextoint(arguments[1].c_str());
|
||||
EMSESP::set_read_id(type_id);
|
||||
EMSESP::send_read_request(type_id, device_id);
|
||||
if (arguments.size() == 3) {
|
||||
uint16_t offset = Helpers::hextoint(arguments.back().c_str());
|
||||
EMSESP::send_read_request(type_id, device_id, offset);
|
||||
} else {
|
||||
EMSESP::send_read_request(type_id, device_id);
|
||||
}
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
|
||||
@@ -594,7 +594,7 @@ bool Boiler::export_values(JsonObject & output) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Boiler::publish_values() {
|
||||
void Boiler::publish_values(JsonObject & data) {
|
||||
// must make sure this doesn't exist 1000. Currently (2.1.0) its 950b.
|
||||
// otheerwise use DynamicJsonDocument with max size and use .shrinkToFit()
|
||||
StaticJsonDocument<1024> doc;
|
||||
|
||||
@@ -39,7 +39,7 @@ class Boiler : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void Connect::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Connect::publish_values() {
|
||||
void Connect::publish_values(JsonObject & data) {
|
||||
}
|
||||
|
||||
// check to see if values have been updated
|
||||
|
||||
@@ -36,7 +36,7 @@ class Connect : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void Controller::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Controller::publish_values() {
|
||||
void Controller::publish_values(JsonObject & data) {
|
||||
}
|
||||
|
||||
// check to see if values have been updated
|
||||
|
||||
@@ -36,7 +36,7 @@ class Controller : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void Gateway::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Gateway::publish_values() {
|
||||
void Gateway::publish_values(JsonObject & data) {
|
||||
}
|
||||
|
||||
// check to see if values have been updated
|
||||
|
||||
@@ -36,7 +36,7 @@ class Gateway : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ void Heatpump::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Heatpump::publish_values() {
|
||||
void Heatpump::publish_values(JsonObject & data) {
|
||||
}
|
||||
|
||||
// check to see if values have been updated
|
||||
|
||||
@@ -36,7 +36,7 @@ class Heatpump : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -138,20 +138,24 @@ bool Mixing::command_info(const char * value, const int8_t id, JsonObject & outp
|
||||
|
||||
// publish values via MQTT
|
||||
// topic is mixing_data<id>
|
||||
void Mixing::publish_values() {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||
JsonObject output = doc.to<JsonObject>();
|
||||
if (export_values(Mqtt::mqtt_format(), output)) {
|
||||
char topic[30];
|
||||
char s[5];
|
||||
strlcpy(topic, "mixing_data", 30);
|
||||
strlcat(topic, Helpers::itoa(s, device_id() - 0x20 + 1), 30); // append device_id to topic
|
||||
Mqtt::publish(topic, doc.as<JsonObject>());
|
||||
|
||||
// if we're using Home Assistant and haven't created the MQTT Discovery topics, do it now
|
||||
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) {
|
||||
register_mqtt_ha_config(topic);
|
||||
mqtt_ha_config_ = true;
|
||||
void Mixing::publish_values(JsonObject & data) {
|
||||
if (Mqtt::mqtt_format() == Mqtt::Format::SINGLE) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||
JsonObject output = doc.to<JsonObject>();
|
||||
if (export_values(Mqtt::mqtt_format(), output)) {
|
||||
char topic[30];
|
||||
char s[5];
|
||||
strlcpy(topic, "mixing_data", 30);
|
||||
strlcat(topic, Helpers::itoa(s, device_id() - 0x20 + 1), 30); // append device_id to topic
|
||||
Mqtt::publish(topic, doc.as<JsonObject>());
|
||||
}
|
||||
} else {
|
||||
if (export_values(Mqtt::mqtt_format(), data)) {
|
||||
// if we're using Home Assistant and haven't created the MQTT Discovery topics, do it now
|
||||
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) {
|
||||
register_mqtt_ha_config("mixing_data");
|
||||
mqtt_ha_config_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,15 +183,23 @@ void Mixing::register_mqtt_ha_config(const char * topic) {
|
||||
Mqtt::publish_retain(F("homeassistant/sensor/ems-esp/mixing/config"), doc.as<JsonObject>(), true); // publish the config payload with retain flag
|
||||
|
||||
if (this->type() == Type::HC) {
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(flowTemp), this->device_type(), "flowTemp", F_(degrees), nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(flowSetTemp), this->device_type(), "flowSetTemp", F_(degrees), nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpStatus), this->device_type(), "pumpStatus", nullptr, nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(valveStatus), this->device_type(), "valveStatus", nullptr, nullptr);
|
||||
char hc_name[10];
|
||||
char s[5];
|
||||
strlcpy(hc_name, "hc", 10);
|
||||
strlcat(hc_name, Helpers::itoa(s, device_id() - 0x20 + 1), 10); // append device_id to topic
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(flowTemp), this->device_type(), "flowTemp", F_(degrees), F_(icontemperature));
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(flowSetTemp), this->device_type(), "flowSetTemp", F_(degrees), F_(icontemperature));
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(pumpStatus), this->device_type(), "pumpStatus", nullptr, nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(valveStatus), this->device_type(), "valveStatus", nullptr, nullptr);
|
||||
} else {
|
||||
// WWC
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wwTemp), this->device_type(), "wwTemp", F_(degrees), nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpStatus), this->device_type(), "pumpStatus", nullptr, nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(tempStatus), this->device_type(), "tempStatus", nullptr, nullptr);
|
||||
char wwc_name[10];
|
||||
char s[5];
|
||||
strlcpy(wwc_name, "wwc", 10);
|
||||
strlcat(wwc_name, Helpers::itoa(s, device_id() - 0x20 + 1), 10); // append device_id to topic
|
||||
Mqtt::register_mqtt_ha_sensor(wwc_name, F_(wwTemp), this->device_type(), "wwTemp", F_(degrees), F_(icontemperature));
|
||||
Mqtt::register_mqtt_ha_sensor(wwc_name, F_(pumpStatus), this->device_type(), "pumpStatus", nullptr, nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(wwc_name, F_(tempStatus), this->device_type(), "tempStatus", nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +211,7 @@ bool Mixing::export_values(uint8_t mqtt_format, JsonObject & output) {
|
||||
|
||||
if (this->type() == Type::HC) {
|
||||
snprintf_P(hc_name, sizeof(hc_name), PSTR("hc%d"), hc_);
|
||||
if (mqtt_format == Mqtt::Format::NESTED) {
|
||||
if (mqtt_format == Mqtt::Format::NESTED || mqtt_format == Mqtt::Format::HA) {
|
||||
output_hc = output.createNestedObject(hc_name);
|
||||
} else {
|
||||
output_hc = output;
|
||||
|
||||
@@ -37,7 +37,7 @@ class Mixing : public EMSdevice {
|
||||
Mixing(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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ void Solar::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Solar::publish_values() {
|
||||
void Solar::publish_values(JsonObject & data) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
JsonObject output = doc.to<JsonObject>();
|
||||
if (export_values(output)) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class Solar : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void Switch::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Switch::publish_values() {
|
||||
void Switch::publish_values(JsonObject & data) {
|
||||
}
|
||||
|
||||
// check to see if values have been updated
|
||||
|
||||
@@ -36,7 +36,7 @@ class Switch : public EMSdevice {
|
||||
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();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ void Thermostat::device_info_web(JsonArray & root) {
|
||||
print_value_json(root, F("targetflowtemp"), FPSTR(prefix_str), F_(targetflowtemp), F_(degrees), output);
|
||||
print_value_json(root, F("offsettemp"), FPSTR(prefix_str), F_(offsettemp), F_(degrees), output);
|
||||
print_value_json(root, F("designtemp"), FPSTR(prefix_str), F_(designtemp), F_(degrees), output);
|
||||
print_value_json(root, F("roominfluence"), FPSTR(prefix_str), F_(roominfluence), F_(degrees), output);
|
||||
print_value_json(root, F("summertemp"), FPSTR(prefix_str), F_(summertemp), F_(degrees), output);
|
||||
print_value_json(root, F("summermode"), FPSTR(prefix_str), F_(summermode), F_(degrees), output);
|
||||
print_value_json(root, F("mode"), FPSTR(prefix_str), F_(mode), nullptr, output);
|
||||
@@ -297,6 +298,7 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
||||
print_value_json(shell, F("targetflowtemp"), F(" "), F_(targetflowtemp), F_(degrees), output);
|
||||
print_value_json(shell, F("offsettemp"), F(" "), F_(offsettemp), F_(degrees), output);
|
||||
print_value_json(shell, F("designtemp"), F(" "), F_(designtemp), F_(degrees), output);
|
||||
print_value_json(shell, F("roominfluence"), F(" "), F_(roominfluence), F_(degrees), output);
|
||||
print_value_json(shell, F("summertemp"), F(" "), F_(summertemp), F_(degrees), output);
|
||||
print_value_json(shell, F("summermode"), F(" "), F_(summermode), F_(degrees), output);
|
||||
print_value_json(shell, F("mode"), F(" "), F_(mode), nullptr, output);
|
||||
@@ -308,7 +310,7 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// publish values via MQTT
|
||||
void Thermostat::publish_values() {
|
||||
void Thermostat::publish_values(JsonObject & data) {
|
||||
if (EMSESP::actual_master_thermostat() != this->device_id()) {
|
||||
return;
|
||||
}
|
||||
@@ -527,7 +529,11 @@ bool Thermostat::export_values_hc(uint8_t mqtt_format, JsonObject & rootThermost
|
||||
|
||||
// Nofrost temperature
|
||||
if (Helpers::hasValue(hc->nofrosttemp)) {
|
||||
dataThermostat["nofrosttemp"] = (float)hc->nofrosttemp / 2;
|
||||
if (flags == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
|
||||
dataThermostat["nofrosttemp"] = (float)hc->nofrosttemp / 2;
|
||||
} else {
|
||||
dataThermostat["nofrosttemp"] = hc->nofrosttemp;
|
||||
}
|
||||
}
|
||||
|
||||
// Heating Type
|
||||
@@ -550,6 +556,11 @@ bool Thermostat::export_values_hc(uint8_t mqtt_format, JsonObject & rootThermost
|
||||
dataThermostat["designtemp"] = hc->designtemp;
|
||||
}
|
||||
|
||||
// Room influence
|
||||
if (Helpers::hasValue(hc->roominfluence)) {
|
||||
dataThermostat["roominfluence"] = hc->roominfluence;
|
||||
}
|
||||
|
||||
// Summer temperature
|
||||
if (Helpers::hasValue(hc->summertemp)) {
|
||||
dataThermostat["summertemp"] = hc->summertemp;
|
||||
@@ -716,19 +727,19 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||
|
||||
char str1[40];
|
||||
snprintf_P(str1, sizeof(str1), PSTR("Thermostat hc%d"), hc_num);
|
||||
doc["name"] = str1;
|
||||
|
||||
char str2[40];
|
||||
snprintf_P(str2, sizeof(str2), PSTR("thermostat_hc%d"), hc_num);
|
||||
doc["uniq_id"] = str2;
|
||||
|
||||
doc["~"] = System::hostname(); // ems-esp
|
||||
|
||||
char str3[40];
|
||||
snprintf_P(str3, sizeof(str3), PSTR("~/%s"), str2);
|
||||
doc["mode_cmd_t"] = str3;
|
||||
doc["temp_cmd_t"] = str3;
|
||||
|
||||
doc["mode_cmd_t"] = str3;
|
||||
doc["temp_cmd_t"] = str3;
|
||||
doc["name"] = str1;
|
||||
doc["uniq_id"] = str2;
|
||||
doc["mode_cmd_t"] = str3;
|
||||
doc["temp_cmd_t"] = str3;
|
||||
doc["~"] = System::hostname(); // ems-esp
|
||||
doc["mode_stat_t"] = F("~/thermostat_data");
|
||||
doc["temp_stat_t"] = F("~/thermostat_data");
|
||||
doc["curr_temp_t"] = F("~/thermostat_data");
|
||||
@@ -825,6 +836,7 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(targetflowtemp), this->device_type(), "targetflowtemp", F_(degrees), F_(icontemperature));
|
||||
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_(nofrosttemp), this->device_type(), "nofrosttemp", F_(degrees), F_(icontemperature));
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(roominfluence), this->device_type(), "roominfluence", F_(degrees), F_(icontemperature));
|
||||
break;
|
||||
case EMS_DEVICE_FLAG_JUNKERS:
|
||||
Mqtt::register_mqtt_ha_sensor(hc_name, F_(modetype), this->device_type(), "modetype", nullptr, nullptr);
|
||||
@@ -1230,8 +1242,13 @@ void Thermostat::process_RC35Set(std::shared_ptr<const Telegram> telegram) {
|
||||
|
||||
changed_ |= telegram->read_value(hc->summertemp, 22); // is * 1
|
||||
changed_ |= telegram->read_value(hc->nofrosttemp, 23); // is * 1
|
||||
changed_ |= telegram->read_value(hc->designtemp, 17); // is * 1
|
||||
if (hc->heatingtype == 3) {
|
||||
changed_ |= telegram->read_value(hc->designtemp, 36); // is * 1
|
||||
} else {
|
||||
changed_ |= telegram->read_value(hc->designtemp, 17); // is * 1
|
||||
}
|
||||
changed_ |= telegram->read_value(hc->offsettemp, 6); // is * 2
|
||||
changed_ |= telegram->read_value(hc->roominfluence, 4); // is * 1
|
||||
}
|
||||
|
||||
// process_RCTime - type 0x06 - date and time from a thermostat - 14 bytes long
|
||||
@@ -1395,6 +1412,24 @@ bool Thermostat::set_control(const char * value, const int8_t id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set roominfluence
|
||||
bool Thermostat::set_roominfluence(const char * value, const int8_t id) {
|
||||
uint8_t hc_num = (id == -1) ? AUTO_HEATING_CIRCUIT : id;
|
||||
std::shared_ptr<Thermostat::HeatingCircuit> hc = heating_circuit(hc_num);
|
||||
if (hc == nullptr) {
|
||||
LOG_WARNING(F("Set roominfluence: Heating Circuit %d not found or activated"), hc_num);
|
||||
return false;
|
||||
}
|
||||
int t = 0;
|
||||
if (!Helpers::value2number(value, t)) {
|
||||
LOG_WARNING(F("Set roominfluence: Invalid value"));
|
||||
return false;
|
||||
}
|
||||
LOG_INFO(F("Setting roominfluence to %d"), t);
|
||||
write_command(set_typeids[hc->hc_num() - 1], 4, t, set_typeids[hc->hc_num() - 1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// sets the thermostat ww working mode, where mode is a string, ems and ems+
|
||||
bool Thermostat::set_wwmode(const char * value, const int8_t id) {
|
||||
uint8_t set = 0xFF;
|
||||
@@ -1861,7 +1896,11 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_RC35Set_temp_offset;
|
||||
break;
|
||||
case HeatingCircuit::Mode::DESIGN:
|
||||
offset = EMS_OFFSET_RC35Set_temp_design;
|
||||
if (hc->heatingtype == 3) {
|
||||
offset = EMS_OFFSET_RC35Set_temp_design_floor;
|
||||
} else {
|
||||
offset = EMS_OFFSET_RC35Set_temp_design;
|
||||
}
|
||||
factor = 1;
|
||||
break;
|
||||
case HeatingCircuit::Mode::SUMMER:
|
||||
@@ -2083,6 +2122,7 @@ void Thermostat::add_commands() {
|
||||
register_mqtt_cmd(F("holidaytemp"), [&](const char * value, const int8_t id) { return set_holidaytemp(value, id); });
|
||||
register_mqtt_cmd(F("wwmode"), [&](const char * value, const int8_t id) { return set_wwmode(value, id); });
|
||||
register_mqtt_cmd(F("wwcircmode"), [&](const char * value, const int8_t id) { return set_wwcircmode(value, id); });
|
||||
register_mqtt_cmd(F("roominfluence"), [&](const char * value, const int8_t id) { return set_roominfluence(value, id); });
|
||||
break;
|
||||
case EMS_DEVICE_FLAG_JUNKERS:
|
||||
register_mqtt_cmd(F("nofrosttemp"), [&](const char * value, const int8_t id) { return set_nofrosttemp(value, id); });
|
||||
|
||||
@@ -63,6 +63,7 @@ class Thermostat : public EMSdevice {
|
||||
int8_t offsettemp = EMS_VALUE_INT_NOTSET; // heating curve offest temp at roomtemp signed!
|
||||
uint8_t manualtemp = EMS_VALUE_UINT_NOTSET;
|
||||
uint8_t summer_setmode = EMS_VALUE_UINT_NOTSET;
|
||||
uint8_t roominfluence = EMS_VALUE_UINT_NOTSET;
|
||||
|
||||
uint8_t hc_num() const {
|
||||
return hc_num_;
|
||||
@@ -99,7 +100,7 @@ class Thermostat : public EMSdevice {
|
||||
static std::string mode_tostring(uint8_t mode);
|
||||
|
||||
virtual void show_values(uuid::console::Shell & shell);
|
||||
virtual void publish_values();
|
||||
virtual void publish_values(JsonObject & data);
|
||||
virtual void device_info_web(JsonArray & root);
|
||||
virtual bool updated_values();
|
||||
|
||||
@@ -183,6 +184,7 @@ class Thermostat : public EMSdevice {
|
||||
static constexpr uint8_t EMS_OFFSET_RC35Set_seltemp = 37; // selected temp
|
||||
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_offset = 6;
|
||||
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_design = 17;
|
||||
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_design_floor = 36;
|
||||
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_summer = 22;
|
||||
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_nofrost = 23;
|
||||
|
||||
@@ -283,6 +285,7 @@ class Thermostat : public EMSdevice {
|
||||
bool set_holidaytemp(const char * value, const int8_t id);
|
||||
bool set_manualtemp(const char * value, const int8_t id);
|
||||
bool set_remotetemp(const char * value, const int8_t id);
|
||||
bool set_roominfluence(const char * value, const int8_t id);
|
||||
|
||||
// set functions - these don't use the id/hc, the parameters are ignored
|
||||
bool set_wwmode(const char * value, const int8_t id);
|
||||
|
||||
@@ -140,7 +140,7 @@ class EMSdevice {
|
||||
|
||||
// virtual functions overrules by derived classes
|
||||
virtual void show_values(uuid::console::Shell & shell) = 0;
|
||||
virtual void publish_values() = 0;
|
||||
virtual void publish_values(JsonObject & data) = 0;
|
||||
virtual bool updated_values() = 0;
|
||||
virtual void device_info_web(JsonArray & root) = 0;
|
||||
|
||||
|
||||
@@ -299,9 +299,21 @@ void EMSESP::publish_all() {
|
||||
}
|
||||
|
||||
void EMSESP::publish_device_values(uint8_t device_type) {
|
||||
if (device_type == EMSdevice::DeviceType::MIXING && Mqtt::mqtt_format() != Mqtt::Format::SINGLE) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
JsonObject output = doc.to<JsonObject>();
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
||||
emsdevice->publish_values(output);
|
||||
}
|
||||
}
|
||||
Mqtt::publish("mixing_data", doc.as<JsonObject>());
|
||||
return;
|
||||
}
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
||||
emsdevice->publish_values();
|
||||
JsonObject dummy;
|
||||
emsdevice->publish_values(dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +322,8 @@ void EMSESP::publish_other_values() {
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::BOILER) && (emsdevice->device_type() != EMSdevice::DeviceType::THERMOSTAT)
|
||||
&& (emsdevice->device_type() != EMSdevice::DeviceType::SOLAR) && (emsdevice->device_type() != EMSdevice::DeviceType::MIXING)) {
|
||||
emsdevice->publish_values();
|
||||
JsonObject dummy;
|
||||
emsdevice->publish_values(dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,7 +569,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
if (telegram->type_id == publish_id_) {
|
||||
publish_id_ = 0;
|
||||
}
|
||||
emsdevice->publish_values(); // publish to MQTT if we explicitly have too
|
||||
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -695,6 +708,11 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
|
||||
return true;
|
||||
}
|
||||
|
||||
// send a read request, passing it into to the Tx Service, with offset
|
||||
void EMSESP::send_read_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset) {
|
||||
txservice_.read_request(type_id, dest, offset);
|
||||
}
|
||||
|
||||
// send a read request, passing it into to the Tx Service, with no offset
|
||||
void EMSESP::send_read_request(const uint16_t type_id, const uint8_t dest) {
|
||||
txservice_.read_request(type_id, dest, 0); // 0 = no offset
|
||||
|
||||
@@ -77,6 +77,7 @@ class EMSESP {
|
||||
static std::string pretty_telegram(std::shared_ptr<const Telegram> telegram);
|
||||
|
||||
static void send_read_request(const uint16_t type_id, const uint8_t dest);
|
||||
static void send_read_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset);
|
||||
static void send_write_request(const uint16_t type_id,
|
||||
const uint8_t dest,
|
||||
const uint8_t offset,
|
||||
|
||||
@@ -117,6 +117,7 @@ MAKE_PSTR(asterisks, "********")
|
||||
MAKE_PSTR(n_mandatory, "<n>")
|
||||
MAKE_PSTR(id_optional, "[id|hc]")
|
||||
MAKE_PSTR(data_optional, "[data]")
|
||||
MAKE_PSTR(offset_optional, "[offset]")
|
||||
MAKE_PSTR(typeid_mandatory, "<type ID>")
|
||||
MAKE_PSTR(deviceid_mandatory, "<device ID>")
|
||||
MAKE_PSTR(device_type_optional, "[device]")
|
||||
@@ -253,5 +254,6 @@ MAKE_PSTR(offsettemp, "Offset temperature")
|
||||
MAKE_PSTR(designtemp, "Design temperature")
|
||||
MAKE_PSTR(summertemp, "Summer temperature")
|
||||
MAKE_PSTR(summermode, "Summer mode")
|
||||
MAKE_PSTR(roominfluence, "Room influence")
|
||||
MAKE_PSTR(mode, "Mode")
|
||||
MAKE_PSTR(modetype, "Mode type")
|
||||
|
||||
Reference in New Issue
Block a user