Skip to content

Commit

Permalink
Merge branch 'dev' into dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Oct 12, 2024
2 parents f8ee82e + f0a2f40 commit 054b40c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 46 deletions.
18 changes: 10 additions & 8 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ extra_scripts = scripts/rename_fw.py
board = esp32dev
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM
board_build.extra_flags =
-DARDUINO_ESP32_DEV
-DBOARD_HAS_PSRAM


[env:ci_s3_16M_P]
; 16MB ESP32-S3 - with PSRAM - like BBQKees S3
Expand All @@ -119,7 +122,6 @@ board = lolin_s3
board_build.f_cpu = 240000000L
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM

;
; Direct builds
Expand All @@ -144,14 +146,15 @@ extends = espressif32_base
board = esp32dev
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM
board_build.extra_flags =
-DARDUINO_ESP32_DEV
-DBOARD_HAS_PSRAM

[env:c3_mini_4M]
extends = espressif32_base_tasmota
board = lolin_c3_mini
board_upload.flash_size = 4MB
board_build.partitions = esp32_partition_4M.csv
board_build.extra_flags = '-DEMSESP_DEFAULT_BOARD_PROFILE="C3MINI"'

; lolin C3 mini v1 needs special wifi init.
; https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
Expand All @@ -160,14 +163,15 @@ extends = espressif32_base_tasmota
board = lolin_c3_mini
board_upload.flash_size = 4MB
board_build.partitions = esp32_partition_4M.csv
board_build.extra_flags = -DBOARD_C3_MINI_V1 '-DEMSESP_DEFAULT_BOARD_PROFILE="C3MINI"'
build_flags =
${common.build_flags}
-DBOARD_C3_MINI_V1

[env:s2_4M]
extends = espressif32_base_tasmota
board = lolin_s2_mini
board_upload.flash_size = 4MB
board_build.partitions = esp32_partition_4M.csv
board_build.extra_flags = '-DEMSESP_DEFAULT_BOARD_PROFILE="S2MINI"'

; https://github.com/platformio/platform-espressif32/blob/master/boards/lolin_s3.json
[env:s3_16M_P]
Expand All @@ -177,7 +181,6 @@ board_upload.use_1200bps_touch = false
board_upload.wait_for_upload_port = false
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM

[env:s3_32M_P]
extends = espressif32_base
Expand All @@ -186,7 +189,6 @@ board_build.arduino.memory_type: opi_opi
board_build.flash_mode = opi
board_upload.flash_size = 32MB
board_build.partitions = esp32_partition_32M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM

;
; Building and testing natively, standalone without an ESP32.
Expand Down
17 changes: 17 additions & 0 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,13 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
FL_(hpMaxPower),
DeviceValueUOM::PERCENT,
MAKE_CF_CB(set_hpMaxPower));
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&pvMaxComp_,
DeviceValueType::UINT8,
DeviceValueNumOp::DV_NUMOP_DIV10,
FL_(pvMaxComp),
DeviceValueUOM::KW,
MAKE_CF_CB(set_pvMaxComp));
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&hpSetDiffPress_,
DeviceValueType::UINT8,
Expand Down Expand Up @@ -1939,6 +1946,7 @@ void Boiler::process_HpSilentMode(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, hpMaxPower_, 31);
has_update(telegram, silentFrom_, 52); // in steps of 15 min
has_update(telegram, silentTo_, 53); // in steps of 15 min
has_update(telegram, pvMaxComp_, 54); // #2062
has_update(telegram, hpshutdown_, 58); // 1 powers off
}

Expand Down Expand Up @@ -3114,6 +3122,15 @@ bool Boiler::set_hpMaxPower(const char * value, const int8_t id) {
return false;
}

bool Boiler::set_pvMaxComp(const char * value, const int8_t id) {
float v;
if (Helpers::value2float(value, v)) {
write_command(0x484, 54, (uint8_t)(v * 10), 0x484);
return true;
}
return false;
}

