Skip to content

Commit

Permalink
Merge pull request emsesp#2298 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
update for emsesp#2294 and emsesp#2295
  • Loading branch information
proddy authored Dec 19, 2024
2 parents a4733c3 + d7904bd commit 98640c1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ 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

- long numbers of custom entities [#2267](https://github.com/emsesp/EMS-ESP32/issues/2267)
- 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

Expand Down
1 change: 1 addition & 0 deletions src/device_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 22 additions & 11 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@ void Thermostat::process_RC300Set(std::shared_ptr<const Telegram> 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

Expand Down Expand Up @@ -4643,16 +4646,18 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
} else {
register_device_value(tag, &hc->control, 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);
Expand All @@ -4669,7 +4674,13 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
DeviceValueUOM::NONE,
MAKE_CF_CB(set_switchProgMode));

register_device_value(tag, &hc->redThreshold, 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);
Expand Down
11 changes: 8 additions & 3 deletions src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion src/modbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.2-dev.5"
#define EMSESP_APP_VERSION "3.7.2-dev.6"

0 comments on commit 98640c1

Please sign in to comment.