mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix thermostat flag detection - #537
This commit is contained in:
@@ -131,7 +131,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
|
||||
register_telegram_type(monitor_typeids[i], F("JunkersMonitor"), false, [&](std::shared_ptr<const Telegram> t) { process_JunkersMonitor(t); });
|
||||
register_telegram_type(set_typeids[i], F("JunkersSet"), false, [&](std::shared_ptr<const Telegram> t) { process_JunkersSet(t); });
|
||||
}
|
||||
|
||||
// JUNKERS/HT3 older models
|
||||
} else if (model == (EMSdevice::EMS_DEVICE_FLAG_JUNKERS | EMSdevice::EMS_DEVICE_FLAG_JUNKERS_2)) {
|
||||
monitor_typeids = {0x016F, 0x0170, 0x0171, 0x0172};
|
||||
set_typeids = {0x0179, 0x017A, 0x017B, 0x017C};
|
||||
@@ -1671,7 +1671,7 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
|
||||
}
|
||||
break;
|
||||
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS:
|
||||
if ((this->flags() & EMS_DEVICE_FLAG_JUNKERS_2) == EMS_DEVICE_FLAG_JUNKERS_2) {
|
||||
if (this->has_flags(EMS_DEVICE_FLAG_JUNKERS_2)) {
|
||||
offset = EMS_OFFSET_JunkersSetMessage2_set_mode;
|
||||
} else {
|
||||
offset = EMS_OFFSET_JunkersSetMessage_set_mode;
|
||||
@@ -1882,7 +1882,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
} else if (model == EMS_DEVICE_FLAG_JUNKERS) {
|
||||
// figure out if we have older or new thermostats, Heating Circuits on 0x65 or 0x79
|
||||
// see https://github.com/proddy/EMS-ESP/issues/335#issuecomment-593324716)
|
||||
bool old_junkers = ((this->flags() & EMS_DEVICE_FLAG_JUNKERS_2) == EMS_DEVICE_FLAG_JUNKERS_2);
|
||||
bool old_junkers = (this->has_flags(EMS_DEVICE_FLAG_JUNKERS_2));
|
||||
if (!old_junkers) {
|
||||
switch (mode) {
|
||||
case HeatingCircuit::Mode::NOFROST:
|
||||
|
||||
@@ -110,9 +110,9 @@ class Thermostat : public EMSdevice {
|
||||
bool export_values_main(JsonObject & doc);
|
||||
bool export_values_hc(uint8_t mqtt_format, JsonObject & doc);
|
||||
|
||||
// specific thermostat characteristics, stripping the option bits at pos 6 and 7
|
||||
// specific thermostat characteristics, stripping the write option at bit 7
|
||||
inline uint8_t model() const {
|
||||
return (this->flags() & 0x0F);
|
||||
return (this->flags() & 0x7F);
|
||||
}
|
||||
|
||||
// each thermostat has a list of heating controller type IDs for reading and writing
|
||||
|
||||
@@ -67,14 +67,19 @@ class EMSdevice {
|
||||
return ((device_id & 0x7F) == (device_id_ & 0x7F));
|
||||
}
|
||||
|
||||
inline void add_flags(uint8_t flags) {
|
||||
flags_ |= flags;
|
||||
}
|
||||
inline bool has_flags(uint8_t flags) const {
|
||||
return (flags_ & flags) == flags;
|
||||
}
|
||||
inline void remove_flags(uint8_t flags) {
|
||||
flags_ &= ~flags;
|
||||
}
|
||||
inline uint8_t flags() const {
|
||||
return flags_;
|
||||
}
|
||||
|
||||
inline void flags(uint8_t flags) {
|
||||
flags_ = flags;
|
||||
}
|
||||
|
||||
// see enum DeviceType below
|
||||
inline uint8_t device_type() const {
|
||||
return device_type_;
|
||||
|
||||
@@ -652,7 +652,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
|
||||
for (const auto & device : device_library_) {
|
||||
if (device.product_id == product_id) {
|
||||
emsdevice->name(uuid::read_flash_string(device.name));
|
||||
emsdevice->flags(device.flags);
|
||||
emsdevice->add_flags(device.flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace emsesp {
|
||||
// used with the 'test' command, under su/admin
|
||||
void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
||||
if (command == "default") {
|
||||
run_test(shell, "web"); // add the default test case here
|
||||
run_test(shell, "fr120"); // add the default test case here
|
||||
}
|
||||
|
||||
if (command.empty()) {
|
||||
@@ -278,6 +278,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
||||
0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
|
||||
|
||||
shell.invoke_command("show");
|
||||
shell.invoke_command("show devices");
|
||||
}
|
||||
|
||||
if (command == "thermostat") {
|
||||
|
||||
Reference in New Issue
Block a user