diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 1ebd80cd7..da1031200 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -13,6 +13,7 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/). - Mask bits for bool custom entities - thermostat `reduce threshold` [#2288](https://github.com/emsesp/EMS-ESP32/issues/2288) - thermostat `absent` [#1957](https://github.com/emsesp/EMS-ESP32/issues/1957) +- CR11 thermostat [#2295](https://github.com/emsesp/EMS-ESP32/issues/2295) ## Fixed @@ -20,6 +21,7 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/). - modbus command path to `api/` [#2276](https://github.com/emsesp/EMS-ESP32/issues/2276) - info command for devices without entity-commands [#2274](https://github.com/emsesp/EMS-ESP32/issues/2274) - CW100 settings telegram 0x241 [#2290](https://github.com/emsesp/EMS-ESP32/issues/2290) +- modbus signed 8bit values [#2294](https://github.com/emsesp/EMS-ESP32/issues/2294) ## Changed diff --git a/src/device_library.h b/src/device_library.h index e3a5c1d67..4d4ebb457 100644 --- a/src/device_library.h +++ b/src/device_library.h @@ -82,6 +82,7 @@ // Thermostat - Buderus/Nefit/Bosch specific - 0x17 / 0x10 / 0x18 / 0x19-0x1B for hc2-4 / 0x38 { 4, DeviceType::THERMOSTAT, "UI800, BC400", DeviceFlags::EMS_DEVICE_FLAG_BC400}, // 0x10 +{ 10, DeviceType::THERMOSTAT, "CR11", DeviceFlags::EMS_DEVICE_FLAG_RC100}, // 0x18 { 65, DeviceType::THERMOSTAT, "RC10", DeviceFlags::EMS_DEVICE_FLAG_RC20_N},// 0x17 { 67, DeviceType::THERMOSTAT, "RC30", DeviceFlags::EMS_DEVICE_FLAG_RC30_N},// 0x10 - based on RC35 { 77, DeviceType::THERMOSTAT, "RC20, Moduline 300", DeviceFlags::EMS_DEVICE_FLAG_RC20},// 0x17 diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 84f049a70..e2fce386f 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1112,6 +1112,9 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { // set mode for CR120, BC400, https://github.com/emsesp/EMS-ESP32/discussions/1779 has_update(telegram, hc->mode_new, 21); // for BC400, CR120 has_bitupdate(telegram, hc->mode, 0, 0); // RC300, RC100 + if (hc->mode == EMS_VALUE_UINT8_NOTSET) { + has_update(hc->mode, 0); // set manual for CR11 + } has_update(telegram, hc->daytemp, 2); // is * 2 has_update(telegram, hc->nighttemp, 4); // is * 2 @@ -4643,16 +4646,18 @@ void Thermostat::register_device_values_hc(std::shared_ptrcontrol, DeviceValueType::ENUM, FL_(enum_control1), FL_(control), DeviceValueUOM::NONE, MAKE_CF_CB(set_control)); } - register_device_value(tag, - &hc->remotetemp, - DeviceValueType::CMD, - DeviceValueNumOp::DV_NUMOP_DIV10, - FL_(remotetemp), - DeviceValueUOM::DEGREES, - MAKE_CF_CB(set_remotetemp), - -1, - 101); - register_device_value(tag, &hc->remotehum, DeviceValueType::CMD, FL_(remotehum), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_remotehum), -1, 101); + if (model != EMSdevice::EMS_DEVICE_FLAG_RC100 && model != EMSdevice::EMS_DEVICE_FLAG_CR120) { + register_device_value(tag, + &hc->remotetemp, + DeviceValueType::CMD, + DeviceValueNumOp::DV_NUMOP_DIV10, + FL_(remotetemp), + DeviceValueUOM::DEGREES, + MAKE_CF_CB(set_remotetemp), + -1, + 101); + register_device_value(tag, &hc->remotehum, DeviceValueType::CMD, FL_(remotehum), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_remotehum), -1, 101); + } register_device_value(tag, &hc->heatondelay, DeviceValueType::UINT8, FL_(heatondelay), DeviceValueUOM::HOURS, MAKE_CF_CB(set_heatondelay), 1, 48); register_device_value(tag, &hc->heatoffdelay, DeviceValueType::UINT8, FL_(heatoffdelay), DeviceValueUOM::HOURS, MAKE_CF_CB(set_heatoffdelay), 1, 48); register_device_value(tag, &hc->instantstart, DeviceValueType::UINT8, FL_(instantstart), DeviceValueUOM::K, MAKE_CF_CB(set_instantstart), 1, 10); @@ -4669,7 +4674,13 @@ void Thermostat::register_device_values_hc(std::shared_ptrredThreshold, DeviceValueType::INT8, DeviceValueNumOp::DV_NUMOP_DIV2, FL_(redthreshold), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_redthreshold)); + register_device_value(tag, + &hc->redThreshold, + DeviceValueType::INT8, + DeviceValueNumOp::DV_NUMOP_DIV2, + FL_(redthreshold), + DeviceValueUOM::DEGREES, + MAKE_CF_CB(set_redthreshold)); break; case EMSdevice::EMS_DEVICE_FLAG_CRF: register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode5), FL_(mode), DeviceValueUOM::NONE); diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 8d0cf694b..648b85f92 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1188,7 +1188,7 @@ void EMSdevice::setValueEnum(const void * value_p, const char * const ** options if (dv.options != options && Mqtt::ha_enabled()) { dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED); } - dv.options = options; + dv.options = options; dv.options_size = Helpers::count_items(options); break; } @@ -2063,7 +2063,7 @@ int EMSdevice::get_modbus_value(uint8_t tag, const std::string & shortname, std: else if (dv.type == DeviceValueType::INT8) { if (result.size() != 1) return -8; - result[0] = (uint16_t)(uint8_t)(*(int8_t *)(dv.value_p)); + result[0] = (uint16_t)(int16_t)(*(int8_t *)(dv.value_p)); } else if (dv.type == DeviceValueType::UINT8) { if (result.size() != 1) return -9; @@ -2136,7 +2136,12 @@ int EMSdevice::modbus_value_to_json(uint8_t tag, const std::string & shortname, return -4; } - jsonValue["value"] = Helpers::numericoperator2scalefactor(dv.numeric_operator) * (float)((uint16_t)modbus_data[0] << 8 | (uint16_t)modbus_data[1]); + if (dv.type == DeviceValueType::INT8 || dv.type == DeviceValueType::INT16) { // handle signed + jsonValue["value"] = + Helpers::numericoperator2scalefactor(dv.numeric_operator) * (float)(int16_t)((uint16_t)modbus_data[0] << 8 | (uint16_t)modbus_data[1]); + } else { + jsonValue["value"] = Helpers::numericoperator2scalefactor(dv.numeric_operator) * (float)((uint16_t)modbus_data[0] << 8 | (uint16_t)modbus_data[1]); + } } else if (dv.type == DeviceValueType::UINT24 || dv.type == DeviceValueType::UINT32 || dv.type == DeviceValueType::TIME) { // these data types are 2 16 bit register if (modbus_data.size() != 4) { diff --git a/src/modbus.cpp b/src/modbus.cpp index 0c0432a15..5ed595590 100644 --- a/src/modbus.cpp +++ b/src/modbus.cpp @@ -310,8 +310,11 @@ ModbusMessage Modbus::handleRead(const ModbusMessage & request) { } } if (error_code) { - LOG_ERROR("Unable to read raw device value %s for tag=%d - error_code = %d", modbusInfo->short_name, (int)tag, error_code); + if (uuid::get_uptime_sec() > 60 || error_code < -2) { // suppress not found messages for the first minute + LOG_ERROR("Unable to read raw device value %s for tag=%d - error_code = %d", modbusInfo->short_name, (int)tag, error_code); + } response.setError(request.getServerID(), request.getFunctionCode(), SERVER_DEVICE_FAILURE); + return response; } response.add(request.getServerID()); diff --git a/src/version.h b/src/version.h index 4d2245b33..b9f8ad86a 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.7.2-dev.5" \ No newline at end of file +#define EMSESP_APP_VERSION "3.7.2-dev.6" \ No newline at end of file