fix thermostat flag detection - #537

This commit is contained in:
proddy
2020-10-08 10:03:01 +02:00
parent 99880cea2f
commit 7d5a654f52
5 changed files with 17 additions and 11 deletions

View File

@@ -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(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); }); 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)) { } else if (model == (EMSdevice::EMS_DEVICE_FLAG_JUNKERS | EMSdevice::EMS_DEVICE_FLAG_JUNKERS_2)) {
monitor_typeids = {0x016F, 0x0170, 0x0171, 0x0172}; monitor_typeids = {0x016F, 0x0170, 0x0171, 0x0172};
set_typeids = {0x0179, 0x017A, 0x017B, 0x017C}; 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; break;
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS: 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; offset = EMS_OFFSET_JunkersSetMessage2_set_mode;
} else { } else {
offset = EMS_OFFSET_JunkersSetMessage_set_mode; 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) { } else if (model == EMS_DEVICE_FLAG_JUNKERS) {
// figure out if we have older or new thermostats, Heating Circuits on 0x65 or 0x79 // 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) // 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) { if (!old_junkers) {
switch (mode) { switch (mode) {
case HeatingCircuit::Mode::NOFROST: case HeatingCircuit::Mode::NOFROST:

View File

@@ -110,9 +110,9 @@ class Thermostat : public EMSdevice {
bool export_values_main(JsonObject & doc); bool export_values_main(JsonObject & doc);
bool export_values_hc(uint8_t mqtt_format, 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 { 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 // each thermostat has a list of heating controller type IDs for reading and writing

View File

@@ -67,14 +67,19 @@ class EMSdevice {
return ((device_id & 0x7F) == (device_id_ & 0x7F)); 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 { inline uint8_t flags() const {
return flags_; return flags_;
} }
inline void flags(uint8_t flags) {
flags_ = flags;
}
// see enum DeviceType below // see enum DeviceType below
inline uint8_t device_type() const { inline uint8_t device_type() const {
return device_type_; return device_type_;

View File

@@ -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_) { for (const auto & device : device_library_) {
if (device.product_id == product_id) { if (device.product_id == product_id) {
emsdevice->name(uuid::read_flash_string(device.name)); emsdevice->name(uuid::read_flash_string(device.name));
emsdevice->flags(device.flags); emsdevice->add_flags(device.flags);
} }
} }

View File

@@ -28,7 +28,7 @@ namespace emsesp {
// used with the 'test' command, under su/admin // used with the 'test' command, under su/admin
void Test::run_test(uuid::console::Shell & shell, const std::string & command) { void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
if (command == "default") { 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()) { 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}); 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
shell.invoke_command("show"); shell.invoke_command("show");
shell.invoke_command("show devices");
} }
if (command == "thermostat") { if (command == "thermostat") {