diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index f0bd83f6a..528d36a8e 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -671,11 +671,13 @@ std::shared_ptr Thermostat::heating_circuit(std::sha // create a new heating circuit object heating_circuits_.emplace_back(new HeatingCircuit(hc_num, monitor_typeids[hc_num - 1], set_typeids[hc_num - 1])); + std::sort(heating_circuits_.begin(), heating_circuits_.end()); // sort based on hc number + // set the flag saying we want its data during the next auto fetch toggle_fetch(monitor_typeids[hc_num - 1], true); toggle_fetch(set_typeids[hc_num - 1], true); - return heating_circuits_.back(); + return heating_circuits_.back(); // even after sorting, this should still point back to the newly created HC } // decodes the thermostat mode for the heating circuit based on the thermostat type @@ -874,6 +876,8 @@ void Thermostat::show_values(uuid::console::Shell & shell) { } } + // std::sort(heating_circuits_.begin(), heating_circuits_.end()); // sort based on hc number. This has moved to the heating_circuit() function + for (const auto & hc : heating_circuits_) { shell.printfln(F(" Heating Circuit %d:"), hc->hc_num()); @@ -1020,17 +1024,35 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr telegram // type 0x02A5 - data from the Nefit RC1010/3000 thermostat (0x18) and RC300/310s on 0x10 void Thermostat::process_RC300Monitor(std::shared_ptr telegram) { + // can't remember why this is here? if (telegram->message_data[2] == 0x00) { return; } + std::shared_ptr hc = heating_circuit(telegram); - telegram->read_value(hc->curr_roomTemp, 0); // is * 10 + + // if current room temp starts with 0x90 it's usually trouble + if (telegram->message_data[0] != 0x90) { + telegram->read_value(hc->curr_roomTemp, 0); // is * 10 + } + telegram->read_value(hc->mode_type, 10, 1); telegram->read_value(hc->mode, 10, 0); // bit 1, mode (auto=1 or manual=0) - // setpoint is in offset 3 and also 7. We're sticking to 3 for now. - // also ignore if its 0 - see https://github.com/proddy/EMS-ESP/issues/256#issuecomment-585171426 - telegram->read_value8(hc->setpoint_roomTemp, 3); // is * 2, force as single byte + // if manual, take the current setpoint temp at pos 6 + // if auto, take the next setpoint temp at pos 7 + // pos 3 is the current target temp and sometimes can be 0 + // see https://github.com/proddy/EMS-ESP/issues/256#issuecomment-585171426 + uint8_t pos; + if (hc->mode == 0) { // manual + pos = 6; + } else if (hc->mode == 1) { // auto + pos = 7; + } else { + pos = 3; + } + + telegram->read_value8(hc->setpoint_roomTemp, pos); // is * 2, force as single byte } // type 0x02B9 EMS+ for reading from RC300/RC310 thermostat diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 018daf8f9..962de4632 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -62,7 +62,6 @@ class Thermostat : public EMSdevice { uint8_t designtemp = EMS_VALUE_UINT_NOTSET; // heatingcurve design temp at MinExtTemp int8_t offsettemp = EMS_VALUE_INT_NOTSET; // heatingcurve offest temp at roomtemp signed! - uint8_t hc_num() const { return hc_num_; } @@ -80,13 +79,17 @@ class Thermostat : public EMSdevice { enum Mode : uint8_t { UNKNOWN, OFF, MANUAL, AUTO, DAY, NIGHT, HEAT, NOFROST, ECO, HOLIDAY, COMFORT, OFFSET, DESIGN, SUMMER }; + // for sorting + friend inline bool operator<(const std::shared_ptr & lhs, const std::shared_ptr & rhs) { + return (lhs->hc_num_ < rhs->hc_num_); + } + private: uint8_t hc_num_; uint16_t monitor_typeid_; uint16_t set_typeid_; }; - std::string mode_tostring(uint8_t mode) const; virtual void show_values(uuid::console::Shell & shell);