masked enums with single mask, update seltemp in advance

This commit is contained in:
MichaelDvP
2025-05-23 07:41:43 +02:00
parent d3e0f180c5
commit ca81a02a8c
3 changed files with 20 additions and 15 deletions

View File

@@ -197,16 +197,17 @@ class EMSdevice {
} }
} }
void has_enumupdate(std::shared_ptr<const Telegram> telegram, void has_enumupdate(std::shared_ptr<const Telegram> telegram, uint8_t & value, const uint8_t index, const std::vector<uint8_t> & maskIn) {
uint8_t & value,
const uint8_t index,
const std::vector<uint8_t> & maskIn,
const std::vector<uint8_t> & maskOut) {
uint8_t val = value < maskIn.size() ? maskIn[value] : EMS_VALUE_UINT8_NOTSET; uint8_t val = value < maskIn.size() ? maskIn[value] : EMS_VALUE_UINT8_NOTSET;
if (telegram->read_value(val, index)) { if (telegram->read_value(val, index)) {
value = val < maskOut.size() ? maskOut[val] : EMS_VALUE_UINT8_NOTSET; for (uint8_t i = 0; i < maskIn.size(); i++) {
has_update_ = true; if (val == maskIn[i]) {
publish_value((void *)&value); value = i;
has_update_ = true;
publish_value((void *)&value);
return;
}
}
} }
} }

View File

@@ -1805,9 +1805,9 @@ void Boiler::process_HpCooling(std::shared_ptr<const Telegram> telegram) {
// Boiler(0x08) -W-> Me(0x0B), HpHeaterConfig(0x0492), data: 03 00 00 04 00 // Boiler(0x08) -W-> Me(0x0B), HpHeaterConfig(0x0492), data: 03 00 00 04 00
void Boiler::process_HpHeaterConfig(std::shared_ptr<const Telegram> telegram) { void Boiler::process_HpHeaterConfig(std::shared_ptr<const Telegram> telegram) {
if (model() == EMSdevice::EMS_DEVICE_FLAG_CS6800) { if (model() == EMSdevice::EMS_DEVICE_FLAG_CS6800) {
has_enumupdate(telegram, maxHeatComp_, 2, {0, 2, 4, 5}, {0, 0, 1, 0, 2, 3}); has_enumupdate(telegram, maxHeatComp_, 2, {0, 2, 4, 5});
has_enumupdate(telegram, maxHeatHeat_, 3, {2, 4, 5}, {0, 0, 0, 0, 1, 2}); has_enumupdate(telegram, maxHeatHeat_, 3, {2, 4, 5});
has_enumupdate(telegram, maxHeatDhw_, 4, {2, 4, 5}, {0, 0, 0, 0, 1, 2}); has_enumupdate(telegram, maxHeatDhw_, 4, {2, 4, 5});
return; return;
} }
has_update(telegram, maxHeatComp_, 2); has_update(telegram, maxHeatComp_, 2);

View File

@@ -1275,14 +1275,14 @@ void Thermostat::process_RC300WWmode(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, dhw->wwCircPump_, 1); // FF=off, 0=on ? has_update(telegram, dhw->wwCircPump_, 1); // FF=off, 0=on ?
if (model() == EMSdevice::EMS_DEVICE_FLAG_BC400 || model() == EMSdevice::EMS_DEVICE_FLAG_HMC310) { if (model() == EMSdevice::EMS_DEVICE_FLAG_BC400 || model() == EMSdevice::EMS_DEVICE_FLAG_HMC310) {
has_enumupdate(telegram, dhw->wwMode_, 2, {0, 5, 1, 2, 4}, {0, 2, 3, 0, 4, 1}); has_enumupdate(telegram, dhw->wwMode_, 2, {0, 5, 1, 2, 4});
} else if (model() == EMSdevice::EMS_DEVICE_FLAG_R3000) { } else if (model() == EMSdevice::EMS_DEVICE_FLAG_R3000) {
// https://github.com/emsesp/EMS-ESP32/pull/1722#discussion_r1582823521 // https://github.com/emsesp/EMS-ESP32/pull/1722#discussion_r1582823521
has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 5}, {0, 0, 1, 0, 0, 2}); // normal, comfort, eco+ has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 5}); // normal, comfort, eco+
} else if (model() == EMSdevice::EMS_DEVICE_FLAG_CR120) { } else if (model() == EMSdevice::EMS_DEVICE_FLAG_CR120) {
has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 4}, {0, 0, 1, 0, 2, 0}); // normal, comfort, auto has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 4}); // normal, comfort, auto
} else if (model() == EMSdevice::EMS_DEVICE_FLAG_RC100) { } else if (model() == EMSdevice::EMS_DEVICE_FLAG_RC100) {
has_enumupdate(telegram, dhw->wwMode_, 2, {0, 2, 3}, {0, 0, 1, 2, 0, 0}); // normal, on, auto has_enumupdate(telegram, dhw->wwMode_, 2, {0, 2, 3}); // normal, on, auto
} else { } else {
has_update(telegram, dhw->wwMode_, 2); // 0=off, 1=low, 2=high, 3=auto, 4=own prog has_update(telegram, dhw->wwMode_, 2); // 0=off, 1=low, 2=high, 3=auto, 4=own prog
} }
@@ -4171,6 +4171,10 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
// add the write command to the Tx queue. value is *2 // add the write command to the Tx queue. value is *2
// post validate is the corresponding monitor or set type IDs as they can differ per model // post validate is the corresponding monitor or set type IDs as they can differ per model
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid); write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
// update selTemp now, readback from monitor telegram takes a while
if (mode == HeatingCircuit::Mode::AUTO) {
has_update(hc->selTemp,(int16_t)(temperature * factor));
}
return true; return true;
} }
LOG_DEBUG("temperature mode %d not found", mode); LOG_DEBUG("temperature mode %d not found", mode);