mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fix for non-nested thermostat #738
This commit is contained in:
@@ -2042,43 +2042,48 @@ void Thermostat::register_device_values() {
|
|||||||
uint8_t model = this->model();
|
uint8_t model = this->model();
|
||||||
|
|
||||||
// Common for all thermostats
|
// Common for all thermostats
|
||||||
register_device_value(TAG_NONE, &id_, DeviceValueType::UINT, nullptr, F("id"), nullptr); // empty full name to prevent being shown in web or console
|
register_device_value(TAG_THERMOSTAT_DATA, &id_, DeviceValueType::UINT, nullptr, F("id"), nullptr); // empty full name to prevent being shown in web or console
|
||||||
register_device_value(TAG_NONE, &dateTime_, DeviceValueType::TEXT, nullptr, F("dateTime"), F("date/time"));
|
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::TEXT, nullptr, F("dateTime"), F("date/time"));
|
||||||
register_device_value(TAG_NONE, &errorCode_, DeviceValueType::TEXT, nullptr, F("errorCode"), F("error code"));
|
register_device_value(TAG_THERMOSTAT_DATA, &errorCode_, DeviceValueType::TEXT, nullptr, F("errorCode"), F("error code"));
|
||||||
register_device_value(TAG_NONE, &lastCode_, DeviceValueType::TEXT, nullptr, F("lastCode"), F("last error"));
|
register_device_value(TAG_THERMOSTAT_DATA, &lastCode_, DeviceValueType::TEXT, nullptr, F("lastCode"), F("last error"));
|
||||||
|
|
||||||
// RC30 only
|
// RC30 only
|
||||||
if (model == EMSdevice::EMS_DEVICE_FLAG_RC30_1) {
|
if (model == EMSdevice::EMS_DEVICE_FLAG_RC30_1) {
|
||||||
register_device_value(TAG_NONE, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), F("display"), F("display"));
|
register_device_value(TAG_THERMOSTAT_DATA, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), F("display"), F("display"));
|
||||||
register_device_value(TAG_NONE, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), F("language"), F("language"));
|
register_device_value(TAG_THERMOSTAT_DATA, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), F("language"), F("language"));
|
||||||
register_device_value(TAG_NONE, &ibaClockOffset_, DeviceValueType::UINT, nullptr, F("offsetclock"), F("clock offset")); // offset (in sec) to clock, 0xff=-1s, 0x02=2s
|
register_device_value(TAG_THERMOSTAT_DATA, &ibaClockOffset_, DeviceValueType::UINT, nullptr, F("offsetclock"), F("clock offset")); // offset (in sec) to clock, 0xff=-1s, 0x02=2s
|
||||||
}
|
}
|
||||||
|
|
||||||
// RC300 and RC100
|
// RC300 and RC100
|
||||||
if (model == EMS_DEVICE_FLAG_RC300 || model == EMS_DEVICE_FLAG_RC100) {
|
if (model == EMS_DEVICE_FLAG_RC300 || model == EMS_DEVICE_FLAG_RC100) {
|
||||||
register_device_value(TAG_NONE, &floordrystatus_, DeviceValueType::ENUM, FL_(enum_floordrystatus), F("floordry"), F("floor drying"));
|
register_device_value(TAG_THERMOSTAT_DATA, &floordrystatus_, DeviceValueType::ENUM, FL_(enum_floordrystatus), F("floordry"), F("floor drying"));
|
||||||
register_device_value(TAG_NONE, &dampedoutdoortemp2_, DeviceValueType::SHORT, FL_(div10), F("dampedoutdoortemp"), F("damped outdoor temperature"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &dampedoutdoortemp2_, DeviceValueType::SHORT, FL_(div10), F("dampedoutdoortemp"), F("damped outdoor temperature"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &floordrytemp_, DeviceValueType::UINT, nullptr, F("floordrytemp"), F("floor drying temperature"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &floordrytemp_, DeviceValueType::UINT, nullptr, F("floordrytemp"), F("floor drying temperature"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &ibaBuildingType_, DeviceValueType::ENUM, FL_(enum_ibaBuildingType), F("building"), F("building"));
|
register_device_value(TAG_THERMOSTAT_DATA, &ibaBuildingType_, DeviceValueType::ENUM, FL_(enum_ibaBuildingType), F("building"), F("building"));
|
||||||
register_device_value(TAG_NONE, &wwSetTemp_, DeviceValueType::UINT, nullptr, F("wwsettemp"), F("warm water set temperature"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &wwSetTemp_, DeviceValueType::UINT, nullptr, F("wwsettemp"), F("warm water set temperature"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode), F("wwmode"), F("warm water mode"));
|
register_device_value(TAG_THERMOSTAT_DATA, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode), F("wwmode"), F("warm water mode"));
|
||||||
register_device_value(TAG_NONE, &wwSetTempLow_, DeviceValueType::UINT, nullptr, F("wwsettemplow"), F("warm water set temperature low"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &wwSetTempLow_, DeviceValueType::UINT, nullptr, F("wwsettemplow"), F("warm water set temperature low"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode), F("wwcircmode"), F("warm water circulation mode"));
|
register_device_value(TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode), F("wwcircmode"), F("warm water circulation mode"));
|
||||||
register_device_value(TAG_NONE, &wwExtra1_, DeviceValueType::UINT, nullptr, F("wwextra1"), F("warm water circuit 1 extra"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &wwExtra1_, DeviceValueType::UINT, nullptr, F("wwextra1"), F("warm water circuit 1 extra"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &wwExtra2_, DeviceValueType::UINT, nullptr, F("wwextra2"), F("warm water circuit 2 extra"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &wwExtra2_, DeviceValueType::UINT, nullptr, F("wwextra2"), F("warm water circuit 2 extra"), DeviceValueUOM::DEGREES);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RC30 and RC35
|
// RC30 and RC35
|
||||||
if (model == EMS_DEVICE_FLAG_RC35 || model == EMS_DEVICE_FLAG_RC30_1) {
|
if (model == EMS_DEVICE_FLAG_RC35 || model == EMS_DEVICE_FLAG_RC30_1) {
|
||||||
register_device_value(TAG_NONE, &ibaCalIntTemperature_, DeviceValueType::INT, FL_(div2), F("intoffset"), F("offset internal temperature"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &ibaCalIntTemperature_, DeviceValueType::INT, FL_(div2), F("intoffset"), F("offset internal temperature"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &ibaMinExtTemperature_, DeviceValueType::INT, nullptr, F("minexttemp"), F("min external temperature"),
|
register_device_value(TAG_THERMOSTAT_DATA,
|
||||||
|
&ibaMinExtTemperature_,
|
||||||
|
DeviceValueType::INT,
|
||||||
|
nullptr,
|
||||||
|
F("minexttemp"),
|
||||||
|
F("min external temperature"),
|
||||||
DeviceValueUOM::DEGREES); // min ext temp for heating curve, in deg.
|
DeviceValueUOM::DEGREES); // min ext temp for heating curve, in deg.
|
||||||
register_device_value(TAG_NONE, &tempsensor1_, DeviceValueType::USHORT, FL_(div10), F("inttemp1"), F("temperature sensor 1"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &tempsensor1_, DeviceValueType::USHORT, FL_(div10), F("inttemp1"), F("temperature sensor 1"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &tempsensor2_, DeviceValueType::USHORT, FL_(div10), F("inttemp2"), F("temperature sensor 2"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &tempsensor2_, DeviceValueType::USHORT, FL_(div10), F("inttemp2"), F("temperature sensor 2"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &dampedoutdoortemp_, DeviceValueType::INT, nullptr, F("dampedtemp"), F("damped outdoor temperature"), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_THERMOSTAT_DATA, &dampedoutdoortemp_, DeviceValueType::INT, nullptr, F("dampedtemp"), F("damped outdoor temperature"), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &ibaBuildingType_, DeviceValueType::ENUM, FL_(enum_ibaBuildingType2), F("building"), F("building"));
|
register_device_value(TAG_THERMOSTAT_DATA, &ibaBuildingType_, DeviceValueType::ENUM, FL_(enum_ibaBuildingType2), F("building"), F("building"));
|
||||||
register_device_value(TAG_NONE, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode2), F("wwmode"), F("warm water mode"));
|
register_device_value(TAG_THERMOSTAT_DATA, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode2), F("wwmode"), F("warm water mode"));
|
||||||
register_device_value(TAG_NONE, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode2), F("wwcircmode"), F("warm water circulation mode"));
|
register_device_value(TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode2), F("wwcircmode"), F("warm water circulation mode"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ static const __FlashStringHelper * const DeviceValueTAG_s[] PROGMEM = {
|
|||||||
F_(tag_boiler_data),
|
F_(tag_boiler_data),
|
||||||
F_(tag_boiler_data_ww),
|
F_(tag_boiler_data_ww),
|
||||||
F_(tag_boiler_data_info),
|
F_(tag_boiler_data_info),
|
||||||
|
F_(tag_thermostat_data),
|
||||||
F_(tag_hc1),
|
F_(tag_hc1),
|
||||||
F_(tag_hc2),
|
F_(tag_hc2),
|
||||||
F_(tag_hc3),
|
F_(tag_hc3),
|
||||||
@@ -547,7 +548,8 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter
|
|||||||
// and don't show if full_name is empty unless we're outputing for mqtt payloads
|
// and don't show if full_name is empty unless we're outputing for mqtt payloads
|
||||||
// for nested we use all values
|
// for nested we use all values
|
||||||
if (((nested) || tag_filter == DeviceValueTAG::TAG_NONE || (tag_filter == dv.tag)) && (dv.full_name != nullptr || !console)) {
|
if (((nested) || tag_filter == DeviceValueTAG::TAG_NONE || (tag_filter == dv.tag)) && (dv.full_name != nullptr || !console)) {
|
||||||
bool have_tag = (dv.tag != tag_filter);
|
// we have a tag if it matches the filter given, and that the tag name is not empty/""
|
||||||
|
bool have_tag = ((dv.tag != tag_filter) && !tag_to_string(dv.tag).empty());
|
||||||
|
|
||||||
// EMSESP::logger().info(F("**HERE: console=%d nested=%d tag_filter=%d tag=%d type=%d short=%s"), console, nested, tag_filter, dv.tag, dv.type, uuid::read_flash_string(dv.short_name).c_str());
|
// EMSESP::logger().info(F("**HERE: console=%d nested=%d tag_filter=%d tag=%d type=%d short=%s"), console, nested, tag_filter, dv.tag, dv.type, uuid::read_flash_string(dv.short_name).c_str());
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ enum DeviceValueUOM : uint8_t { NONE = 0, DEGREES, PERCENT, LMIN, KWH, WH, HOURS
|
|||||||
MAKE_PSTR(tag_boiler_data, "boiler")
|
MAKE_PSTR(tag_boiler_data, "boiler")
|
||||||
MAKE_PSTR(tag_boiler_data_ww, "warm water")
|
MAKE_PSTR(tag_boiler_data_ww, "warm water")
|
||||||
MAKE_PSTR(tag_boiler_data_info, "info")
|
MAKE_PSTR(tag_boiler_data_info, "info")
|
||||||
|
MAKE_PSTR(tag_thermostat_data, "") // use empty string if want to suppress showing tags
|
||||||
MAKE_PSTR(tag_hc1, "hc1")
|
MAKE_PSTR(tag_hc1, "hc1")
|
||||||
MAKE_PSTR(tag_hc2, "hc2")
|
MAKE_PSTR(tag_hc2, "hc2")
|
||||||
MAKE_PSTR(tag_hc3, "hc3")
|
MAKE_PSTR(tag_hc3, "hc3")
|
||||||
@@ -81,10 +82,11 @@ MAKE_PSTR(tag_wwc2, "wwc2")
|
|||||||
MAKE_PSTR(tag_wwc3, "wwc3")
|
MAKE_PSTR(tag_wwc3, "wwc3")
|
||||||
MAKE_PSTR(tag_wwc4, "wwc4")
|
MAKE_PSTR(tag_wwc4, "wwc4")
|
||||||
enum DeviceValueTAG : uint8_t {
|
enum DeviceValueTAG : uint8_t {
|
||||||
TAG_NONE = 0,
|
TAG_NONE = 0, // wild card
|
||||||
TAG_BOILER_DATA,
|
TAG_BOILER_DATA,
|
||||||
TAG_BOILER_DATA_WW,
|
TAG_BOILER_DATA_WW,
|
||||||
TAG_BOILER_DATA_INFO,
|
TAG_BOILER_DATA_INFO,
|
||||||
|
TAG_THERMOSTAT_DATA,
|
||||||
TAG_HC1,
|
TAG_HC1,
|
||||||
TAG_HC2,
|
TAG_HC2,
|
||||||
TAG_HC3,
|
TAG_HC3,
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
|||||||
if (nested) {
|
if (nested) {
|
||||||
need_publish |= emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE, true); // nested
|
need_publish |= emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE, true); // nested
|
||||||
} else {
|
} else {
|
||||||
emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE, false); // not nested
|
emsdevice->generate_values_json(json, DeviceValueTAG::TAG_THERMOSTAT_DATA, false); // not nested
|
||||||
Mqtt::publish("thermostat_data", json);
|
Mqtt::publish("thermostat_data", json);
|
||||||
json.clear();
|
json.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ class Mqtt {
|
|||||||
return nested_format_;
|
return nested_format_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nested_format(bool nested_format) {
|
||||||
|
nested_format_ = nested_format;
|
||||||
|
}
|
||||||
|
|
||||||
static bool ha_enabled() {
|
static bool ha_enabled() {
|
||||||
return ha_enabled_;
|
return ha_enabled_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,13 +414,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
|
|
||||||
if (command == "mqtt_nested") {
|
if (command == "mqtt_nested") {
|
||||||
shell.printfln(F("Testing nested MQTT"));
|
shell.printfln(F("Testing nested MQTT"));
|
||||||
Mqtt::ha_enabled(false); // turn off HA Discovery
|
Mqtt::ha_enabled(false); // turn off HA Discovery to stop the chatter
|
||||||
|
|
||||||
run_test("boiler");
|
run_test("boiler");
|
||||||
run_test("thermostat");
|
run_test("thermostat");
|
||||||
run_test("solar");
|
run_test("solar");
|
||||||
run_test("mixer");
|
run_test("mixer");
|
||||||
|
|
||||||
|
// first with nested
|
||||||
|
Mqtt::nested_format(true);
|
||||||
|
shell.invoke_command("call system publish");
|
||||||
|
|
||||||
|
// then without nested
|
||||||
|
Mqtt::nested_format(false);
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user