From 752ce333ec204cf3871c0aabdb76e98b625cf5bf Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 13 Nov 2023 13:54:13 +0100 Subject: [PATCH 1/4] RC300/BC400 mode setting --- src/devices/thermostat.cpp | 21 +++++++++++++-------- src/devices/thermostat.h | 2 ++ src/locale_common.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index f7f5dfa32..4229b6c59 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1021,8 +1021,14 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { // has_update(telegram, hc->selTemp, 8, 1); // single byte conversion, value is * 2 - auto? // has_update(telegram, hc->selTemp, 10, 1); // single byte conversion, value is * 2 - manual - // check why mode is both in the Monitor and Set for the RC300. It'll be read twice! - // has_update(telegram, hc->mode, 0); // Auto = xFF, Manual = x00 eg. 10 00 FF 08 01 B9 FF + telegram->read_value(hc->mode_new, 21); // 0-off, 1-manual, 2-auto + if (Helpers::hasValue(hc->mode_new)) { + has_update(hc->mode, hc->mode_new); + } else { + uint8_t mode = EMS_VALUE_UINT_NOTSET; + telegram->read_value(mode, 0); + has_update(hc->mode, mode == 0xFF ? 2 : 1); + } has_update(telegram, hc->daytemp, 2); // is * 2 has_update(telegram, hc->nighttemp, 4); // is * 2 @@ -2552,12 +2558,11 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) { break; case EMSdevice::EMS_DEVICE_FLAG_RC300: case EMSdevice::EMS_DEVICE_FLAG_RC100: - offset = EMS_OFFSET_RCPLUSSet_mode; - validate_typeid = monitor_typeids[hc_p]; - if (mode == HeatingCircuit::Mode::AUTO) { - set_mode_value = 0xFF; // special value for auto + if (Helpers::hasValue(hc->mode_new)) { + offset = EMS_OFFSET_RCPLUSSet_mode_new; } else { - set_mode_value = 0; // everything else, like manual/day etc.. + offset = EMS_OFFSET_RCPLUSSet_mode; + set_mode_value = set_mode_value == 2 ? 0xFF : 0; } break; case EMSdevice::EMS_DEVICE_FLAG_JUNKERS: @@ -3599,7 +3604,7 @@ void Thermostat::register_device_values() { &wwDisinfectHour_, DeviceValueType::UINT, DeviceValueNumOp::DV_NUMOP_MUL15, - FL_(wwDisinfectTime), + FL_(wwDisinfectHour), DeviceValueUOM::MINUTES, MAKE_CF_CB(set_wwDisinfectHour), 0, diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 8db4096dd..4fa450143 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -41,6 +41,7 @@ class Thermostat : public EMSdevice { uint8_t tempautotemp; int8_t remoteseltemp; uint8_t mode; + uint8_t mode_new; uint8_t modetype; uint8_t summermode; uint8_t holidaymode; @@ -318,6 +319,7 @@ class Thermostat : public EMSdevice { static constexpr uint8_t EMS_OFFSET_RCPLUSStatusMessage_curr = 0; // current temp static constexpr uint8_t EMS_OFFSET_RCPLUSStatusMessage_currsetpoint = 6; // target setpoint temp static constexpr uint8_t EMS_OFFSET_RCPLUSSet_mode = 0; // operation mode(Auto=0xFF, Manual=0x00) + static constexpr uint8_t EMS_OFFSET_RCPLUSSet_mode_new = 21; // operation mode(0-off, 1-manual, 2-auto) static constexpr uint8_t EMS_OFFSET_RCPLUSSet_temp_comfort3 = 1; // comfort3 level static constexpr uint8_t EMS_OFFSET_RCPLUSSet_temp_comfort2 = 2; // comfort2 level static constexpr uint8_t EMS_OFFSET_RCPLUSSet_temp_comfort1 = 3; // comfort1 level diff --git a/src/locale_common.h b/src/locale_common.h index 7d52e6801..ce3b8675f 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -303,7 +303,7 @@ MAKE_ENUM(enum_summer, FL_(winter), FL_(summer)) MAKE_ENUM(enum_operatingstate, FL_(heating), FL_(off), FL_(cooling)) MAKE_ENUM(enum_hpmode, FL_(heating), FL_(cooling), FL_(heatandcool)) -MAKE_ENUM(enum_mode, FL_(manual), FL_(auto)) // RC100, RC300, RC310 +MAKE_ENUM(enum_mode, FL_(off), FL_(manual), FL_(auto)) // RC100, RC300, RC310 MAKE_ENUM(enum_mode2, FL_(off), FL_(manual), FL_(auto)) // RC20, RC30 MAKE_ENUM(enum_mode3, FL_(night), FL_(day), FL_(auto)) // RC35, RC30_N, RC25, RC20_N MAKE_ENUM(enum_mode4, FL_(nofrost), FL_(eco), FL_(heat), FL_(auto)) // JUNKERS From 50590f492440d3a9c15667a0931202d8d6527261 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 14 Nov 2023 10:52:23 +0100 Subject: [PATCH 2/4] console api_data --- src/console.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/console.cpp b/src/console.cpp index e74ecded8..cc8be210c 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -530,7 +530,14 @@ static void setup_commands(std::shared_ptr & commands) { if (return_code == CommandRet::OK && json.size()) { if (json.containsKey("api_data")) { JsonVariant data = json["api_data"]; - shell.println(data.as()); + if (data.is()) { + shell.printfln("%d", data.as()); + } else if (data.is()) { + char s[10]; + shell.println(Helpers::render_value(s, data.as(), 1)); + } else { + shell.println(data.as()); + } return; } serializeJsonPretty(doc, shell); From 3b30083e7cfff0f8036cd0bd7bdee5b8bfc4e57e Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 14 Nov 2023 10:52:39 +0100 Subject: [PATCH 3/4] fix extension module --- src/devices/extension.cpp | 22 ++++++++++++++-------- src/devices/extension.h | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/devices/extension.cpp b/src/devices/extension.cpp index 8ca66acc2..460d80791 100644 --- a/src/devices/extension.cpp +++ b/src/devices/extension.cpp @@ -25,6 +25,7 @@ REGISTER_FACTORY(Extension, EMSdevice::DeviceType::EXTENSION); Extension::Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand) : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { register_telegram_type(0x935, "EM100SetMessage", true, MAKE_PF_CB(process_EM100SetMessage)); + register_telegram_type(0x936, "EM100OutMessage", false, MAKE_PF_CB(process_EM100OutMessage)); register_telegram_type(0x937, "EM100TempMessage", false, MAKE_PF_CB(process_EM100TempMessage)); register_telegram_type(0x938, "EM100InputMessage", false, MAKE_PF_CB(process_EM100InputMessage)); register_telegram_type(0x939, "EM100MonitorMessage", false, MAKE_PF_CB(process_EM100MonitorMessage)); @@ -36,7 +37,7 @@ Extension::Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(flowTempVf), DeviceValueUOM::DEGREES); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &input_, DeviceValueType::USHORT, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(input), DeviceValueUOM::VOLTS); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &input_, DeviceValueType::UINT, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(input), DeviceValueUOM::VOLTS); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &outPower_, DeviceValueType::UINT, FL_(outPower), DeviceValueUOM::PERCENT); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setPower_, DeviceValueType::UINT, FL_(setPower), DeviceValueUOM::PERCENT); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setPoint_, DeviceValueType::UINT, FL_(setPoint), DeviceValueUOM::DEGREES); @@ -61,7 +62,8 @@ Extension::Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, } -// 0x935 needs fetch +// extension(0x15) -W-> Me(0x0B), EM100SetMessage(0x0935), data: 00 00 64 50 14 +// need to be fetched void Extension::process_EM100SetMessage(std::shared_ptr telegram) { has_update(telegram, minV_, 1); // Input for off, is / 10 has_update(telegram, maxV_, 2); // Input for 100%, is / 10 @@ -69,18 +71,22 @@ void Extension::process_EM100SetMessage(std::shared_ptr telegram has_update(telegram, maxT_, 4); // max temp } -// alert(0x15) -B-> All(0x00), ?(0x093A), data: 00 00 00 00 00 00 00 00 00 03 01 +// extension(0x15) -B-> All(0x00), ?(0x0936), data: 00 00 00 00 28 00 (offset 1) +void Extension::process_EM100OutMessage(std::shared_ptr telegram) { + has_update(telegram, outPower_, 5); // power monitor % +} + +// extension(0x15) -B-> All(0x00), ?(0x093A), data: 00 00 00 00 00 00 00 00 00 03 01 void Extension::process_EM100ConfigMessage(std::shared_ptr telegram) { has_update(telegram, dip_, 9); } -// alert(0x15) -B-> All(0x00), ?(0x0938), data: 01 62 +// extension(0x15) -B-> All(0x00), ?(0x0938), data: 01 62 void Extension::process_EM100InputMessage(std::shared_ptr telegram) { - has_update(telegram, outPower_, 0); // IO1 has_update(telegram, input_, 1); } -// alert(0x15) -B-> All(0x00), ?(0x0939), data: 64 4E 00 00 +// extension(0x15) -B-> All(0x00), ?(0x0939), data: 64 4E 00 00 void Extension::process_EM100MonitorMessage(std::shared_ptr telegram) { has_update(telegram, setPower_, 0); // percent has_update(telegram, setPoint_, 1); // °C @@ -88,7 +94,7 @@ void Extension::process_EM100MonitorMessage(std::shared_ptr tele // has_update(telegram, errorPump_, 3); // IE0 } -// alert(0x15) -B-> All(0x00), ?(0x0937), data: 80 00 +// extension(0x15) -B-> All(0x00), ?(0x0937), data: 80 00 void Extension::process_EM100TempMessage(std::shared_ptr telegram) { has_update(telegram, headerTemp_, 0); } @@ -129,4 +135,4 @@ bool Extension::set_maxT(const char * value, const int8_t id) { return true; } -} // namespace emsesp \ No newline at end of file +} // namespace emsesp diff --git a/src/devices/extension.h b/src/devices/extension.h index ceaba27a0..ae592bd66 100644 --- a/src/devices/extension.h +++ b/src/devices/extension.h @@ -29,6 +29,7 @@ class Extension : public EMSdevice { private: void process_EM100SetMessage(std::shared_ptr telegram); + void process_EM100OutMessage(std::shared_ptr telegram); void process_EM100MonitorMessage(std::shared_ptr telegram); void process_EM100TempMessage(std::shared_ptr telegram); void process_EM100InputMessage(std::shared_ptr telegram); @@ -41,7 +42,7 @@ class Extension : public EMSdevice { int16_t headerTemp_; // T0 - int16_t input_; // IO1 + uint8_t input_; // IO1 uint8_t errorState_; // OE1 uint8_t errorPump_; // IE0 uint8_t outPower_; // IO1 From 4f1ef297c7f69a1df0a8781783d078586994e5c2 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 14 Nov 2023 10:53:20 +0100 Subject: [PATCH 4/4] thermostat RC300 mode --- src/devices/thermostat.cpp | 22 ++++++++++++---------- src/devices/thermostat.h | 2 +- src/emsdevice.cpp | 10 ++++++++++ src/emsdevice.h | 1 + src/locale_translations.h | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 4229b6c59..9573c7bc7 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -976,7 +976,8 @@ void Thermostat::process_RC300Monitor(std::shared_ptr telegram) has_update(telegram, hc->roomTemp, 0); // is * 10 has_bitupdate(telegram, hc->modetype, 10, 1); - has_bitupdate(telegram, hc->mode, 10, 0); // bit 1, mode (auto=1 or manual=0) + // auto status, read mode in settings + // has_bitupdate(telegram, hc->mode, 10, 0); // bit 0, mode (auto=1 or manual=0) // if manual, take the current setpoint temp at pos 6 // if auto, take the next setpoint temp at pos 7 @@ -990,7 +991,7 @@ void Thermostat::process_RC300Monitor(std::shared_ptr telegram) // summermode is bit 4 for boilers and bit 6 for heatpumps: 0:winter, 1:summer telegram->read_value(hc->statusbyte, 2); // use summertemp or hpoperatingstate, https://github.com/emsesp/EMS-ESP32/issues/747, #550, #503 - if ((hc->statusbyte & 1) || !is_fetch(summer2_typeids[hc->hc()])) { + if ((hc->statusbyte & 1) || !is_received(summer2_typeids[hc->hc()])) { has_update(hc->summermode, hc->statusbyte & 0x50 ? 1 : 0); has_update(hc->hpoperatingstate, EMS_VALUE_UINT_NOTSET); } else { @@ -1022,12 +1023,13 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { // has_update(telegram, hc->selTemp, 10, 1); // single byte conversion, value is * 2 - manual telegram->read_value(hc->mode_new, 21); // 0-off, 1-manual, 2-auto - if (Helpers::hasValue(hc->mode_new)) { + if (hc->mode_new <= 2) { has_update(hc->mode, hc->mode_new); } else { - uint8_t mode = EMS_VALUE_UINT_NOTSET; - telegram->read_value(mode, 0); - has_update(hc->mode, mode == 0xFF ? 2 : 1); + uint8_t mode = hc->mode == 2 ? 0xFF : 0; // auto : manual + if (telegram->read_value(mode, 0)) { + has_update(hc->mode, mode == 0xFF ? 2 : 1); + } } has_update(telegram, hc->daytemp, 2); // is * 2 has_update(telegram, hc->nighttemp, 4); // is * 2 @@ -1063,7 +1065,7 @@ void Thermostat::process_RC300Summer(std::shared_ptr telegram) { has_update(telegram, hc->roominfluence, 0); has_update(telegram, hc->roominfl_factor, 1); // is * 10 has_update(telegram, hc->offsettemp, 2); - if (!is_fetch(summer2_typeids[hc->hc()])) { + if (!is_received(summer2_typeids[hc->hc()])) { has_update(telegram, hc->summertemp, 6); has_update(telegram, hc->summersetmode, 7); } @@ -2616,7 +2618,7 @@ bool Thermostat::set_summermode(const char * value, const int8_t id) { uint8_t set; - if (is_fetch(summer2_typeids[hc->hc()])) { + if (is_received(summer2_typeids[hc->hc()])) { if ((hc->statusbyte & 1) && Helpers::value2enum(value, set, FL_(enum_summermode))) { write_command(summer2_typeids[hc->hc()], 0, set, summer2_typeids[hc->hc()]); return true; @@ -3169,7 +3171,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co validate_typeid = set_typeids[hc->hc()]; switch (mode) { case HeatingCircuit::Mode::SUMMER: - if (is_fetch(summer2_typeids[hc->hc()])) { + if (is_received(summer2_typeids[hc->hc()])) { offset = 0x01; set_typeid = summer2_typeids[hc->hc()]; } else { @@ -3604,7 +3606,7 @@ void Thermostat::register_device_values() { &wwDisinfectHour_, DeviceValueType::UINT, DeviceValueNumOp::DV_NUMOP_MUL15, - FL_(wwDisinfectHour), + FL_(wwDisinfectTime), DeviceValueUOM::MINUTES, MAKE_CF_CB(set_wwDisinfectHour), 0, diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 4fa450143..3ad8bec68 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -41,7 +41,7 @@ class Thermostat : public EMSdevice { uint8_t tempautotemp; int8_t remoteseltemp; uint8_t mode; - uint8_t mode_new; + uint8_t mode_new = EMS_VALUE_UINT_NOTSET; // not initialized by register_value uint8_t modetype; uint8_t summermode; uint8_t holidaymode; diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index e5af41ed2..5c7847829 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -333,6 +333,16 @@ bool EMSdevice::is_fetch(uint16_t telegram_id) const { return false; } +// get status of automatic fetch for a telegramID +bool EMSdevice::is_received(uint16_t telegram_id) const { + for (const auto & tf : telegram_functions_) { + if (tf.telegram_type_id_ == telegram_id) { + return tf.received_; + } + } + return false; +} + // check for a tag to create a nest bool EMSdevice::has_tags(const uint8_t tag) const { for (const auto & dv : devicevalues_) { diff --git a/src/emsdevice.h b/src/emsdevice.h index 7060a119d..afd0f2aea 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -316,6 +316,7 @@ class EMSdevice { void fetch_values(); void toggle_fetch(uint16_t telegram_id, bool toggle); bool is_fetch(uint16_t telegram_id) const; + bool is_received(uint16_t telegram_id) const; bool has_telegram_id(uint16_t id) const; void ha_config_clear(); diff --git a/src/locale_translations.h b/src/locale_translations.h index 3f8b91a8f..e82f1f585 100644 --- a/src/locale_translations.h +++ b/src/locale_translations.h @@ -614,7 +614,7 @@ MAKE_TRANSLATION(wwChargeDuration, "wwchargeduration", "charge duration", "Laded MAKE_TRANSLATION(wwDisinfect, "wwdisinfect", "disinfection", "Desinfektion", "Desinfectie", "Desinfektion", "dezynfekcja termiczna", "desinfeksjon", "désinfection", "dezenfeksiyon", "disinfezione") MAKE_TRANSLATION(wwDisinfectDay, "wwdisinfectday", "disinfection day", "Desinfektionstag", "Desinfectiedag", "Desinfektionsdag", "dzień dezynfekcji termicznej", "desinfeksjonsdag", "jour désinfection", "dezenfeksiyon günü", "giorno disinfezione") MAKE_TRANSLATION(wwDisinfectHour, "wwdisinfecthour", "disinfection hour", "Desinfektionsstunde", "Desinfectieuur", "Desinfektionstimme", "godzina dezynfekcji termicznej", "desinfeksjonstime", "heure désinfection", "dezenfeksiyon saati", "ora disinfezione") -MAKE_TRANSLATION(wwDisinfectTime, "wwdisinfecttime", "disinfection time", "Desinfektionsdauer", "Desinfectietijd", "Desinfektionstid", "maksymalny czas trwania dezynfekcji termicznej", "desinfeksjonstid", "durée désinfection", "dezenfeksiyon zamanı", "orario disinfezione") +MAKE_TRANSLATION(wwDisinfectTime, "wwdisinfecttime", "disinfection time", "Desinfektionszeit", "Desinfectietijd", "Desinfektionstid", "maksymalny czas trwania dezynfekcji termicznej", "desinfeksjonstid", "durée désinfection", "dezenfeksiyon zamanı", "orario disinfezione") MAKE_TRANSLATION(wwDailyHeating, "wwdailyheating", "daily heating", "täglich Heizen", "Dagelijks opwarmen", "Daglig Uppvärmning", "codzienne nagrzewanie", "daglig oppvarming", "chauffage quotidien", "günlük ısıtma", "riscaldamento giornaliero") MAKE_TRANSLATION(wwDailyHeatTime, "wwdailyheattime", "daily heating time", "tägliche Heizzeit", "Tijd dagelijkse opwarming", "Daglig Uppvärmningstid", "czas trwania codziennego nagrzewania", "daglig oppvarmingstid", "heure chauffage quotidien", "günlük ısıtma süresi", "orario riscaldamento giornaliero")