bool Boiler::set_hpDiffPress(const char * value, const int8_t id) {
int v;
if (Helpers::value2number(value, v)) {
Expand Down
2 changes: 2 additions & 0 deletions src/devices/boiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class Boiler : public EMSdevice {
uint8_t maxHeatHeat_;
uint8_t maxHeatDhw_;
uint8_t hpMaxPower_;
uint8_t pvMaxComp_;

uint8_t pvCooling_;
uint8_t manDefrost_;
Expand Down Expand Up @@ -476,6 +477,7 @@ class Boiler : public EMSdevice {
bool set_hpCircPumpWw(const char * value, const int8_t id);
bool set_hpPumpMode(const char * value, const int8_t id);
bool set_hpMaxPower(const char * value, const int8_t id);
bool set_pvMaxComp(const char * value, const int8_t id);
bool set_hpDiffPress(const char * value, const int8_t id);
bool set_hpPowerLimit(const char * value, const int8_t id);

Expand Down
52 changes: 26 additions & 26 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,18 @@ uint8_t Thermostat::HeatingCircuit::get_mode_type() const {
return HeatingCircuit::Mode::DAY;
}

std::shared_ptr<Thermostat::DhwCircuit> Thermostat::dhw_circuit(const uint8_t offset, const uint8_t dhw_num, const bool create) {
std::shared_ptr<Thermostat::DhwCircuit> Thermostat::dhw_circuit(const uint8_t offset, const bool create) {
// check for existing circuit
for (const auto & dhw_circuit : dhw_circuits_) {
if (dhw_circuit->dhw() == dhw_num - 1 || dhw_circuit->offset() == offset) {
if (dhw_circuit->offset() == offset) {
return dhw_circuit;
}
}
if (!create) {
return nullptr;
}
// create a new circuit object and add to the list
auto new_dhw = std::make_shared<Thermostat::DhwCircuit>(offset, dhw_num == 255 ? offset + 1 : dhw_num);
auto new_dhw = std::make_shared<Thermostat::DhwCircuit>(offset);
dhw_circuits_.push_back(new_dhw);
// register the device values
register_device_values_dhw(new_dhw);
Expand Down Expand Up @@ -677,7 +677,7 @@ void Thermostat::process_RC10Set(std::shared_ptr<const Telegram> telegram) {
if (hc == nullptr) {
return;
}
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
has_update(telegram, ibaCalIntTemperature_, 0);
has_update(telegram, backlight_, 1);
has_update(telegram, dhw->wwMode_, 2);
Expand Down Expand Up @@ -898,10 +898,10 @@ void Thermostat::process_JunkersTimer(std::shared_ptr<const Telegram> telegram)
memcpy(&hc->switchprog[telegram->offset], telegram->message_data, length);
}
} else if (telegram->type_id == 0x1FB) { // dhw
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
memcpy(&dhw->switchprog[telegram->offset], telegram->message_data, length);
} else if (telegram->type_id == 0x20F) { // dhw
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
memcpy(&dhw->circswitchprog[telegram->offset], telegram->message_data, length);
}
}
Expand Down Expand Up @@ -957,7 +957,7 @@ void Thermostat::process_IBASettings(std::shared_ptr<const Telegram> telegram) {

// Settings WW 0x37 - RC35
void Thermostat::process_RC35wwSettings(std::shared_ptr<const Telegram> telegram) {
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
has_update(telegram, dhw->wwProgMode_, 0); // 0-like hc, 0xFF own prog
has_update(telegram, dhw->wwCircProg_, 1); // 0-like hc, 0xFF own prog
has_update(telegram, dhw->wwMode_, 2); // 0-off, 1-on, 2-auto
Expand All @@ -971,7 +971,7 @@ void Thermostat::process_RC35wwSettings(std::shared_ptr<const Telegram> telegram

// Settings WW 0x3A - RC30
void Thermostat::process_RC30wwSettings(std::shared_ptr<const Telegram> telegram) {
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
has_update(telegram, dhw->wwMode_, 0); // 0-on, 1-off, 2-auto
has_update(telegram, dhw->wwWhenModeOff_, 1); // 0-off, 0xFF on
has_update(telegram, dhw->wwDisinfecting_, 2); // 0-off, 0xFF on
Expand All @@ -981,7 +981,7 @@ void Thermostat::process_RC30wwSettings(std::shared_ptr<const Telegram> telegram

// type 0x38 (ww) and 0x39 (circ)
void Thermostat::process_RC35wwTimer(std::shared_ptr<const Telegram> telegram) {
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
if (telegram->offset < 84) {
auto length = ((telegram->offset + telegram->message_length) > 84) ? 84 - telegram->offset : telegram->message_length;
if (telegram->type_id == 0x38) {
Expand Down Expand Up @@ -1085,7 +1085,7 @@ void Thermostat::process_JunkersSetMixer(std::shared_ptr<const Telegram> telegra

// Thermostat(0x10) -> All(0x00), ?(0x01D3), data: 01 00 00
void Thermostat::process_JunkersWW(std::shared_ptr<const Telegram> telegram) {
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
has_bitupdate(telegram, dhw->wwCharge_, 0, 3);
}

Expand Down Expand Up @@ -1273,7 +1273,7 @@ void Thermostat::process_RC300Curve(std::shared_ptr<const Telegram> telegram) {

// types 0x31B
void Thermostat::process_RC300WWtemp(std::shared_ptr<const Telegram> telegram) {
auto dhw = dhw_circuit(0, 1, true);
auto dhw = dhw_circuit(0, true);
has_update(telegram, dhw->wwSetTemp_, 0);
has_update(telegram, dhw->wwSetTempLow_, 1);
}
Expand All @@ -1283,8 +1283,8 @@ void Thermostat::process_RC300WWtemp(std::shared_ptr<const Telegram> telegram) {
// RC300WWmode(0x2F6), data: 02 FF 04 00 00 00 08 05 00 08 04 00 00 00 00 00 00 00 00 00 01
void Thermostat::process_RC300WWmode(std::shared_ptr<const Telegram> telegram) {
uint8_t circuit = 0;
telegram->read_value(circuit, 0);
auto dhw = dhw_circuit(telegram->type_id - 0x2F5, 255, circuit != 0);
telegram->read_value(circuit, 0); // 00-no circuit, 01-boiler, 02-mixer
auto dhw = dhw_circuit(telegram->type_id - 0x2F5, circuit != 0);
if (dhw == nullptr) {
return;
}
Expand Down Expand Up @@ -2230,7 +2230,7 @@ bool Thermostat::set_roomsensor(const char * value, const int8_t id) {

// 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) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand Down Expand Up @@ -2317,7 +2317,7 @@ bool Thermostat::set_wwtemplow(const char * value, const int8_t id) {

// Set ww charge RC300, ems+
bool Thermostat::set_wwcharge(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -2337,7 +2337,7 @@ bool Thermostat::set_wwcharge(const char * value, const int8_t id) {

// Set ww charge duration in steps of 15 min, ems+
bool Thermostat::set_wwchargeduration(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand Down Expand Up @@ -2430,7 +2430,7 @@ bool Thermostat::set_switchProgMode(const char * value, const int8_t id) {

// sets the thermostat ww circulation working mode, where mode is a string
bool Thermostat::set_wwcircmode(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -2453,7 +2453,7 @@ bool Thermostat::set_wwcircmode(const char * value, const int8_t id) {
}

bool Thermostat::set_wwDailyHeating(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -2467,7 +2467,7 @@ bool Thermostat::set_wwDailyHeating(const char * value, const int8_t id) {
}

bool Thermostat::set_wwDailyHeatTime(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -2488,7 +2488,7 @@ bool Thermostat::set_wwDailyHeatTime(const char * value, const int8_t id) {
}

bool Thermostat::set_wwDisinfect(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -2509,7 +2509,7 @@ bool Thermostat::set_wwDisinfect(const char * value, const int8_t id) {
}

bool Thermostat::set_wwDisinfectDay(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -2530,7 +2530,7 @@ bool Thermostat::set_wwDisinfectDay(const char * value, const int8_t id) {
}

bool Thermostat::set_wwDisinfectHour(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand Down Expand Up @@ -3542,7 +3542,7 @@ bool Thermostat::set_switchprog(const char * value, const int8_t id) {

// sets switchprogram in the thermostat dhw circulation program
bool Thermostat::set_wwCircSwitchProg(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand All @@ -3559,7 +3559,7 @@ bool Thermostat::set_wwCircSwitchProg(const char * value, const int8_t id) {

// sets switchprogram in the thermostat dhw program
bool Thermostat::set_wwSwitchProg(const char * value, const int8_t id) {
auto dhw = dhw_circuit(255, id2dhw(id));
auto dhw = dhw_circuit(id2dhw(id));
if (dhw == nullptr) {
return false;
}
Expand Down Expand Up @@ -4506,7 +4506,7 @@ void Thermostat::register_device_values() {
register_device_values_hc(new_hc);

// also a dhw circuit...
auto new_dhw = std::make_shared<Thermostat::DhwCircuit>(0, 1); // offset 0, dhw num 1
auto new_dhw = std::make_shared<Thermostat::DhwCircuit>(0); // offset 0, dhw num 1
dhw_circuits_.push_back(new_dhw);
register_device_values_dhw(new_dhw);
#endif
Expand Down Expand Up @@ -4985,7 +4985,7 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi

// registers the values for a heating circuit
void Thermostat::register_device_values_dhw(std::shared_ptr<Thermostat::DhwCircuit> dhw) {
int8_t tag = DeviceValueTAG::TAG_DHW1 + dhw->dhw();
int8_t tag = dhw->id();
switch (this->model()) {
case EMSdevice::EMS_DEVICE_FLAG_RC100:
case EMSdevice::EMS_DEVICE_FLAG_RC300:
Expand Down
23 changes: 11 additions & 12 deletions src/devices/thermostat.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ class Thermostat : public EMSdevice {

class DhwCircuit {
public:
DhwCircuit(const uint8_t offset, const uint8_t dhw_num)
: offset_(offset)
, dhw_num_(dhw_num) {
DhwCircuit(const uint8_t offset)
: dhw_num_(offset) {
}
~DhwCircuit() = default;
uint8_t wwExtra_;
Expand All @@ -200,16 +199,16 @@ class Thermostat : public EMSdevice {
char wwHoliday_[22];
char wwVacation_[22];

uint8_t dhw() const {
return dhw_num_ - 1;
uint8_t id() const { // returns TAG(id)
return DeviceValueTAG::TAG_DHW1 + dhw_num_;
}
uint8_t offset() const {
return offset_;

uint8_t offset() const { // returns telegram offset
return dhw_num_;
}

private:
uint8_t offset_; // telegram offset to base telegram
uint8_t dhw_num_; // dhw circuit number 1..10
uint8_t dhw_num_; // dhw circuit number 0..10
};

private:
Expand All @@ -232,8 +231,8 @@ class Thermostat : public EMSdevice {
return (flags() & 32);
}

inline uint8_t id2dhw(const int8_t id) const {
return id - DeviceValueTAG::TAG_DHW1 + 1;
inline uint8_t id2dhw(const int8_t id) const { // returns telegram offset for TAG(id)
return id - DeviceValueTAG::TAG_DHW1;
}

// each thermostat has a list of heating controller type IDs for reading and writing
Expand Down Expand Up @@ -401,7 +400,7 @@ class Thermostat : public EMSdevice {

std::shared_ptr<Thermostat::HeatingCircuit> heating_circuit(std::shared_ptr<const Telegram> telegram);
std::shared_ptr<Thermostat::HeatingCircuit> heating_circuit(const int8_t id);
std::shared_ptr<Thermostat::DhwCircuit> dhw_circuit(const uint8_t offset = 0, const uint8_t dhw_num = 255, const bool create = false);
std::shared_ptr<Thermostat::DhwCircuit> dhw_circuit(const uint8_t offset, const bool create = false);

void register_device_values_hc(std::shared_ptr<Thermostat::HeatingCircuit> hc);
void register_device_values_dhw(std::shared_ptr<Thermostat::DhwCircuit> dhw);
Expand Down
Loading

0 comments on commit 054b40c

Please sign in to comment.