From 85a12bf581cb02bfcdde71c5212094f95e148a79 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 16 May 2026 15:45:14 +0200 Subject: [PATCH] add const --- src/core/analogsensor.h | 4 +- src/core/command.h | 2 +- src/core/emsdevice.h | 40 +++++---- src/core/emsesp.cpp | 12 +-- src/core/mqtt.h | 6 +- src/core/temperaturesensor.h | 2 +- src/devices/alert.cpp | 2 +- src/devices/alert.h | 2 +- src/devices/boiler.h | 112 ++++++++++++------------- src/devices/connect.cpp | 16 ++-- src/devices/connect.h | 16 ++-- src/devices/controller.cpp | 2 +- src/devices/controller.h | 2 +- src/devices/extension.cpp | 12 +-- src/devices/extension.h | 12 +-- src/devices/heatpump.cpp | 26 +++--- src/devices/heatpump.h | 26 +++--- src/devices/heatsource.cpp | 14 ++-- src/devices/heatsource.h | 14 ++-- src/devices/mixer.cpp | 18 ++-- src/devices/mixer.h | 18 ++-- src/devices/pool.cpp | 2 +- src/devices/pool.h | 2 +- src/devices/solar.h | 40 ++++----- src/devices/switch.cpp | 6 +- src/devices/switch.h | 6 +- src/devices/thermostat.cpp | 128 +++++++++++++++-------------- src/devices/thermostat.h | 122 +++++++++++++-------------- src/devices/ventilation.cpp | 12 +-- src/devices/ventilation.h | 12 +-- src/devices/water.cpp | 30 +++---- src/devices/water.h | 30 +++---- src/web/WebCustomEntityService.cpp | 2 +- src/web/WebCustomEntityService.h | 2 +- src/web/WebDataService.cpp | 2 +- 35 files changed, 384 insertions(+), 370 deletions(-) diff --git a/src/core/analogsensor.h b/src/core/analogsensor.h index 65e200662..6492e2c8a 100644 --- a/src/core/analogsensor.h +++ b/src/core/analogsensor.h @@ -146,7 +146,7 @@ class AnalogSensor { bool updated_values(); // return back reference to the sensor list, used by other classes - std::vector> sensors() const { + const std::vector> & sensors() const { return sensors_; } @@ -178,7 +178,7 @@ class AnalogSensor { bool get_value_info(JsonObject output, const char * cmd, const int8_t id = -1); void store_counters(); std::string get_metrics_prometheus(); - static std::vector exclude_types() { + static const std::vector & exclude_types() { return exclude_types_; } diff --git a/src/core/command.h b/src/core/command.h index 6ab6b1230..2c9cffc91 100644 --- a/src/core/command.h +++ b/src/core/command.h @@ -98,7 +98,7 @@ class Command { } }; - static std::vector> commands() { + static const std::vector> & commands() { return cmdfunctions_; } diff --git a/src/core/emsdevice.h b/src/core/emsdevice.h index 793313f3d..0f10a9f06 100644 --- a/src/core/emsdevice.h +++ b/src/core/emsdevice.h @@ -34,7 +34,7 @@ class EMSdevice { public: virtual ~EMSdevice() = default; // destructor of base class must always be virtual because it's a polymorphic class - using process_function_p = std::function)>; + using process_function_p = std::function &)>; // device_type defines which derived class to use, e.g. BOILER, THERMOSTAT etc.. EMSdevice(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * default_name, uint8_t flags, uint8_t brand) @@ -64,6 +64,10 @@ class EMSdevice { bool has_tags(const int8_t tag) const; bool has_cmd(const char * cmd, const int8_t id) const; std::string brand_to_char(); + // Same as brand_to_char() but returns a const char* (flash literal or + // custom_brand_.c_str()) without allocating a std::string. Lifetime is + // tied to this EMSdevice instance. + const char * brand_to_cstr() const; std::string to_string(); std::string to_string_short(); std::string to_string_version(); @@ -125,7 +129,7 @@ class EMSdevice { custom_name_ = custom_name; } - std::string custom_name() const { + const std::string & custom_name() const { return custom_name_; } @@ -134,7 +138,7 @@ class EMSdevice { custom_brand_ = custom_brand; } - std::string custom_brand() const { + const std::string & custom_brand() const { return custom_brand_; } // set device model @@ -142,7 +146,7 @@ class EMSdevice { model_ = model; } - std::string model() const { + const std::string & model() const { return model_; } @@ -207,14 +211,14 @@ class EMSdevice { } } - void has_enumupdate(std::shared_ptr telegram, uint8_t & value, const uint8_t index, int8_t s = 0) { + void has_enumupdate(const std::shared_ptr & telegram, uint8_t & value, const uint8_t index, int8_t s = 0) { if (telegram->read_enumvalue(value, index, s)) { has_update_ = true; publish_value((void *)&value); } } - void has_enumupdate(std::shared_ptr telegram, uint8_t & value, const uint8_t index, const std::vector & maskIn) { + void has_enumupdate(const std::shared_ptr & telegram, uint8_t & value, const uint8_t index, const std::vector & maskIn) { uint8_t val = value < maskIn.size() ? maskIn[value] : EMS_VALUE_UINT8_NOTSET; if (telegram->read_value(val, index)) { for (uint8_t i = 0; i < maskIn.size(); i++) { @@ -229,7 +233,7 @@ class EMSdevice { } template - void has_update(std::shared_ptr telegram, Value & value, const uint8_t index, uint8_t s = 0) { + void has_update(const std::shared_ptr & telegram, Value & value, const uint8_t index, uint8_t s = 0) { if (telegram->read_value(value, index, s)) { has_update_ = true; publish_value((void *)&value); @@ -237,7 +241,7 @@ class EMSdevice { } template - void has_bitupdate(std::shared_ptr telegram, BitValue & value, const uint8_t index, uint8_t b) { + void has_bitupdate(const std::shared_ptr & telegram, BitValue & value, const uint8_t index, uint8_t b) { if (telegram->read_bitvalue(value, index, b)) { has_update_ = true; publish_value((void *)&value); @@ -260,7 +264,7 @@ class EMSdevice { void getCustomizationEntities(std::vector & entity_ids); void register_telegram_type(const uint16_t telegram_type_id, const char * telegram_type_name, bool fetch, const process_function_p cb, uint8_t length = 0); - bool handle_telegram(std::shared_ptr telegram); + bool handle_telegram(const std::shared_ptr & telegram); std::string get_value_uom(const std::string & shortname) const; bool get_value_info(JsonObject root, const char * cmd, const int8_t id); @@ -359,7 +363,7 @@ class EMSdevice { void publish_value(void * value_p) const; void publish_all_values(); void mqtt_ha_entity_config_create(); - const char * telegram_type_name(std::shared_ptr telegram); + const char * telegram_type_name(const std::shared_ptr & telegram); void fetch_values(); void toggle_fetch(uint16_t telegram_id, bool toggle); bool is_fetch(uint16_t telegram_id, uint8_t len = 0) const; @@ -518,13 +522,17 @@ class EMSdevice { uint8_t count_entities_fav(); bool has_entities() const; - // void reserve_device_values(uint8_t elements) { - // devicevalues_.reserve(elements); - // } + // Pre-allocate vector capacity to avoid realloc storms during device + // construction. Realloc here is especially expensive because each entry + // contains a std::function (heap-allocated functor) and DeviceValue + // (with std::string member), so growing copies a lot. + void reserve_device_values(uint16_t elements) { + devicevalues_.reserve(elements); + } - // void reserve_telegram_functions(uint8_t elements) { - // telegram_functions_.reserve(elements); - // } + void reserve_telegram_functions(uint8_t elements) { + telegram_functions_.reserve(elements); + } #if defined(EMSESP_STANDALONE) struct TelegramFunctionDump { diff --git a/src/core/emsesp.cpp b/src/core/emsesp.cpp index 65994edd2..5055e1af4 100644 --- a/src/core/emsesp.cpp +++ b/src/core/emsesp.cpp @@ -701,7 +701,7 @@ void EMSESP::publish_sensor_values(const bool time, const bool force) { } // MQTT publish a telegram as raw data to the topic 'response' -void EMSESP::publish_response(std::shared_ptr telegram) { +void EMSESP::publish_response(const std::shared_ptr & telegram) { static char * buffer = nullptr; static uint8_t offset = 0; static uint16_t type = 0; @@ -815,7 +815,7 @@ std::string EMSESP::device_tostring(const uint8_t device_id) { // create a pretty print telegram as a text string // e.g. Boiler(0x08) -> Me(0x0B), Version(0x02), data: 7B 06 01 00 00 00 00 00 00 04 (offset 1) -std::string EMSESP::pretty_telegram(std::shared_ptr telegram) { +std::string EMSESP::pretty_telegram(const std::shared_ptr & telegram) { uint8_t src = telegram->src & 0x7F; uint8_t dest = telegram->dest & 0x7F; uint8_t offset = telegram->offset; @@ -975,7 +975,7 @@ std::string EMSESP::pretty_telegram(std::shared_ptr telegram) { * e.g. in example above 1st byte = x0B = b1011 so we have deviceIDs 0x08, 0x09, 0x011 * and 2nd byte = x80 = b1000 b0000 = deviceID 0x17 */ -void EMSESP::process_UBADevices(std::shared_ptr telegram) { +void EMSESP::process_UBADevices(const std::shared_ptr & telegram) { // exit it length is incorrect (must be 13 or 15 bytes long) if (telegram->message_length > 15) { return; @@ -1001,7 +1001,7 @@ void EMSESP::process_UBADevices(std::shared_ptr telegram) { } // read deviceName from telegram 0x01 offset 27 and set it to custom name -void EMSESP::process_deviceName(std::shared_ptr telegram) { +void EMSESP::process_deviceName(const std::shared_ptr & telegram) { // exit if only part of name fields if (telegram->offset > 27 || (telegram->offset + telegram->message_length) < 29) { return; @@ -1029,7 +1029,7 @@ void EMSESP::process_deviceName(std::shared_ptr telegram) { // process the Version telegram (type 0x02), which is a common type // e.g. 09 0B 02 00 PP V1 V2 -void EMSESP::process_version(std::shared_ptr telegram) { +void EMSESP::process_version(const std::shared_ptr & telegram) { // check for valid telegram, just in case if (telegram->offset != 0) { return; @@ -1087,7 +1087,7 @@ void EMSESP::process_version(std::shared_ptr telegram) { // but only process if the telegram is sent to us or it's a broadcast (dest=0x00=all) // We also check for common telegram types, like the Version(0x02) // returns false if there are none found -bool EMSESP::process_telegram(std::shared_ptr telegram) { +bool EMSESP::process_telegram(const std::shared_ptr & telegram) { // if watching or reading... if ((telegram->type_id == read_id_ || telegram->type_id == response_id_) && (telegram->dest == EMSbus::ems_bus_id())) { if (telegram->type_id == response_id_) { diff --git a/src/core/mqtt.h b/src/core/mqtt.h index bd785625d..21a1cfcc7 100644 --- a/src/core/mqtt.h +++ b/src/core/mqtt.h @@ -146,11 +146,11 @@ class Mqtt { mqtt_enabled_ = mqtt_enabled; } - static std::string base() { + static const std::string & base() { return mqtt_base_; } - static std::string basename() { + static const std::string & basename() { return mqtt_basename_; } @@ -227,7 +227,7 @@ class Mqtt { ha_enabled_ = ha_enabled; } - static std::string get_response() { + static const std::string & get_response() { return lastresponse_; } diff --git a/src/core/temperaturesensor.h b/src/core/temperaturesensor.h index a4aa63dfe..ee141d353 100644 --- a/src/core/temperaturesensor.h +++ b/src/core/temperaturesensor.h @@ -99,7 +99,7 @@ class TemperatureSensor { std::string get_metrics_prometheus(); // return back reference to the sensor list, used by other classes - std::vector> sensors() const { + const std::vector> & sensors() const { return sensors_; } diff --git a/src/devices/alert.cpp b/src/devices/alert.cpp index e4ecf5ddf..5d71579c6 100644 --- a/src/devices/alert.cpp +++ b/src/devices/alert.cpp @@ -33,7 +33,7 @@ Alert::Alert(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setBurnPow_, DeviceValueType::UINT8, FL_(setBurnPow), DeviceValueUOM::PERCENT); } // UBASetPoint 0x1A -void Alert::process_UBASetPoints(std::shared_ptr telegram) { +void Alert::process_UBASetPoints(const std::shared_ptr & telegram) { has_update(telegram, setFlowTemp_, 0); // boiler set temp from thermostat has_update(telegram, setBurnPow_, 1); // max burner power in % } diff --git a/src/devices/alert.h b/src/devices/alert.h index d818aca09..1d3cfa3fd 100644 --- a/src/devices/alert.h +++ b/src/devices/alert.h @@ -28,7 +28,7 @@ class Alert : public EMSdevice { Alert(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand); private: - void process_UBASetPoints(std::shared_ptr telegram); + void process_UBASetPoints(const std::shared_ptr & telegram); uint8_t setFlowTemp_; // boiler setpoint temp uint8_t setBurnPow_; // Burner power % diff --git a/src/devices/boiler.h b/src/devices/boiler.h index c0b7dab9b..e0900cfe3 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -349,65 +349,65 @@ class Boiler : public EMSdevice { uint8_t delayBoiler_; // minutes uint8_t tempDiffBoiler_; // relative temperature degrees */ - void process_UBAFactory(std::shared_ptr telegram); - void process_UBAParameterWW(std::shared_ptr telegram); - void process_UBAMonitorFast(std::shared_ptr telegram); - void process_UBATotalUptime(std::shared_ptr telegram); - void process_UBAParameters(std::shared_ptr telegram); - void process_UBAMonitorWW(std::shared_ptr telegram); - void process_UBAMonitorFastPlus(std::shared_ptr telegram); - void process_UBAMonitorSlow(std::shared_ptr telegram); - void process_UBAMonitorSlowPlus(std::shared_ptr telegram); - void process_UBAMonitorSlowPlus2(std::shared_ptr telegram); - void process_UBAParametersPlus(std::shared_ptr telegram); - void process_UBAParameterWWPlus(std::shared_ptr telegram); - void process_UBAOutdoorTemp(std::shared_ptr telegram); - void process_UBASetPoints(std::shared_ptr telegram); - void process_UBASetPoints2(std::shared_ptr telegram); - void process_UBAFlags(std::shared_ptr telegram); - void process_MC110Status(std::shared_ptr telegram); - void process_UBAMaintenanceStatus(std::shared_ptr telegram); - void process_UBAMaintenanceData(std::shared_ptr telegram); - void process_ErrorMessage(std::shared_ptr telegram); - void process_UBAErrorMessage(std::shared_ptr telegram); - void process_UBAErrorMessage2(std::shared_ptr telegram); - void process_UBAErrorMessage3(std::shared_ptr telegram); - void process_UBAMonitorWWPlus(std::shared_ptr telegram); - void process_UBAInformation(std::shared_ptr telegram); - void process_UBAEnergySupplied(std::shared_ptr telegram); - void process_CascadeMessage(std::shared_ptr telegram); - void process_UBASettingsWW(std::shared_ptr telegram); - void process_HpPower(std::shared_ptr telegram); - void process_HpTemperatures(std::shared_ptr telegram); - void process_HpPool(std::shared_ptr telegram); - void process_HpInput(std::shared_ptr telegram); - void process_HpInConfig(std::shared_ptr telegram); - void process_HpPressure(std::shared_ptr telegram); - void process_HpCooling(std::shared_ptr telegram); - void process_HpHeaterConfig(std::shared_ptr telegram); - void process_HybridHp(std::shared_ptr telegram); - void process_HpSilentMode(std::shared_ptr telegram); - void process_HpAdditionalHeater(std::shared_ptr telegram); - void process_HpValve(std::shared_ptr telegram); - void process_HpPumps(std::shared_ptr telegram); - void process_HpPump2(std::shared_ptr telegram); - void process_HpDhwSettings(std::shared_ptr telegram); - void process_HpSettings2(std::shared_ptr telegram); - void process_HpSettings3(std::shared_ptr telegram); - void process_HpEnergy(std::shared_ptr telegram); - void process_HpMeters(std::shared_ptr telegram); - void process_WeatherComp(std::shared_ptr telegram); - void process_HpFan(std::shared_ptr telegram); - void process_HpPower2(std::shared_ptr telegram); - void process_HpPowerLimit(std::shared_ptr telegram); - void process_PumpKick(std::shared_ptr telegram); + void process_UBAFactory(const std::shared_ptr & telegram); + void process_UBAParameterWW(const std::shared_ptr & telegram); + void process_UBAMonitorFast(const std::shared_ptr & telegram); + void process_UBATotalUptime(const std::shared_ptr & telegram); + void process_UBAParameters(const std::shared_ptr & telegram); + void process_UBAMonitorWW(const std::shared_ptr & telegram); + void process_UBAMonitorFastPlus(const std::shared_ptr & telegram); + void process_UBAMonitorSlow(const std::shared_ptr & telegram); + void process_UBAMonitorSlowPlus(const std::shared_ptr & telegram); + void process_UBAMonitorSlowPlus2(const std::shared_ptr & telegram); + void process_UBAParametersPlus(const std::shared_ptr & telegram); + void process_UBAParameterWWPlus(const std::shared_ptr & telegram); + void process_UBAOutdoorTemp(const std::shared_ptr & telegram); + void process_UBASetPoints(const std::shared_ptr & telegram); + void process_UBASetPoints2(const std::shared_ptr & telegram); + void process_UBAFlags(const std::shared_ptr & telegram); + void process_MC110Status(const std::shared_ptr & telegram); + void process_UBAMaintenanceStatus(const std::shared_ptr & telegram); + void process_UBAMaintenanceData(const std::shared_ptr & telegram); + void process_ErrorMessage(const std::shared_ptr & telegram); + void process_UBAErrorMessage(const std::shared_ptr & telegram); + void process_UBAErrorMessage2(const std::shared_ptr & telegram); + void process_UBAErrorMessage3(const std::shared_ptr & telegram); + void process_UBAMonitorWWPlus(const std::shared_ptr & telegram); + void process_UBAInformation(const std::shared_ptr & telegram); + void process_UBAEnergySupplied(const std::shared_ptr & telegram); + void process_CascadeMessage(const std::shared_ptr & telegram); + void process_UBASettingsWW(const std::shared_ptr & telegram); + void process_HpPower(const std::shared_ptr & telegram); + void process_HpTemperatures(const std::shared_ptr & telegram); + void process_HpPool(const std::shared_ptr & telegram); + void process_HpInput(const std::shared_ptr & telegram); + void process_HpInConfig(const std::shared_ptr & telegram); + void process_HpPressure(const std::shared_ptr & telegram); + void process_HpCooling(const std::shared_ptr & telegram); + void process_HpHeaterConfig(const std::shared_ptr & telegram); + void process_HybridHp(const std::shared_ptr & telegram); + void process_HpSilentMode(const std::shared_ptr & telegram); + void process_HpAdditionalHeater(const std::shared_ptr & telegram); + void process_HpValve(const std::shared_ptr & telegram); + void process_HpPumps(const std::shared_ptr & telegram); + void process_HpPump2(const std::shared_ptr & telegram); + void process_HpDhwSettings(const std::shared_ptr & telegram); + void process_HpSettings2(const std::shared_ptr & telegram); + void process_HpSettings3(const std::shared_ptr & telegram); + void process_HpEnergy(const std::shared_ptr & telegram); + void process_HpMeters(const std::shared_ptr & telegram); + void process_WeatherComp(const std::shared_ptr & telegram); + void process_HpFan(const std::shared_ptr & telegram); + void process_HpPower2(const std::shared_ptr & telegram); + void process_HpPowerLimit(const std::shared_ptr & telegram); + void process_PumpKick(const std::shared_ptr & telegram); - void process_Meters(std::shared_ptr telegram); - void process_Energy(std::shared_ptr telegram); + void process_Meters(const std::shared_ptr & telegram); + void process_Energy(const std::shared_ptr & telegram); // HIU - void process_HIUSettings(std::shared_ptr telegram); - void process_HIUMonitor(std::shared_ptr telegram); + void process_HIUSettings(const std::shared_ptr & telegram); + void process_HIUMonitor(const std::shared_ptr & telegram); bool set_keepWarmTemp(const char * value, const int8_t id); bool set_returnTemp(const char * value, const int8_t id); diff --git a/src/devices/connect.cpp b/src/devices/connect.cpp index 1b87a695e..3c289281f 100644 --- a/src/devices/connect.cpp +++ b/src/devices/connect.cpp @@ -59,13 +59,13 @@ Connect::Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, con /* * OutdoorTemp - type 0xD1 - external temperature */ -void Connect::process_OutdoorTemp(std::shared_ptr telegram) { +void Connect::process_OutdoorTemp(const std::shared_ptr & telegram) { has_update(telegram, outdoorTemp_, 0); } // sent if thermostat is connected // https://github.com/emsesp/EMS-ESP32/issues/2277 -void Connect::process_RCTime(std::shared_ptr telegram) { +void Connect::process_RCTime(const std::shared_ptr & telegram) { if (telegram->offset || telegram->message_length < 10) { return; } @@ -121,7 +121,7 @@ std::shared_ptr Connect::room_circuit(const uint8_t num, c } // gateway(0x50) B all(0x00), ?(0x0BDD), data: 00 E6 36 2A -void Connect::process_roomThermostat(std::shared_ptr telegram) { +void Connect::process_roomThermostat(const std::shared_ptr & telegram) { bool create = telegram->offset == 0 && telegram->message_data[0] < 0x80; auto rc = room_circuit(telegram->type_id - 0xBDD, create); if (rc == nullptr) { @@ -147,7 +147,7 @@ void Connect::process_roomThermostat(std::shared_ptr telegram) { // gateway(0x48) W gateway(0x50), ?(0x0B42), data: 01 // icon in offset 0 // gateway(0x48) W gateway(0x50), ?(0x0B42), data: 00 4B 00 FC 00 63 00 68 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (offset 1) -void Connect::process_roomThermostatName(std::shared_ptr telegram) { +void Connect::process_roomThermostatName(const std::shared_ptr & telegram) { auto rc = room_circuit(telegram->type_id - 0xB3D); if (rc == nullptr) { return; @@ -163,7 +163,7 @@ void Connect::process_roomThermostatName(std::shared_ptr telegra // settings 0-mode, 1-tempautotemp, 3 - manualtemp, 6 - ?, 7 - childlock // 0x0BB5, ff: data: 00 FF 00 24 01 FF 24 00 -void Connect::process_roomThermostatSettings(std::shared_ptr telegram) { +void Connect::process_roomThermostatSettings(const std::shared_ptr & telegram) { auto rc = room_circuit(telegram->type_id - 0xBB5); if (rc == nullptr) { return; @@ -176,7 +176,7 @@ void Connect::process_roomThermostatSettings(std::shared_ptr tel } // unknown telegrams, needs fetch -void Connect::process_roomThermostatParam(std::shared_ptr telegram) { +void Connect::process_roomThermostatParam(const std::shared_ptr & telegram) { auto rc = room_circuit(telegram->type_id - 0x1230); if (rc == nullptr) { return; @@ -184,7 +184,7 @@ void Connect::process_roomThermostatParam(std::shared_ptr telegr } // unknown broadcasted telegrams -void Connect::process_roomThermostatData(std::shared_ptr telegram) { +void Connect::process_roomThermostatData(const std::shared_ptr & telegram) { auto rc = room_circuit(telegram->type_id - 0x1244); if (rc == nullptr) { return; @@ -192,7 +192,7 @@ void Connect::process_roomThermostatData(std::shared_ptr telegra } // schedule for all thermostats -void Connect::process_roomSchedule(std::shared_ptr telegram) { +void Connect::process_roomSchedule(const std::shared_ptr & telegram) { uint8_t length = ((telegram->offset + telegram->message_length) > 126) ? 126 - telegram->offset : telegram->message_length; memcpy(&schedule_[telegram->offset], telegram->message_data, length); for (uint8_t c : schedule_) { diff --git a/src/devices/connect.h b/src/devices/connect.h index bbe647119..04c04aef2 100644 --- a/src/devices/connect.h +++ b/src/devices/connect.h @@ -56,12 +56,12 @@ class Connect : public EMSdevice { std::shared_ptr room_circuit(const uint8_t num, const bool create = false); void register_device_values_room(std::shared_ptr room); - void process_roomThermostat(std::shared_ptr telegram); - void process_roomThermostatName(std::shared_ptr telegram); - void process_roomThermostatSettings(std::shared_ptr telegram); - void process_roomThermostatParam(std::shared_ptr telegram); - void process_roomThermostatData(std::shared_ptr telegram); - void process_roomSchedule(std::shared_ptr telegram); + void process_roomThermostat(const std::shared_ptr & telegram); + void process_roomThermostatName(const std::shared_ptr & telegram); + void process_roomThermostatSettings(const std::shared_ptr & telegram); + void process_roomThermostatParam(const std::shared_ptr & telegram); + void process_roomThermostatData(const std::shared_ptr & telegram); + void process_roomSchedule(const std::shared_ptr & telegram); bool set_mode(const char * value, const int8_t id); bool set_seltemp(const char * value, const int8_t id); bool set_name(const char * value, const int8_t id); @@ -70,8 +70,8 @@ class Connect : public EMSdevice { std::vector, AllocatorPSRAM>> room_circuits_; - void process_OutdoorTemp(std::shared_ptr telegram); - void process_RCTime(std::shared_ptr telegram); + void process_OutdoorTemp(const std::shared_ptr & telegram); + void process_RCTime(const std::shared_ptr & telegram); int16_t outdoorTemp_; char dateTime_[25]; // date and time stamp uint8_t schedule_[126]; // telegram copy diff --git a/src/devices/controller.cpp b/src/devices/controller.cpp index 3a4a12efd..5e782ae6f 100644 --- a/src/devices/controller.cpp +++ b/src/devices/controller.cpp @@ -32,7 +32,7 @@ Controller::Controller(uint8_t device_type, uint8_t device_id, uint8_t product_i } // process_dateTime - type 0x06 - date and time from a thermostat - 14 bytes long, IVT only -void Controller::process_dateTime(std::shared_ptr telegram) { +void Controller::process_dateTime(const std::shared_ptr & telegram) { if (telegram->offset > 0 || telegram->message_length < 5) { return; } diff --git a/src/devices/controller.h b/src/devices/controller.h index 404ff1b9c..574591d6a 100644 --- a/src/devices/controller.h +++ b/src/devices/controller.h @@ -27,7 +27,7 @@ class Controller : public EMSdevice { public: Controller(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand); - void process_dateTime(std::shared_ptr telegram); + void process_dateTime(const std::shared_ptr & telegram); char dateTime_[25]; }; diff --git a/src/devices/extension.cpp b/src/devices/extension.cpp index be0f0c2e6..27cf3d416 100644 --- a/src/devices/extension.cpp +++ b/src/devices/extension.cpp @@ -69,7 +69,7 @@ Extension::Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, // extension(0x15) -W-> Me(0x0B), EM100SetMessage(0x0935), data: 00 00 64 50 14 // need to be fetched -void Extension::process_EM100SetMessage(std::shared_ptr telegram) { +void Extension::process_EM100SetMessage(const std::shared_ptr & telegram) { has_update(telegram, minV_, 1); // Input for off, is / 10 has_update(telegram, maxV_, 2); // Input for 100%, is / 10 has_update(telegram, minT_, 3); // min temp @@ -77,22 +77,22 @@ void Extension::process_EM100SetMessage(std::shared_ptr telegram } // extension(0x15) -B-> All(0x00), ?(0x0936), data: 00 00 00 00 28 00 (offset 1) -void Extension::process_EM100OutMessage(std::shared_ptr telegram) { +void Extension::process_EM100OutMessage(const std::shared_ptr & telegram) { has_update(telegram, outPower_, 5); // power monitor % } // extension(0x15) -B-> All(0x00), ?(0x093A), data: 00 00 00 00 00 00 00 00 00 03 01 -void Extension::process_EM100ConfigMessage(std::shared_ptr telegram) { +void Extension::process_EM100ConfigMessage(const std::shared_ptr & telegram) { has_update(telegram, dip_, 9); } // extension(0x15) -B-> All(0x00), ?(0x0938), data: 01 62 -void Extension::process_EM100InputMessage(std::shared_ptr telegram) { +void Extension::process_EM100InputMessage(const std::shared_ptr & telegram) { has_update(telegram, input_, 1); } // extension(0x15) -B-> All(0x00), ?(0x0939), data: 64 4E 00 00 -void Extension::process_EM100MonitorMessage(std::shared_ptr telegram) { +void Extension::process_EM100MonitorMessage(const std::shared_ptr & telegram) { has_update(telegram, setPower_, 0); // percent has_update(telegram, setPoint_, 1); // °C // has_update(telegram, errorState_, 2); // OE1 @@ -100,7 +100,7 @@ void Extension::process_EM100MonitorMessage(std::shared_ptr tele } // extension(0x15) -B-> All(0x00), ?(0x0937), data: 80 00 -void Extension::process_EM100TempMessage(std::shared_ptr telegram) { +void Extension::process_EM100TempMessage(const std::shared_ptr & telegram) { has_update(telegram, headerTemp_, 0); } diff --git a/src/devices/extension.h b/src/devices/extension.h index a6c6c4d5f..bebe897f1 100644 --- a/src/devices/extension.h +++ b/src/devices/extension.h @@ -28,12 +28,12 @@ class Extension : public EMSdevice { Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand); private: - void process_EM100SetMessage(std::shared_ptr telegram); - void process_EM100OutMessage(std::shared_ptr telegram); - void process_EM100MonitorMessage(std::shared_ptr telegram); - void process_EM100TempMessage(std::shared_ptr telegram); - void process_EM100InputMessage(std::shared_ptr telegram); - void process_EM100ConfigMessage(std::shared_ptr telegram); + void process_EM100SetMessage(const std::shared_ptr & telegram); + void process_EM100OutMessage(const std::shared_ptr & telegram); + void process_EM100MonitorMessage(const std::shared_ptr & telegram); + void process_EM100TempMessage(const std::shared_ptr & telegram); + void process_EM100InputMessage(const std::shared_ptr & telegram); + void process_EM100ConfigMessage(const std::shared_ptr & telegram); bool set_minV(const char * value, const int8_t id); bool set_maxV(const char * value, const int8_t id); diff --git a/src/devices/heatpump.cpp b/src/devices/heatpump.cpp index aa59ff97a..db15b7df3 100644 --- a/src/devices/heatpump.cpp +++ b/src/devices/heatpump.cpp @@ -204,7 +204,7 @@ Heatpump::Heatpump(uint8_t device_type, uint8_t device_id, uint8_t product_id, c * Type 0x47B - HeatPump Monitor 2 * e.g. "38 10 FF 00 03 7B 08 24 00 4B" */ -void Heatpump::process_HPMonitor2(std::shared_ptr telegram) { +void Heatpump::process_HPMonitor2(const std::shared_ptr & telegram) { has_update(telegram, dewTemperature_, 0); has_update(telegram, airHumidity_, 1); } @@ -213,13 +213,13 @@ void Heatpump::process_HPMonitor2(std::shared_ptr telegram) { * Type 0x42B- HeatPump Monitor 1 * e.g. "38 10 FF 00 03 2B 00 D1 08 2A 01" */ -void Heatpump::process_HPMonitor1(std::shared_ptr telegram) { +void Heatpump::process_HPMonitor1(const std::shared_ptr & telegram) { // still to implement } // 0x09A0 // Heatpump(0x53) -> All(0x00), ?(0x09A0), data: 02 23 01 3E 01 39 00 5D 01 DE 01 38 00 40 00 5E 00 58 00 3F 01 34 00 02 -void Heatpump::process_HPTemperature(std::shared_ptr telegram) { +void Heatpump::process_HPTemperature(const std::shared_ptr & telegram) { has_update(telegram, hpTc3_, 2); // condenser temp. has_update(telegram, hpTr1_, 8); // compressor temp. has_update(telegram, hpTr3_, 10); // cond. temp. heating @@ -234,7 +234,7 @@ void Heatpump::process_HPTemperature(std::shared_ptr telegram) { // 0x099B // Heatpump(0x53) -> All(0x00), ?(0x099B), data: 80 00 80 00 01 3C 01 38 80 00 80 00 80 00 01 37 00 00 00 00 64 -void Heatpump::process_HPFlowTemp(std::shared_ptr telegram) { +void Heatpump::process_HPFlowTemp(const std::shared_ptr & telegram) { has_update(telegram, flowTemp_, 4); has_update(telegram, retTemp_, 6); has_update(telegram, sysRetTemp_, 14); @@ -243,7 +243,7 @@ void Heatpump::process_HPFlowTemp(std::shared_ptr telegram) { // 0x0998 HPSettings // [emsesp] Heatpump(0x53) -> Me(0x0B), ?(0x0998), data: 00 00 0B 00 00 1F 01 00 01 01 16 06 00 04 02 FF 00 01 7C 01 -void Heatpump::process_HPSettings(std::shared_ptr telegram) { +void Heatpump::process_HPSettings(const std::shared_ptr & telegram) { has_update(telegram, controlStrategy_, 0); has_update(telegram, hybridDHW_, 1); has_update(telegram, energyPriceGas_, 2); @@ -258,14 +258,14 @@ void Heatpump::process_HPSettings(std::shared_ptr telegram) { // 0x099C HPComp // Broadcast (0x099C), data: 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 76 00 00 // data: 00 2B 00 03 04 13 00 00 00 00 00 02 02 02 (offset 24) -void Heatpump::process_HPComp(std::shared_ptr telegram) { +void Heatpump::process_HPComp(const std::shared_ptr & telegram) { has_update(telegram, hpCompSpd_, 15); has_update(telegram, hpPower_, 17); // https://github.com/emsesp/EMS-ESP32/issues/2883 } // 0x999 HPFunctionTest // HPFunctionTest(0x0999), data: 00 00 00 32 00 00 00 00 00 00 00 -void Heatpump::process_HPFunctionTest(std::shared_ptr telegram) { +void Heatpump::process_HPFunctionTest(const std::shared_ptr & telegram) { has_update(telegram, airPurgeMode_, 0); has_update(telegram, heatPumpOutput_, 2); has_update(telegram, coolingCircuit_, 6); @@ -276,7 +276,7 @@ void Heatpump::process_HPFunctionTest(std::shared_ptr telegram) // boiler(0x08) -W-> Me(0x0B), ?(0x04AE), data: 00 00 BD C4 00 00 5B 6A 00 00 00 24 00 00 62 59 00 00 00 00 00 00 00 00 // boiler(0x08) -W-> Me(0x0B), ?(0x04AE), data: 00 00 00 00 00 00 00 00 (offset 24) -void Heatpump::process_HpEnergy(std::shared_ptr telegram) { +void Heatpump::process_HpEnergy(const std::shared_ptr & telegram) { has_update(telegram, nrgTotal_, 0); has_update(telegram, nrgHeat_, 4); has_update(telegram, nrgWw_, 12); @@ -285,7 +285,7 @@ void Heatpump::process_HpEnergy(std::shared_ptr telegram) { // boiler(0x08) -W-> Me(0x0B), ?(0x04AF), data: 00 00 48 B2 00 00 48 55 00 00 00 5D 00 00 01 78 00 00 00 00 00 00 07 61 // boiler(0x08) -W-> Me(0x0B), ?(0x04AF), data: 00 00 24 B0 00 00 00 12 00 00 23 A5 00 00 00 4B 00 00 00 00 00 00 00 00 (offset 24) // boiler(0x08) -W-> Me(0x0B), ?(0x04AF), data: 00 00 00 00 00 00 00 00 (offset 48) -void Heatpump::process_HpMeters(std::shared_ptr telegram) { +void Heatpump::process_HpMeters(const std::shared_ptr & telegram) { has_update(telegram, meterTotal_, 0); has_update(telegram, meterComp_, 4); has_update(telegram, meterEHeat_, 8); @@ -294,14 +294,14 @@ void Heatpump::process_HpMeters(std::shared_ptr telegram) { } // Broadcast (0x099A), data: 05 00 00 00 00 00 00 37 00 00 1D 00 00 52 00 00 13 01 00 01 7C -void Heatpump::process_HpStarts(std::shared_ptr telegram) { +void Heatpump::process_HpStarts(const std::shared_ptr & telegram) { has_update(telegram, hpActivity_, 2); // https://github.com/emsesp/EMS-ESP32/issues/2883 has_update(telegram, heatStartsHp_, 11, 3); has_update(telegram, wwStartsHp_, 14, 3); } // 0x0112E energy consumption -void Heatpump::process_HpEnergy1(std::shared_ptr telegram) { +void Heatpump::process_HpEnergy1(const std::shared_ptr & telegram) { has_update(telegram, fuelHeat_, 3); has_update(telegram, fuelDhw_, 7); has_update(telegram, elHeat_, 11); @@ -309,14 +309,14 @@ void Heatpump::process_HpEnergy1(std::shared_ptr telegram) { } // 0x013B energy generated -void Heatpump::process_HpEnergy2(std::shared_ptr telegram) { +void Heatpump::process_HpEnergy2(const std::shared_ptr & telegram) { has_update(telegram, elGenHeat_, 3); has_update(telegram, elGenDhw_, 7); } // 0x04AA power, Broadcast (0x04AA), data: 00 00 // see https://github.com/emsesp/EMS-ESP32/issues/2883 -void Heatpump::process_HpPower(std::shared_ptr telegram) { +void Heatpump::process_HpPower(const std::shared_ptr & telegram) { has_update(telegram, hpCurrPower_, 0); } diff --git a/src/devices/heatpump.h b/src/devices/heatpump.h index b1c83a0d7..bce29aaa1 100644 --- a/src/devices/heatpump.h +++ b/src/devices/heatpump.h @@ -89,19 +89,19 @@ class Heatpump : public EMSdevice { uint32_t elGenHeat_; uint32_t elGenDhw_; - void process_HPMonitor1(std::shared_ptr telegram); - void process_HPMonitor2(std::shared_ptr telegram); - void process_HPSettings(std::shared_ptr telegram); - void process_HPFunctionTest(std::shared_ptr telegram); - void process_HPTemperature(std::shared_ptr telegram); - void process_HPFlowTemp(std::shared_ptr telegram); - void process_HPComp(std::shared_ptr telegram); - void process_HpEnergy(std::shared_ptr telegram); - void process_HpMeters(std::shared_ptr telegram); - void process_HpStarts(std::shared_ptr telegram); - void process_HpEnergy1(std::shared_ptr telegram); - void process_HpEnergy2(std::shared_ptr telegram); - void process_HpPower(std::shared_ptr telegram); + void process_HPMonitor1(const std::shared_ptr & telegram); + void process_HPMonitor2(const std::shared_ptr & telegram); + void process_HPSettings(const std::shared_ptr & telegram); + void process_HPFunctionTest(const std::shared_ptr & telegram); + void process_HPTemperature(const std::shared_ptr & telegram); + void process_HPFlowTemp(const std::shared_ptr & telegram); + void process_HPComp(const std::shared_ptr & telegram); + void process_HpEnergy(const std::shared_ptr & telegram); + void process_HpMeters(const std::shared_ptr & telegram); + void process_HpStarts(const std::shared_ptr & telegram); + void process_HpEnergy1(const std::shared_ptr & telegram); + void process_HpEnergy2(const std::shared_ptr & telegram); + void process_HpPower(const std::shared_ptr & telegram); bool set_controlStrategy(const char * value, const int8_t id); bool set_lowNoiseMode(const char * value, const int8_t id); diff --git a/src/devices/heatsource.cpp b/src/devices/heatsource.cpp index 1487b5406..ff0f772fe 100644 --- a/src/devices/heatsource.cpp +++ b/src/devices/heatsource.cpp @@ -96,14 +96,14 @@ Heatsource::Heatsource(uint8_t device_type, uint8_t device_id, uint8_t product_i */ // 0x6DC, ff for cascaded heatsources (hs) -void Heatsource::process_CascadeMessage(std::shared_ptr telegram) { +void Heatsource::process_CascadeMessage(const std::shared_ptr & telegram) { telegram->read_value(burnWorkMin_, 3); // this is in seconds burnWorkMin_ /= 60; has_update(burnWorkMin_); } // UBAMonitorFastPlus - type 0xE4 - central heating monitor EMS+ -void Heatsource::process_UBAMonitorFastPlus(std::shared_ptr telegram) { +void Heatsource::process_UBAMonitorFastPlus(const std::shared_ptr & telegram) { has_update(telegram, setFlowTemp_, 6); has_update(telegram, curBurnPow_, 10); has_update(telegram, selBurnPow_, 9); @@ -116,7 +116,7 @@ void Heatsource::process_UBAMonitorFastPlus(std::shared_ptr tele // 0x054D AM200 temperatures // Rx: 60 00 FF 00 04 4D 0103 0108 8000 00C6 0127 0205 8000 0200 0000 8000 6C // TB4 TR2 TA1 TR1 TB1 TB2* TB3 -void Heatsource::process_amTempMessage(std::shared_ptr telegram) { +void Heatsource::process_amTempMessage(const std::shared_ptr & telegram) { has_update(telegram, curFlowTemp_, 0); // TB4 has_update(telegram, retTemp_, 2); // TR2 has_update(telegram, flueGasTemp_, 4); @@ -129,7 +129,7 @@ void Heatsource::process_amTempMessage(std::shared_ptr telegram) // 0x054E AM200 status (6 bytes long) // Rx: 60 00 FF 00 04 4E 00 00 00 00 00 00 86 -void Heatsource::process_amStatusMessage(std::shared_ptr telegram) { +void Heatsource::process_amStatusMessage(const std::shared_ptr & telegram) { has_update(telegram, aPumpMod_, 0); // PR1 // offset 1: bitfield 01-pump on, 02-VR1 opening, 04-VR1 closing, 08-VB1 opening, 10-VB1 closing // actually we dont know the offset of VR2 @@ -143,7 +143,7 @@ void Heatsource::process_amStatusMessage(std::shared_ptr telegra // 0x054C AM200 not broadcasted message, 23 bytes long // data: 00 01 01 00 01 00 41 4B 00 5A 00 5A 00 01 05 3C 00 00 5A 00 01 23 00 -void Heatsource::process_amSettingMessage(std::shared_ptr telegram) { +void Heatsource::process_amSettingMessage(const std::shared_ptr & telegram) { has_update(telegram, vr2Config_, 12); // pos 12: off(00)/bypass(01) has_update(telegram, ahsActivated_, 0); // pos 00: Alternate heat source activation: No(00),Yes(01) has_update(telegram, aPumpConfig_, 4); // pos 04: Buffer primary pump->Config pump: No(00),Yes(01) @@ -164,7 +164,7 @@ void Heatsource::process_amSettingMessage(std::shared_ptr telegr // 0x054F AM200 not broadcasted message, 7 bytes long // Boiler(0x60) -> Me(0x0B), amCommand(0x054F), data: 00 00 00 00 00 00 00 -void Heatsource::process_amCommandMessage(std::shared_ptr telegram) { +void Heatsource::process_amCommandMessage(const std::shared_ptr & telegram) { // pos 0: return pump in percent // pos 3: setValveBuffer VB1 0-off, 1-open, 2-close // pos 2: setValveReturn VR1 0-off, 1-open, 2-close @@ -174,7 +174,7 @@ void Heatsource::process_amCommandMessage(std::shared_ptr telegr // 0x0550 AM200 broadcasted message, all 27 bytes unkown // Rx: 60 00 FF 00 04 50 00 FF 00 FF FF 00 0D 00 01 00 00 00 00 01 03 01 00 03 00 2D 19 C8 02 94 00 4A // Rx: 60 00 FF 19 04 50 00 FF FF 39 -void Heatsource::process_amExtraMessage(std::shared_ptr telegram) { +void Heatsource::process_amExtraMessage(const std::shared_ptr & telegram) { has_update(telegram, blockRemain_, 24); // minutes has_update(telegram, blockRemainWw_, 25); // minutes } diff --git a/src/devices/heatsource.h b/src/devices/heatsource.h index c292cadd8..93f938f13 100644 --- a/src/devices/heatsource.h +++ b/src/devices/heatsource.h @@ -72,14 +72,14 @@ class Heatsource : public EMSdevice { int8_t blockHyst_; // pos 14?: Hyst. for bolier block (K) uint8_t releaseWait_; // pos 15: Boiler release wait time (min) - void process_CascadeMessage(std::shared_ptr telegram); - void process_UBAMonitorFastPlus(std::shared_ptr telegram); + void process_CascadeMessage(const std::shared_ptr & telegram); + void process_UBAMonitorFastPlus(const std::shared_ptr & telegram); - void process_amTempMessage(std::shared_ptr telegram); - void process_amStatusMessage(std::shared_ptr telegram); - void process_amSettingMessage(std::shared_ptr telegram); - void process_amCommandMessage(std::shared_ptr telegram); - void process_amExtraMessage(std::shared_ptr telegram); + void process_amTempMessage(const std::shared_ptr & telegram); + void process_amStatusMessage(const std::shared_ptr & telegram); + void process_amSettingMessage(const std::shared_ptr & telegram); + void process_amCommandMessage(const std::shared_ptr & telegram); + void process_amExtraMessage(const std::shared_ptr & telegram); bool set_vr2Config(const char * value, const int8_t id); // pos 12: off(00)/Keelbypass(01)/(hc1pump(02) only standalone) diff --git a/src/devices/mixer.cpp b/src/devices/mixer.cpp index 4d521f90b..554ebf40c 100644 --- a/src/devices/mixer.cpp +++ b/src/devices/mixer.cpp @@ -91,7 +91,7 @@ Mixer::Mixer(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c // heating circuits 0x02D7, 0x02D8 etc... // e.g. A0 00 FF 00 01 D7 00 00 00 80 00 00 00 00 03 C5 // A0 0B FF 00 01 D7 00 00 00 80 00 00 00 00 03 80 -void Mixer::process_MMPLUSStatusMessage_HC(std::shared_ptr telegram) { +void Mixer::process_MMPLUSStatusMessage_HC(const std::shared_ptr & telegram) { has_update(telegram, flowTempHc_, 3); // is * 10 has_update(telegram, flowSetTemp_, 5); has_bitupdate(telegram, pumpStatus_, 0, 0); @@ -102,7 +102,7 @@ void Mixer::process_MMPLUSStatusMessage_HC(std::shared_ptr teleg // Mixer IPM - 0x010C // e.g. A0 00 FF 00 00 0C 01 00 00 00 00 00 54 // A1 00 FF 00 00 0C 02 04 00 01 1D 00 82 -void Mixer::process_IPMStatusMessage(std::shared_ptr telegram) { +void Mixer::process_IPMStatusMessage(const std::shared_ptr & telegram) { // check if circuit is active, 0-off, 1-unmixed, 2-mixed uint8_t ismixed = 0; telegram->read_value(ismixed, 0); @@ -122,14 +122,14 @@ void Mixer::process_IPMStatusMessage(std::shared_ptr telegram) { // Mixer IPM - 0x001E Temperature Message in unmixed circuits // in unmixed circuits FlowTemp in 10C is zero, this is the measured flowtemp in header -void Mixer::process_IPMTempMessage(std::shared_ptr telegram) { +void Mixer::process_IPMTempMessage(const std::shared_ptr & telegram) { has_update(telegram, flowTempVf_, 0); // TC1, is * 10 } // Mixer on a MM10 - 0xAB // e.g. Mixer Module -> All, type 0xAB, telegram: 21 00 AB 00 2D 01 BE 64 04 01 00 (CRC=15) #data=7 // see also https://github.com/emsesp/EMS-ESP/issues/386 -void Mixer::process_MMStatusMessage(std::shared_ptr telegram) { +void Mixer::process_MMStatusMessage(const std::shared_ptr & telegram) { // the heating circuit is determine by which device_id it is, 0x20 - 0x23 // 0x21 is position 2. 0x20 is typically reserved for the WM10 switch module // see https://github.com/emsesp/EMS-ESP/issues/270 and https://github.com/emsesp/EMS-ESP/issues/386#issuecomment-629610918 @@ -147,14 +147,14 @@ void Mixer::process_MMStatusMessage(std::shared_ptr telegram) { // Mixer on a MM10 - 0xAA // e.g. Thermostat -> Mixer Module, type 0xAA, telegram: 10 21 AA 00 FF 0C 0A 11 0A 32 xx -void Mixer::process_MMConfigMessage(std::shared_ptr telegram) { +void Mixer::process_MMConfigMessage(const std::shared_ptr & telegram) { has_update(telegram, activated_, 0); // on = 0xFF has_update(telegram, setValveTime_, 1); // valve runtime in 10 sec, max 120 s } // Mixer Config 0x2CD, .. // mixer(0x20) -W-> Me(0x0B), ?(0x02CD), data: FF 0E 05 FF 1E 00 -void Mixer::process_MMPLUSConfigMessage_HC(std::shared_ptr telegram) { +void Mixer::process_MMPLUSConfigMessage_HC(const std::shared_ptr & telegram) { has_update(telegram, activated_, 0); // on = 0xFF has_update(telegram, setValveTime_, 1); // valve runtime in 10 sec, default 120 s, max 600 s has_update(telegram, flowTempOffset_, 2); // Mixer increase [0-20 K] @@ -165,14 +165,14 @@ void Mixer::process_MMPLUSConfigMessage_HC(std::shared_ptr teleg // Thermostat(0x10) -> Mixer(0x20), ?(0x2E1), data: 01 1C 64 00 01 // Thermostat(0x10) -> Mixing Module(0x20), (0x2E1), data: 01 00 00 00 01 // Thermostat(0x10) -> Mixing Module(0x20), (0x2EB), data: 00 -// void Mixer::process_MMPLUSSetMessage_HC(std::shared_ptr telegram) { +// void Mixer::process_MMPLUSSetMessage_HC(const std::shared_ptr & telegram) { // pos 1: setpoint // pos2: pump // } // Mixer on a MM10 - 0xAC // e.g. Thermostat -> Mixer Module, type 0xAC, telegram: 10 21 AC 00 1E 64 01 AB -void Mixer::process_MMSetMessage(std::shared_ptr telegram) { +void Mixer::process_MMSetMessage(const std::shared_ptr & telegram) { // pos 0: flowtemp setpoint 1E = 30°C // pos 1: pump in % // pos 2 flags (mostly 01) @@ -180,7 +180,7 @@ void Mixer::process_MMSetMessage(std::shared_ptr telegram) { } // Thermostat(0x10) -> Mixer(0x21), ?(0x23), data: 1A 64 00 90 21 23 00 1A 64 00 89 -void Mixer::process_IPMSetMessage(std::shared_ptr telegram) { +void Mixer::process_IPMSetMessage(const std::shared_ptr & telegram) { // pos 0: flowtemp setpoint 1A = 26°C // pos 1: pump in %? } diff --git a/src/devices/mixer.h b/src/devices/mixer.h index 742308864..ef9f834d9 100644 --- a/src/devices/mixer.h +++ b/src/devices/mixer.h @@ -30,15 +30,15 @@ class Mixer : public EMSdevice { private: static uuid::log::Logger logger_; - void process_MMPLUSStatusMessage_HC(std::shared_ptr telegram); - void process_MMPLUSConfigMessage_HC(std::shared_ptr telegram); - void process_MMPLUSSetMessage_HC(std::shared_ptr telegram); - void process_IPMStatusMessage(std::shared_ptr telegram); - void process_IPMTempMessage(std::shared_ptr telegram); - void process_IPMSetMessage(std::shared_ptr telegram); - void process_MMStatusMessage(std::shared_ptr telegram); - void process_MMConfigMessage(std::shared_ptr telegram); - void process_MMSetMessage(std::shared_ptr telegram); + void process_MMPLUSStatusMessage_HC(const std::shared_ptr & telegram); + void process_MMPLUSConfigMessage_HC(const std::shared_ptr & telegram); + void process_MMPLUSSetMessage_HC(const std::shared_ptr & telegram); + void process_IPMStatusMessage(const std::shared_ptr & telegram); + void process_IPMTempMessage(const std::shared_ptr & telegram); + void process_IPMSetMessage(const std::shared_ptr & telegram); + void process_MMStatusMessage(const std::shared_ptr & telegram); + void process_MMConfigMessage(const std::shared_ptr & telegram); + void process_MMSetMessage(const std::shared_ptr & telegram); bool set_flowSetTemp(const char * value, const int8_t id); bool set_pump(const char * value, const int8_t id); diff --git a/src/devices/pool.cpp b/src/devices/pool.cpp index f3dc95e17..ecc37d303 100644 --- a/src/devices/pool.cpp +++ b/src/devices/pool.cpp @@ -39,7 +39,7 @@ Pool::Pool(uint8_t device_type, uint8_t device_id, uint8_t product_id, const cha } // Mixer MP100 for pools - 0x5BA -void Pool::process_HpPoolStatus(std::shared_ptr telegram) { +void Pool::process_HpPoolStatus(const std::shared_ptr & telegram) { has_update(telegram, poolTemp_, 0); has_update(telegram, poolShunt_, 3); // 0-100% how much is the shunt open? telegram->read_value(poolShuntStatus__, 2); diff --git a/src/devices/pool.h b/src/devices/pool.h index 3c98494da..b2cf42699 100644 --- a/src/devices/pool.h +++ b/src/devices/pool.h @@ -30,7 +30,7 @@ class Pool : public EMSdevice { private: static uuid::log::Logger logger_; - void process_HpPoolStatus(std::shared_ptr telegram); + void process_HpPoolStatus(const std::shared_ptr & telegram); private: // MP100 pool diff --git a/src/devices/solar.h b/src/devices/solar.h index 0fc30918b..4649d714b 100644 --- a/src/devices/solar.h +++ b/src/devices/solar.h @@ -137,30 +137,30 @@ class Solar : public EMSdevice { std::deque energy; - void process_SM10Monitor(std::shared_ptr telegram); - void process_SM10Config(std::shared_ptr telegram); - void process_SM100SystemConfig(std::shared_ptr telegram); - void process_SM100CircuitConfig(std::shared_ptr telegram); - void process_SM100Circuit2Config(std::shared_ptr telegram); - void process_SM100ParamCfg(std::shared_ptr telegram); - void process_SM100Monitor(std::shared_ptr telegram); - void process_SM100Monitor2(std::shared_ptr telegram); + void process_SM10Monitor(const std::shared_ptr & telegram); + void process_SM10Config(const std::shared_ptr & telegram); + void process_SM100SystemConfig(const std::shared_ptr & telegram); + void process_SM100CircuitConfig(const std::shared_ptr & telegram); + void process_SM100Circuit2Config(const std::shared_ptr & telegram); + void process_SM100ParamCfg(const std::shared_ptr & telegram); + void process_SM100Monitor(const std::shared_ptr & telegram); + void process_SM100Monitor2(const std::shared_ptr & telegram); - void process_SM100Config(std::shared_ptr telegram); - void process_SM100Config1(std::shared_ptr telegram); + void process_SM100Config(const std::shared_ptr & telegram); + void process_SM100Config1(const std::shared_ptr & telegram); - void process_SM100Status(std::shared_ptr telegram); - void process_SM100Status2(std::shared_ptr telegram); - void process_SM100CollectorConfig(std::shared_ptr telegram); - void process_SM100Energy(std::shared_ptr telegram); - void process_SM100Time(std::shared_ptr telegram); + void process_SM100Status(const std::shared_ptr & telegram); + void process_SM100Status2(const std::shared_ptr & telegram); + void process_SM100CollectorConfig(const std::shared_ptr & telegram); + void process_SM100Energy(const std::shared_ptr & telegram); + void process_SM100Time(const std::shared_ptr & telegram); - void process_SM100HeatAssist(std::shared_ptr telegram); - void process_SM100Differential(std::shared_ptr telegram); + void process_SM100HeatAssist(const std::shared_ptr & telegram); + void process_SM100Differential(const std::shared_ptr & telegram); - void process_ISM1StatusMessage(std::shared_ptr telegram); - void process_ISM1Set(std::shared_ptr telegram); - void process_ISM2StatusMessage(std::shared_ptr telegram); + void process_ISM1StatusMessage(const std::shared_ptr & telegram); + void process_ISM1Set(const std::shared_ptr & telegram); + void process_ISM2StatusMessage(const std::shared_ptr & telegram); // settings bool set_CollectorMaxTemp(const char * value, const int8_t id); diff --git a/src/devices/switch.cpp b/src/devices/switch.cpp index 5e2c0c8aa..4a83a7feb 100644 --- a/src/devices/switch.cpp +++ b/src/devices/switch.cpp @@ -41,13 +41,13 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const // message 0x9D switch on/off // Thermostat(0x10) -> Switch(0x11), ?(0x9D), data: 00 -void Switch::process_WM10SetMessage(std::shared_ptr telegram) { +void Switch::process_WM10SetMessage(const std::shared_ptr & telegram) { has_update(telegram, activated_, 0); } // message 0x9C holds flowtemp and unknown status value // Switch(0x11) -> All(0x00), ?(0x9C), data: 01 BA 00 01 00 -void Switch::process_WM10MonitorMessage(std::shared_ptr telegram) { +void Switch::process_WM10MonitorMessage(const std::shared_ptr & telegram) { has_update(telegram, flowTempHc_, 0); // is * 10 has_update(telegram, status_, 2); // has_update(telegram, status2_, 3)); // unknown @@ -55,7 +55,7 @@ void Switch::process_WM10MonitorMessage(std::shared_ptr telegram // message 0x1E flow temperature, same as in 9C, published often, republished also by boiler UBAFast 0x18 // Switch(0x11) -> Boiler(0x08), ?(0x1E), data: 01 BA -void Switch::process_WM10TempMessage(std::shared_ptr telegram) { +void Switch::process_WM10TempMessage(const std::shared_ptr & telegram) { has_update(telegram, flowTempHc_, 0); // is * 10 } diff --git a/src/devices/switch.h b/src/devices/switch.h index 4b05a4ea6..6851d7949 100644 --- a/src/devices/switch.h +++ b/src/devices/switch.h @@ -28,9 +28,9 @@ class Switch : public EMSdevice { Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand); private: - void process_WM10SetMessage(std::shared_ptr telegram); - void process_WM10MonitorMessage(std::shared_ptr telegram); - void process_WM10TempMessage(std::shared_ptr telegram); + void process_WM10SetMessage(const std::shared_ptr & telegram); + void process_WM10MonitorMessage(const std::shared_ptr & telegram); + void process_WM10TempMessage(const std::shared_ptr & telegram); uint16_t flowTempHc_; uint8_t status_; diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 824897496..e5d1752b9 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -26,6 +26,12 @@ uuid::log::Logger Thermostat::logger_{F_(thermostat), uuid::log::Facility::CONSO Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand) : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { + // pre-size containers; max in-code counts are ~78 telegrams / ~332 values + // but real per-instance counts after flag-discriminated branches are + // ~40-60 telegrams / ~150-220 values. Reserve generously to avoid realloc. + reserve_telegram_functions(64); + reserve_device_values(220); + // RF remote sensor seen at 0x40, maybe this is also for different hc with id 0x40 - 0x47? emsesp.cpp maps only 0x40 if (device_id >= 0x40 && device_id <= 0x47) { register_telegram_type(0x0435, "RFTemp", false, MAKE_PF_CB(process_RemoteTemp)); @@ -288,7 +294,7 @@ std::shared_ptr Thermostat::heating_circuit(const in // determine which heating circuit the type ID is referring too // returns pointer to the HeatingCircuit or nullptr if it can't be found // if its a new one, the heating circuit object will be created and also the fetch flags set -std::shared_ptr Thermostat::heating_circuit(std::shared_ptr telegram) { +std::shared_ptr Thermostat::heating_circuit(const std::shared_ptr & telegram) { // do not create a hc on empty messages if (telegram->message_length == 0) { return nullptr; @@ -641,7 +647,7 @@ std::shared_ptr Thermostat::dhw_circuit(const uint8_t of // type 0xB1 - data from the RC10 thermostat (0x17) // Data: 04 23 00 BA 00 00 00 BA -void Thermostat::process_RC10Monitor(std::shared_ptr telegram) { +void Thermostat::process_RC10Monitor(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -658,7 +664,7 @@ void Thermostat::process_RC10Monitor(std::shared_ptr telegram) { // type 0xB0 - for reading the mode from the RC10 thermostat (0x17) // Data: 00 FF 00 1C 20 08 01 -void Thermostat::process_RC10Set(std::shared_ptr telegram) { +void Thermostat::process_RC10Set(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -675,7 +681,7 @@ void Thermostat::process_RC10Set(std::shared_ptr telegram) { // type 0xB2, mode setting Data: 04 00 // not used, we read mode from monitor 0xB1 -void Thermostat::process_RC10Set_2(std::shared_ptr telegram) { +void Thermostat::process_RC10Set_2(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -687,7 +693,7 @@ void Thermostat::process_RC10Set_2(std::shared_ptr telegram) { // 0xA8 - for reading the mode from the RC20 thermostat (0x17) // RC20Set(0xA8), data: 01 00 FF F6 01 06 00 01 0D 01 00 FF FF 01 02 02 02 00 00 05 1E 05 1E 02 1C 00 FF 00 00 26 02 -void Thermostat::process_RC20Set(std::shared_ptr telegram) { +void Thermostat::process_RC20Set(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -700,7 +706,7 @@ void Thermostat::process_RC20Set(std::shared_ptr telegram) { // 0x90 - for reading curve temperature from the RC20 thermostat (0x17) // -void Thermostat::process_RC20Temp(std::shared_ptr telegram) { +void Thermostat::process_RC20Temp(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -716,7 +722,7 @@ void Thermostat::process_RC20Temp(std::shared_ptr telegram) { // data: 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 (offset 27) // data: E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 90 E7 (offset 54) // data: 90 E7 90 01 00 00 01 01 00 01 01 00 01 01 00 01 01 00 00 (offset 81) -void Thermostat::process_RC20Timer(std::shared_ptr telegram) { +void Thermostat::process_RC20Timer(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -744,7 +750,7 @@ void Thermostat::process_RC20Timer(std::shared_ptr telegram) { // type 0xAE - data from the RC20 thermostat (0x17) - not for RC20's // 17 00 AE 00 80 12 2E 00 D0 00 00 64 (#data=8) // https://github.com/emsesp/EMS-ESP/issues/361 -void Thermostat::process_RC20Monitor_2(std::shared_ptr telegram) { +void Thermostat::process_RC20Monitor_2(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -763,7 +769,7 @@ void Thermostat::process_RC20Monitor_2(std::shared_ptr telegram) // offset: 01-nighttemp, 02-daytemp, 03-mode, 0B-program(1-9), 0D-setpoint_roomtemp(temporary) // 17 00 AD 00 01 27 29 01 4B 05 01 FF 28 19 0A 02 00 00 // RC25(0x17) -> All(0x00), ?(0xAD), data: 01 27 2D 00 44 05 01 FF 28 19 0A 07 00 00 F6 12 5A 11 00 28 05 05 00 -void Thermostat::process_RC20Set_2(std::shared_ptr telegram) { +void Thermostat::process_RC20Set_2(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -783,14 +789,14 @@ void Thermostat::process_RC20Set_2(std::shared_ptr telegram) { } // 0xAF - for reading the roomtemperature from the RC20/ES72 thermostat (0x18, 0x19, ..) -void Thermostat::process_RC20Remote(std::shared_ptr telegram) { +void Thermostat::process_RC20Remote(const std::shared_ptr & telegram) { has_update(telegram, tempsensor1_, 0); } // 0x42B - for reading the roomtemperature from the RC100H remote thermostat (0x38, 0x39, ..) // e.g. "38 10 FF 00 03 2B 00 D1 08 2A 01" // also RF temp from 0x435 -void Thermostat::process_RemoteTemp(std::shared_ptr telegram) { +void Thermostat::process_RemoteTemp(const std::shared_ptr & telegram) { has_update(telegram, tempsensor1_, 0); if (telegram->type_id >= 0x435) { return; @@ -804,7 +810,7 @@ void Thermostat::process_RemoteTemp(std::shared_ptr telegram) { // 0x47B, ff - for reading humidity from the RC100H remote thermostat (0x38, 0x39, ..) // e.g. "38 10 FF 00 03 7B 08 24 00 4B" -void Thermostat::process_RemoteHumidity(std::shared_ptr telegram) { +void Thermostat::process_RemoteHumidity(const std::shared_ptr & telegram) { // has_update(telegram, dewtemperature_, 0); // this is int8 has_update(telegram, humidity_, 1); has_update(telegram, dewtemperature_, 2); // this is int16 @@ -821,17 +827,17 @@ void Thermostat::process_RemoteHumidity(std::shared_ptr telegram // 0x273 - for reading temperaturcorrection from the RC100H remote thermostat (0x38, 0x39, ..) // Thermostat(0x38) -> Me(0x0B), RemoteCorrection(0x0273), data: 0A 00 -void Thermostat::process_RemoteCorrection(std::shared_ptr telegram) { +void Thermostat::process_RemoteCorrection(const std::shared_ptr & telegram) { has_update(telegram, ibaCalIntTemperature_, 0); } // 0xA6A - for reading battery from the RC100H remote thermostat (0x38, 0x39, ..) -void Thermostat::process_RemoteBattery(std::shared_ptr telegram) { +void Thermostat::process_RemoteBattery(const std::shared_ptr & telegram) { has_update(telegram, battery_, 1); } // type 0x0165, ff -void Thermostat::process_JunkersSet(std::shared_ptr telegram) { +void Thermostat::process_JunkersSet(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -859,7 +865,7 @@ void Thermostat::process_JunkersSet(std::shared_ptr telegram) { } // type 0x0179, ff for Junkers_OLD -void Thermostat::process_JunkersSet2(std::shared_ptr telegram) { +void Thermostat::process_JunkersSet2(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -879,12 +885,12 @@ void Thermostat::process_JunkersSet2(std::shared_ptr telegram) { } // type 0x123 - FB10 Junkers remote -void Thermostat::process_JunkersRemoteMonitor(std::shared_ptr telegram) { +void Thermostat::process_JunkersRemoteMonitor(const std::shared_ptr & telegram) { has_update(telegram, tempsensor1_, 0); // roomTemp from remote } // type 0xA3 - for external temp settings from the the RC* thermostats (e.g. RC35) -void Thermostat::process_RCOutdoorTemp(std::shared_ptr telegram) { +void Thermostat::process_RCOutdoorTemp(const std::shared_ptr & telegram) { has_update(telegram, dampedoutdoortemp_, 0); has_update(telegram, tempsensor1_, 3); // sensor 1 - is * 10 has_update(telegram, tempsensor2_, 5); // sensor 2 - is * 10 @@ -893,7 +899,7 @@ void Thermostat::process_RCOutdoorTemp(std::shared_ptr telegram) // 0x91 - data from the RC20 thermostat (0x17) - 15 bytes long // RC20Monitor(0x91), data: 90 2A 00 D5 1A 00 00 05 00 5A 04 00 D6 00 // offset 8: setburnpower to boiler, offset 9: setflowtemp to boiler (thermostat: targetflowtemp) send via 0x1A -void Thermostat::process_RC20Monitor(std::shared_ptr telegram) { +void Thermostat::process_RC20Monitor(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -906,7 +912,7 @@ void Thermostat::process_RC20Monitor(std::shared_ptr telegram) { } // type 0x0A - data from the Nefit Easy/TC100 thermostat (0x18) - 31 bytes long -void Thermostat::process_EasyMonitor(std::shared_ptr telegram) { +void Thermostat::process_EasyMonitor(const std::shared_ptr & telegram) { monitor_typeids[0] = telegram->type_id; auto hc = heating_circuit(telegram); if (hc == nullptr) { @@ -936,7 +942,7 @@ void Thermostat::process_EasyMonitor(std::shared_ptr telegram) { } // Settings Parameters - 0xA5 - RC30_1 -void Thermostat::process_IBASettings(std::shared_ptr telegram) { +void Thermostat::process_IBASettings(const std::shared_ptr & telegram) { // 22 - display line on RC35 // display on Thermostat: 0 int. temp, 1 int. setpoint, 2 ext. temp., 3 burner temp., 4 ww temp, 5 functioning mode, 6 time, 7 data, 8 smoke temp @@ -950,7 +956,7 @@ void Thermostat::process_IBASettings(std::shared_ptr telegram) { } // Settings WW 0x37 - RC35 -void Thermostat::process_RC35wwSettings(std::shared_ptr telegram) { +void Thermostat::process_RC35wwSettings(const std::shared_ptr & telegram) { auto dhw = dhw_circuit(0, true); has_bitupdate(telegram, dhw->wwProgMode_, 0, 0); // 0-like hc, 0xFF own prog has_bitupdate(telegram, dhw->wwCircProg_, 1, 0); // 0-like hc, 0xFF own prog @@ -964,7 +970,7 @@ void Thermostat::process_RC35wwSettings(std::shared_ptr telegram } // Settings WW 0x3A - RC30 -void Thermostat::process_RC30wwSettings(std::shared_ptr telegram) { +void Thermostat::process_RC30wwSettings(const std::shared_ptr & telegram) { auto dhw = dhw_circuit(0, true); has_update(telegram, dhw->wwMode_, 0); // 0-on, 1-off, 2-auto has_update(telegram, dhw->wwWhenModeOff_, 1); // 0-off, 0xFF on @@ -974,7 +980,7 @@ void Thermostat::process_RC30wwSettings(std::shared_ptr telegram } // type 0x38 (ww) and 0x39 (circ) -void Thermostat::process_RC35wwTimer(std::shared_ptr telegram) { +void Thermostat::process_RC35wwTimer(const std::shared_ptr & telegram) { auto dhw = dhw_circuit(0, true); if ((telegram->message_length == 2 && telegram->offset < 83 && !(telegram->offset & 1)) || (!telegram->offset && telegram->type_id == 0x38 && !strlen(dhw->wwSwitchTime_) && telegram->message_length > 1) @@ -1037,7 +1043,7 @@ void Thermostat::process_RC35wwTimer(std::shared_ptr telegram) { } // type 0x6F - FR10/FR50/FR100/FR110/FR120 Junkers -void Thermostat::process_JunkersMonitor(std::shared_ptr telegram) { +void Thermostat::process_JunkersMonitor(const std::shared_ptr & telegram) { // ignore single byte telegram messages if (telegram->message_length <= 1) { return; @@ -1062,7 +1068,7 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr telegram // 0xBB Heatpump optimization // ?(0xBB), data: 00 00 00 00 00 00 00 00 00 00 00 FF 02 0F 1E 0B 1A 00 14 03 -void Thermostat::process_HybridSettings(std::shared_ptr telegram) { +void Thermostat::process_HybridSettings(const std::shared_ptr & telegram) { has_enumupdate(telegram, hybridStrategy_, 12, 1); // cost = 2, temperature = 3, mix = 4 has_update(telegram, switchOverTemp_, 13); // full degrees has_update(telegram, energyCostRatio_, 14); // is *10 @@ -1073,18 +1079,18 @@ void Thermostat::process_HybridSettings(std::shared_ptr telegram } // 0x23E PV settings -void Thermostat::process_PVSettings(std::shared_ptr telegram) { +void Thermostat::process_PVSettings(const std::shared_ptr & telegram) { has_update(telegram, pvRaiseHeat_, 0); has_update(telegram, pvEnableWw_, 3); has_update(telegram, pvLowerCool_, 5); } // 0x16E Absent settings - hc or dhw or device_data? #1957 -void Thermostat::process_Absent(std::shared_ptr telegram) { +void Thermostat::process_Absent(const std::shared_ptr & telegram) { has_update(telegram, absent_, 0); } -void Thermostat::process_JunkersSetMixer(std::shared_ptr telegram) { +void Thermostat::process_JunkersSetMixer(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1093,13 +1099,13 @@ void Thermostat::process_JunkersSetMixer(std::shared_ptr telegra } // Thermostat(0x10) -> All(0x00), ?(0x01D3), data: 01 00 00 -void Thermostat::process_JunkersWW(std::shared_ptr telegram) { +void Thermostat::process_JunkersWW(const std::shared_ptr & telegram) { auto dhw = dhw_circuit(0, true); has_bitupdate(telegram, dhw->wwCharge_, 0, 3); } // 0x11E -void Thermostat::process_JunkersDisp(std::shared_ptr telegram) { +void Thermostat::process_JunkersDisp(const std::shared_ptr & telegram) { has_enumupdate(telegram, ibaMainDisplay_, 1, 1); has_update(telegram, ibaLanguage_, 3); has_update(telegram, ibaMinExtTemperature_, 16); @@ -1107,7 +1113,7 @@ void Thermostat::process_JunkersDisp(std::shared_ptr telegram) { } // type 0x02A5 - data from Worchester CRF200 -void Thermostat::process_CRFMonitor(std::shared_ptr telegram) { +void Thermostat::process_CRFMonitor(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1123,7 +1129,7 @@ void Thermostat::process_CRFMonitor(std::shared_ptr telegram) { } // type 0x02A5 - data from CR11 -void Thermostat::process_CR11Monitor(std::shared_ptr telegram) { +void Thermostat::process_CR11Monitor(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1144,7 +1150,7 @@ void Thermostat::process_CR11Monitor(std::shared_ptr telegram) { // type 0x02A5 - data from the Nefit RC1010/3000 thermostat (0x18) and RC300/310s on 0x10 // Rx: 10 0B FF 00 01 A5 80 00 01 30 23 00 30 28 01 E7 03 03 01 01 E7 02 33 00 00 11 01 03 FF FF 00 04 -void Thermostat::process_RC300Monitor(std::shared_ptr telegram) { +void Thermostat::process_RC300Monitor(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1185,7 +1191,7 @@ void Thermostat::process_RC300Monitor(std::shared_ptr telegram) // type 0x02B9 EMS+ for reading from RC300/RC310 thermostat // Thermostat(0x10) -> Me(0x0B), RC300Set(0x2B9), data: FF 2E 2A 26 1E 02 4E FF FF 00 1C 01 E1 20 01 0F 05 00 00 02 1F -void Thermostat::process_RC300Set(std::shared_ptr telegram) { +void Thermostat::process_RC300Set(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr || model() == EMSdevice::EMS_DEVICE_FLAG_CR11) { return; @@ -1236,7 +1242,7 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { // types 0x2AF ff // RC300Summer(0x02AF), data: 00 28 00 00 3C 26 00 00 19 0F 00 (from a heatpump) -void Thermostat::process_RC300Summer(std::shared_ptr telegram) { +void Thermostat::process_RC300Summer(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1266,7 +1272,7 @@ void Thermostat::process_RC300Summer(std::shared_ptr telegram) { // types 0x471 ff summer2_typeids // (0x473), data: 00 11 04 01 01 1C 08 04 -void Thermostat::process_RC300Summer2(std::shared_ptr telegram) { +void Thermostat::process_RC300Summer2(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { // telegram 0x470 see https://github.com/emsesp/EMS-ESP32/issues/2686 @@ -1295,7 +1301,7 @@ void Thermostat::process_RC300Summer2(std::shared_ptr telegram) // types 0x29B ff // Thermostat(0x10) -> Me(0x0B), RC300Curves(0x29B), data: 01 01 00 FF FF 01 05 30 52 -void Thermostat::process_RC300Curve(std::shared_ptr telegram) { +void Thermostat::process_RC300Curve(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1315,7 +1321,7 @@ void Thermostat::process_RC300Curve(std::shared_ptr telegram) { } // types 0x31B -void Thermostat::process_RC300WWtemp(std::shared_ptr telegram) { +void Thermostat::process_RC300WWtemp(const std::shared_ptr & telegram) { auto dhw = dhw_circuit(0, true); has_update(telegram, dhw->wwSetTemp_, 0); has_update(telegram, dhw->wwSetTempLow_, 1); @@ -1324,7 +1330,7 @@ void Thermostat::process_RC300WWtemp(std::shared_ptr telegram) { // type 02F5 // RC300WWmode(0x2F5), data: 01 FF 04 00 00 00 08 05 00 08 04 00 00 00 00 00 00 00 00 00 01 // RC300WWmode(0x2F6), data: 02 FF 04 00 00 00 08 05 00 08 04 00 00 00 00 00 00 00 00 00 01 -void Thermostat::process_RC300WWmode(std::shared_ptr telegram) { +void Thermostat::process_RC300WWmode(const std::shared_ptr & telegram) { uint8_t circuit = 0; telegram->read_value(circuit, 0); // 00-no circuit, 01-boiler, 02-mixer auto dhw = dhw_circuit(telegram->type_id - 0x2F5, circuit != 0); @@ -1358,7 +1364,7 @@ void Thermostat::process_RC300WWmode(std::shared_ptr telegram) { // types 0x31D and 0x31E // RC300WWmode2(0x31D), data: 00 00 09 07 -void Thermostat::process_RC300WWmode2(std::shared_ptr telegram) { +void Thermostat::process_RC300WWmode2(const std::shared_ptr & telegram) { auto dhw = dhw_circuit(telegram->type_id - 0x31D); if (dhw == nullptr) { return; @@ -1372,13 +1378,13 @@ void Thermostat::process_RC300WWmode2(std::shared_ptr telegram) } // 0x23A damped outdoor temp -void Thermostat::process_RC300OutdoorTemp(std::shared_ptr telegram) { +void Thermostat::process_RC300OutdoorTemp(const std::shared_ptr & telegram) { has_update(telegram, dampedoutdoortemp2_, 0); // is *10 } // 0x240 RC300 parameter, 0x0241 for CW100, see https://github.com/emsesp/EMS-ESP32/issues/2290 // RC300Settings(0x240), data: 26 00 03 00 00 00 00 00 FF 01 F6 06 FF 00 00 00 00 00 00 00 00 00 00 -void Thermostat::process_RC300Settings(std::shared_ptr telegram) { +void Thermostat::process_RC300Settings(const std::shared_ptr & telegram) { has_update(telegram, ibaCalIntTemperature_, 7); has_update(telegram, ibaDamping_, 8); has_enumupdate(telegram, ibaBuildingType_, 9, 1); // 1=light, 2=medium, 3=heavy @@ -1387,7 +1393,7 @@ void Thermostat::process_RC300Settings(std::shared_ptr telegram) } // 0x2CC - e.g. wwprio for RC310 hcx parameter -void Thermostat::process_RC300Set2(std::shared_ptr telegram) { +void Thermostat::process_RC300Set2(const std::shared_ptr & telegram) { // typeids are not in a row. hc:0x2CC, hc2: 0x2CE for RC310 // telegram is either offset 3 with data length of 1 and values 0/1 (radiators) - 10 0B FF 03 01 CC 01 F6 // or offset 0 with data length of 6 bytes - offset 3 values are 0x00 or 0xFF - 10 0B FF 00 01 CE FF 13 0A FF 1E 00 20 @@ -1400,14 +1406,14 @@ void Thermostat::process_RC300Set2(std::shared_ptr telegram) { } // 0x267 RC300 floordrying -void Thermostat::process_RC300Floordry(std::shared_ptr telegram) { +void Thermostat::process_RC300Floordry(const std::shared_ptr & telegram) { has_update(telegram, floordrystatus_, 0); has_update(telegram, floordrytemp_, 1); } // 0x269 - 0x26D RC300 EMS+ holidaymodes 1 to 5 // special case R3000 only date in 0x269, CR50 only 0x043F -void Thermostat::process_RC300Holiday(std::shared_ptr telegram) { +void Thermostat::process_RC300Holiday(const std::shared_ptr & telegram) { if (telegram->offset || telegram->message_length < 6) { return; } @@ -1425,7 +1431,7 @@ void Thermostat::process_RC300Holiday(std::shared_ptr telegram) } // https://github.com/emsesp/EMS-ESP32/issues/2735#issuecomment-3520124647 -void Thermostat::process_PID(std::shared_ptr telegram) { +void Thermostat::process_PID(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1445,7 +1451,7 @@ void Thermostat::process_PID(std::shared_ptr telegram) { // 0x291 ff. HP mode // thermostat(0x10) -W-> Me(0x0B), HPMode(0x0291), data: 01 00 00 03 FF 00 -void Thermostat::process_HPMode(std::shared_ptr telegram) { +void Thermostat::process_HPMode(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1455,7 +1461,7 @@ void Thermostat::process_HPMode(std::shared_ptr telegram) { } // 0x467 ff HP settings -void Thermostat::process_HPSet(std::shared_ptr telegram) { +void Thermostat::process_HPSet(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1467,7 +1473,7 @@ void Thermostat::process_HPSet(std::shared_ptr telegram) { // type 0x41 - data from the RC30 thermostat(0x10) - 14 bytes long // RC30Monitor(0x41), data: 80 20 00 AC 00 00 00 02 00 05 09 00 AC 00 -void Thermostat::process_RC30Monitor(std::shared_ptr telegram) { +void Thermostat::process_RC30Monitor(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1482,7 +1488,7 @@ void Thermostat::process_RC30Monitor(std::shared_ptr telegram) { // type 0xA7 - for reading the mode from the RC30 thermostat (0x10) and all the installation settings // RC30Set(0xA7), data: 01 00 FF F6 01 06 00 01 0D 00 00 FF FF 01 02 02 02 00 00 05 1F 05 1F 01 0E 00 FF // RC30Set(0xA7), data: 00 00 20 02 (offset 27) -void Thermostat::process_RC30Set(std::shared_ptr telegram) { +void Thermostat::process_RC30Set(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1505,7 +1511,7 @@ void Thermostat::process_RC30Set(std::shared_ptr telegram) { // type 0x40 (HC1) - for reading the operating mode from the RC30 thermostat (0x10) // RC30Temp(0x40), data: 01 01 02 20 24 28 2A 1E 0E 00 01 5A 32 05 4B 2D 00 28 00 3C FF 11 00 05 00 -void Thermostat::process_RC30Temp(std::shared_ptr telegram) { +void Thermostat::process_RC30Temp(const std::shared_ptr & telegram) { // check to see we have a valid type. heating: 1 radiator, 2 convectors, 3 floors if (telegram->offset == 0 && telegram->message_data[0] == 0x00) { return; @@ -1526,7 +1532,7 @@ void Thermostat::process_RC30Temp(std::shared_ptr telegram) { } // type 0x3E (HC1), 0x48 (HC2), 0x52 (HC3), 0x5C (HC4) - data from the RC35 thermostat (0x10) - 16 bytes -void Thermostat::process_RC35Monitor(std::shared_ptr telegram) { +void Thermostat::process_RC35Monitor(const std::shared_ptr & telegram) { // Check if heatingciruit is active, see https://github.com/emsesp/EMS-ESP32/issues/786 // roomtemp is measured value or 7D00 on active hc's, zero on inactive uint16_t active = 0; @@ -1552,7 +1558,7 @@ void Thermostat::process_RC35Monitor(std::shared_ptr telegram) { } // type 0x3D (HC1), 0x47 (HC2), 0x51 (HC3), 0x5B (HC4) - Working Mode Heating - for reading the mode from the RC35 thermostat (0x10) -void Thermostat::process_RC35Set(std::shared_ptr telegram) { +void Thermostat::process_RC35Set(const std::shared_ptr & telegram) { // check to see we have a valid type. heating: 1 radiator, 2 convectors, 3 floors, 4 room supply if (telegram->offset == 0 && telegram->message_data[0] == 0x00) { return; @@ -1600,7 +1606,7 @@ void Thermostat::process_RC35Set(std::shared_ptr telegram) { } // type 0x3F (HC1), 0x49 (HC2), 0x53 (HC3), 0x5D (HC4) - timer setting -void Thermostat::process_RC35Timer(std::shared_ptr telegram) { +void Thermostat::process_RC35Timer(const std::shared_ptr & telegram) { auto hc = heating_circuit(telegram); if (hc == nullptr) { return; @@ -1671,7 +1677,7 @@ void Thermostat::process_RC35Timer(std::shared_ptr telegram) { } // type 0x9A (HC1) -void Thermostat::process_RC30Vacation(std::shared_ptr telegram) { +void Thermostat::process_RC30Vacation(const std::shared_ptr & telegram) { if ((telegram->offset + telegram->message_length) > 57) { return; } @@ -1695,7 +1701,7 @@ void Thermostat::process_RC30Vacation(std::shared_ptr telegram) } // process_RCTime - type 0x06 - date and time from a thermostat - 12 or 15 bytes long -void Thermostat::process_RCTime(std::shared_ptr telegram) { +void Thermostat::process_RCTime(const std::shared_ptr & telegram) { if (telegram->offset > 0 || telegram->message_length < 8) { return; } @@ -1779,7 +1785,7 @@ void Thermostat::process_RCTime(std::shared_ptr telegram) { // process_RCError - type 0xA2 - error message - 14 bytes long // 10 00 A2 00 41 32 32 03 30 00 02 00 00 00 00 00 00 02 CRC // A 2 2 816 -void Thermostat::process_RCError(std::shared_ptr telegram) { +void Thermostat::process_RCError(const std::shared_ptr & telegram) { if (telegram->offset > 0 || telegram->message_length < 5) { return; } @@ -1796,7 +1802,7 @@ void Thermostat::process_RCError(std::shared_ptr telegram) { // 0x12 and 0x13 error log // RCErrorMessage(0x12), data: 32 32 03 30 95 0A 0A 15 18 00 01 19 32 32 03 30 95 0A 09 05 18 00 01 19 31 38 03 // RCErrorMessage(0x12), data: 39 95 08 09 0F 19 00 01 17 64 31 03 34 95 07 10 08 00 00 01 70 (offset 27) -void Thermostat::process_RCErrorMessage(std::shared_ptr telegram) { +void Thermostat::process_RCErrorMessage(const std::shared_ptr & telegram) { if (telegram->offset > 0 || telegram->message_length < 11) { return; } @@ -1828,12 +1834,12 @@ void Thermostat::process_RCErrorMessage(std::shared_ptr telegram } // 0xBF -void Thermostat::process_ErrorMessageBF(std::shared_ptr telegram) { +void Thermostat::process_ErrorMessageBF(const std::shared_ptr & telegram) { EMSESP::send_read_request(0xC0, device_id(), 0, 20); // read last errorcode } // 0xC0 error log for RC300 -void Thermostat::process_RCErrorMessage2(std::shared_ptr telegram) { +void Thermostat::process_RCErrorMessage2(const std::shared_ptr & telegram) { if (telegram->offset > 0 || telegram->message_length < 20) { return; } diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 4c33b78b9..c702a602f 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -408,7 +408,7 @@ class Thermostat : public EMSdevice { static constexpr uint8_t EMS_TYPE_RC30wwSettings = 0x3A; // RC30 ww settings static constexpr uint8_t EMS_TYPE_time = 0x06; // time - std::shared_ptr heating_circuit(std::shared_ptr telegram); + std::shared_ptr heating_circuit(const std::shared_ptr & telegram); std::shared_ptr heating_circuit(const int8_t id); std::shared_ptr dhw_circuit(const uint8_t offset, const bool create = false); @@ -417,66 +417,66 @@ class Thermostat : public EMSdevice { void add_ha_climate(std::shared_ptr hc) const; - void process_RCOutdoorTemp(std::shared_ptr telegram); - void process_IBASettings(std::shared_ptr telegram); - void process_RCTime(std::shared_ptr telegram); - void process_RCError(std::shared_ptr telegram); - void process_RCErrorMessage(std::shared_ptr telegram); - void process_RCErrorMessage2(std::shared_ptr telegram); - void process_ErrorMessageBF(std::shared_ptr telegram); - void process_RC35wwSettings(std::shared_ptr telegram); - void process_RC35wwTimer(std::shared_ptr telegram); - void process_RC35Monitor(std::shared_ptr telegram); - void process_RC35Set(std::shared_ptr telegram); - void process_RC35Timer(std::shared_ptr telegram); - void process_RC30Vacation(std::shared_ptr telegram); - void process_RC30Monitor(std::shared_ptr telegram); - void process_RC30Set(std::shared_ptr telegram); - void process_RC30Temp(std::shared_ptr telegram); - void process_RC30wwSettings(std::shared_ptr telegram); - void process_RC20Monitor(std::shared_ptr telegram); - void process_RC20Set(std::shared_ptr telegram); - void process_RC20Temp(std::shared_ptr telegram); - void process_RC20Timer(std::shared_ptr telegram); - void process_RC20Remote(std::shared_ptr telegram); - void process_RC20Monitor_2(std::shared_ptr telegram); - void process_RC20Set_2(std::shared_ptr telegram); - void process_RC10Monitor(std::shared_ptr telegram); - void process_RC10Set(std::shared_ptr telegram); - void process_RC10Set_2(std::shared_ptr telegram); - void process_CRFMonitor(std::shared_ptr telegram); - void process_CR11Monitor(std::shared_ptr telegram); - void process_RC300Monitor(std::shared_ptr telegram); - void process_RC300Set(std::shared_ptr telegram); - void process_RC300Set2(std::shared_ptr telegram); - void process_RC300Summer(std::shared_ptr telegram); - void process_RC300Summer2(std::shared_ptr telegram); - void process_RC300WWmode(std::shared_ptr telegram); - void process_RC300WWmode2(std::shared_ptr telegram); - void process_RC300WWtemp(std::shared_ptr telegram); - void process_RC300OutdoorTemp(std::shared_ptr telegram); - void process_RC300Settings(std::shared_ptr telegram); - void process_RC300Floordry(std::shared_ptr telegram); - void process_RC300Holiday(std::shared_ptr telegram); - void process_RC300Curve(std::shared_ptr telegram); - void process_JunkersMonitor(std::shared_ptr telegram); - void process_JunkersSet(std::shared_ptr telegram); - void process_JunkersSet2(std::shared_ptr telegram); - void process_EasyMonitor(std::shared_ptr telegram); - void process_JunkersRemoteMonitor(std::shared_ptr telegram); - void process_HybridSettings(std::shared_ptr telegram); - void process_PVSettings(std::shared_ptr telegram); - void process_Absent(std::shared_ptr telegram); - void process_JunkersSetMixer(std::shared_ptr telegram); - void process_JunkersWW(std::shared_ptr telegram); - void process_JunkersDisp(std::shared_ptr telegram); - void process_RemoteTemp(std::shared_ptr telegram); - void process_RemoteHumidity(std::shared_ptr telegram); - void process_RemoteCorrection(std::shared_ptr telegram); - void process_RemoteBattery(std::shared_ptr telegram); - void process_HPSet(std::shared_ptr telegram); - void process_HPMode(std::shared_ptr telegram); - void process_PID(std::shared_ptr telegram); + void process_RCOutdoorTemp(const std::shared_ptr & telegram); + void process_IBASettings(const std::shared_ptr & telegram); + void process_RCTime(const std::shared_ptr & telegram); + void process_RCError(const std::shared_ptr & telegram); + void process_RCErrorMessage(const std::shared_ptr & telegram); + void process_RCErrorMessage2(const std::shared_ptr & telegram); + void process_ErrorMessageBF(const std::shared_ptr & telegram); + void process_RC35wwSettings(const std::shared_ptr & telegram); + void process_RC35wwTimer(const std::shared_ptr & telegram); + void process_RC35Monitor(const std::shared_ptr & telegram); + void process_RC35Set(const std::shared_ptr & telegram); + void process_RC35Timer(const std::shared_ptr & telegram); + void process_RC30Vacation(const std::shared_ptr & telegram); + void process_RC30Monitor(const std::shared_ptr & telegram); + void process_RC30Set(const std::shared_ptr & telegram); + void process_RC30Temp(const std::shared_ptr & telegram); + void process_RC30wwSettings(const std::shared_ptr & telegram); + void process_RC20Monitor(const std::shared_ptr & telegram); + void process_RC20Set(const std::shared_ptr & telegram); + void process_RC20Temp(const std::shared_ptr & telegram); + void process_RC20Timer(const std::shared_ptr & telegram); + void process_RC20Remote(const std::shared_ptr & telegram); + void process_RC20Monitor_2(const std::shared_ptr & telegram); + void process_RC20Set_2(const std::shared_ptr & telegram); + void process_RC10Monitor(const std::shared_ptr & telegram); + void process_RC10Set(const std::shared_ptr & telegram); + void process_RC10Set_2(const std::shared_ptr & telegram); + void process_CRFMonitor(const std::shared_ptr & telegram); + void process_CR11Monitor(const std::shared_ptr & telegram); + void process_RC300Monitor(const std::shared_ptr & telegram); + void process_RC300Set(const std::shared_ptr & telegram); + void process_RC300Set2(const std::shared_ptr & telegram); + void process_RC300Summer(const std::shared_ptr & telegram); + void process_RC300Summer2(const std::shared_ptr & telegram); + void process_RC300WWmode(const std::shared_ptr & telegram); + void process_RC300WWmode2(const std::shared_ptr & telegram); + void process_RC300WWtemp(const std::shared_ptr & telegram); + void process_RC300OutdoorTemp(const std::shared_ptr & telegram); + void process_RC300Settings(const std::shared_ptr & telegram); + void process_RC300Floordry(const std::shared_ptr & telegram); + void process_RC300Holiday(const std::shared_ptr & telegram); + void process_RC300Curve(const std::shared_ptr & telegram); + void process_JunkersMonitor(const std::shared_ptr & telegram); + void process_JunkersSet(const std::shared_ptr & telegram); + void process_JunkersSet2(const std::shared_ptr & telegram); + void process_EasyMonitor(const std::shared_ptr & telegram); + void process_JunkersRemoteMonitor(const std::shared_ptr & telegram); + void process_HybridSettings(const std::shared_ptr & telegram); + void process_PVSettings(const std::shared_ptr & telegram); + void process_Absent(const std::shared_ptr & telegram); + void process_JunkersSetMixer(const std::shared_ptr & telegram); + void process_JunkersWW(const std::shared_ptr & telegram); + void process_JunkersDisp(const std::shared_ptr & telegram); + void process_RemoteTemp(const std::shared_ptr & telegram); + void process_RemoteHumidity(const std::shared_ptr & telegram); + void process_RemoteCorrection(const std::shared_ptr & telegram); + void process_RemoteBattery(const std::shared_ptr & telegram); + void process_HPSet(const std::shared_ptr & telegram); + void process_HPMode(const std::shared_ptr & telegram); + void process_PID(const std::shared_ptr & telegram); // internal helper functions bool set_mode_n(const uint8_t mode, const int8_t id); diff --git a/src/devices/ventilation.cpp b/src/devices/ventilation.cpp index 8473b123d..32f138691 100644 --- a/src/devices/ventilation.cpp +++ b/src/devices/ventilation.cpp @@ -51,12 +51,12 @@ Ventilation::Ventilation(uint8_t device_type, uint8_t device_id, uint8_t product } // message 0x055C, data: 08 01 11 17 -void Ventilation::process_SetMessage(std::shared_ptr telegram) { +void Ventilation::process_SetMessage(const std::shared_ptr & telegram) { has_update(telegram, bypass_, 1); } // message 583 -void Ventilation::process_MonitorMessage(std::shared_ptr telegram) { +void Ventilation::process_MonitorMessage(const std::shared_ptr & telegram) { has_update(telegram, outEx_, 0); // Fortluft has_update(telegram, inEx_, 7); // Abluft has_update(telegram, outFresh_, 13); // Außenluft @@ -69,25 +69,25 @@ void Ventilation::process_MonitorMessage(std::shared_ptr telegra // message 585 26 bytes long // Data: 46 46 00 00 00 77 00 03 F4 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -void Ventilation::process_BlowerMessage(std::shared_ptr telegram) { +void Ventilation::process_BlowerMessage(const std::shared_ptr & telegram) { has_update(telegram, ventOutSpeed_, 0); has_update(telegram, ventInSpeed_, 1); } // message 0x05D9, data: 03 9C FF -void Ventilation::process_VOCMessage(std::shared_ptr telegram) { +void Ventilation::process_VOCMessage(const std::shared_ptr & telegram) { has_update(telegram, voc_, 0); has_update(telegram, humidity_, 2); } // message 0x56B // level 0=0, 1=1, 2=2, 3=3, 4= 4, Auto 0xFF, demand 5, sleep 6, intense 7, bypass-8, party 9, fireplace 0A -void Ventilation::process_ModeMessage(std::shared_ptr telegram) { +void Ventilation::process_ModeMessage(const std::shared_ptr & telegram) { has_enumupdate(telegram, mode_, 0, -1); } // message 0x0587, data: 00 00 64 00 64 0A 00 01 54 01 00 01 00 00 00 46 00 00 00 02 00 A3 00 A3 -void Ventilation::process_BypassMessage(std::shared_ptr telegram) { +void Ventilation::process_BypassMessage(const std::shared_ptr & telegram) { // has_update(telegram, bypass_closing, 0); // has_update(telegram, bypass_opening, 1); } diff --git a/src/devices/ventilation.h b/src/devices/ventilation.h index 6311bab5e..7c31dc7b1 100644 --- a/src/devices/ventilation.h +++ b/src/devices/ventilation.h @@ -41,12 +41,12 @@ class Ventilation : public EMSdevice { uint8_t ventOutSpeed_; // handlers: 0x056B 0x0575 0x0583 0x0585 0x0586 0x0587 0x0588 0x058D 0x058E 0x058F 0x0590 0x05CF 0x05D9 0x05E3 - void process_SetMessage(std::shared_ptr telegram); // 0x55C - void process_MonitorMessage(std::shared_ptr telegram); - void process_ModeMessage(std::shared_ptr telegram); // 0x56B - void process_BlowerMessage(std::shared_ptr telegram); // 0x56B - void process_VOCMessage(std::shared_ptr telegram); // 0x56B - void process_BypassMessage(std::shared_ptr telegram); // 0x56B + void process_SetMessage(const std::shared_ptr & telegram); // 0x55C + void process_MonitorMessage(const std::shared_ptr & telegram); + void process_ModeMessage(const std::shared_ptr & telegram); // 0x56B + void process_BlowerMessage(const std::shared_ptr & telegram); // 0x56B + void process_VOCMessage(const std::shared_ptr & telegram); // 0x56B + void process_BypassMessage(const std::shared_ptr & telegram); // 0x56B bool set_ventMode(const char * value, const int8_t id); bool set_bypass(const char * value, const int8_t id); diff --git a/src/devices/water.cpp b/src/devices/water.cpp index 17bcdf75f..047a44946 100644 --- a/src/devices/water.cpp +++ b/src/devices/water.cpp @@ -107,7 +107,7 @@ Water::Water(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c // SM100wwTemperature - 0x07D6, dhw4: 0x07D7 // Solar Module(0x2A) -> (0x00), (0x7D6), data: 01 C1 00 00 02 5B 01 AF 01 AD 80 00 01 90 -void Water::process_SM100wwTemperature(std::shared_ptr telegram) { +void Water::process_SM100wwTemperature(const std::shared_ptr & telegram) { has_update(telegram, wwTemp_, 0); // is *10 TS17 has_update(telegram, wwFlow_, 2); // is *10 l/min has_update(telegram, wwTemp2_, 4); // is *10 TS21 @@ -120,13 +120,13 @@ void Water::process_SM100wwTemperature(std::shared_ptr telegram) // SM100wwStatus - 0x07AA // Solar Module(0x2A) -> (0x00), (0x7AA), data: 64 00 04 00 03 00 28 01 0F -void Water::process_SM100wwStatus(std::shared_ptr telegram) { +void Water::process_SM100wwStatus(const std::shared_ptr & telegram) { has_update(telegram, wwPump_, 0); } // SM100wwParam - 0x07A6, Solar Module(0x2A) -> (0x00) // data: FF 05 0F 5F 00 01 3C 3C 3C 3C 28 12 46 01 3C 1E 03 07 3C 00 0F 00 05 -void Water::process_SM100wwParam(std::shared_ptr telegram) { +void Water::process_SM100wwParam(const std::shared_ptr & telegram) { has_update(telegram, wwDailyTemp_, 6); has_update(telegram, wwHotTemp_, 7); has_update(telegram, wwMaxTemp_, 8); @@ -137,13 +137,13 @@ void Water::process_SM100wwParam(std::shared_ptr telegram) { has_update(telegram, errorDisp_, 19); } // SM100wwParam2 - 0x07AC, Solar Module(0x2A) -> (0x00) -void Water::process_SM100wwParam2(std::shared_ptr telegram) { +void Water::process_SM100wwParam2(const std::shared_ptr & telegram) { has_update(telegram, wwDeltaTRet_, 1); } // SM100wwCirc - 0x07A5 // Solar Module(0x2A) -> (0x00), (0x7A5), data: -void Water::process_SM100wwCirc(std::shared_ptr telegram) { +void Water::process_SM100wwCirc(const std::shared_ptr & telegram) { has_update(telegram, wwCirc_, 0); has_update(telegram, wwCircMode_, 3); has_update(telegram, wwCircTc_, 4); // time controlled on/off @@ -151,13 +151,13 @@ void Water::process_SM100wwCirc(std::shared_ptr telegram) { // SM100wwKeepWarm - 0x7AE, keepWarm // Thermostat(0x10) -> Solar(0x2A), ?(0x7AE), data: FF -void Water::process_SM100wwKeepWarm(std::shared_ptr telegram) { +void Water::process_SM100wwKeepWarm(const std::shared_ptr & telegram) { has_update(telegram, wwKeepWarm_, 0); } // SM100ValveStatus - 0x7AD, valveStatus // Thermostat(0x10) -> Solar(0x2A), ?(0x7AD), data: -void Water::process_SM100ValveStatus(std::shared_ptr telegram) { +void Water::process_SM100ValveStatus(const std::shared_ptr & telegram) { has_update(telegram, wwRetValve_, 1); } @@ -165,7 +165,7 @@ void Water::process_SM100ValveStatus(std::shared_ptr telegram) { // data: 00 00 46 00 00 01 06 0E 06 0E 00 00 00 00 00 03 03 03 03 // publishes single values offset 1/2(16bit), offset 5, offset 6, offset 7, offset 8, offset 9, // status2 = 03:"no heat", 06:"heat request", 08:"disinfecting", 09:"hold" -void Water::process_SM100wwStatus2(std::shared_ptr telegram) { +void Water::process_SM100wwStatus2(const std::shared_ptr & telegram) { // has_update(telegram, wwFlow_, 7); // single byte, wrong see #1387 has_update(telegram, wwStatus2_, 8); has_update(telegram, wwPumpMod_, 9); @@ -174,7 +174,7 @@ void Water::process_SM100wwStatus2(std::shared_ptr telegram) { // SM100wwCommand - 0x07AB // Thermostat(0x10) -> Solar Module(0x2A), (0x7AB), data: 01 00 01 // or dhw3 module (0x2A) -> dhw4 module(0x2B), (0x7C3), data: 01 01 00 -void Water::process_SM100wwCommand(std::shared_ptr telegram) { +void Water::process_SM100wwCommand(const std::shared_ptr & telegram) { // not implemented yet } @@ -185,14 +185,14 @@ void Water::process_SM100wwCommand(std::shared_ptr telegram) { // Mixer warm water loading/DHW - 0x0331, 0x0332 // e.g. A9 00 FF 00 02 32 02 6C 00 3C 00 3C 3C 46 02 03 03 00 3C // on 0x28 // A8 00 FF 00 02 31 02 35 00 3C 00 3C 3C 46 02 03 03 00 3C // in 0x29 -void Water::process_MMPLUSStatusMessage_WWC(std::shared_ptr telegram) { +void Water::process_MMPLUSStatusMessage_WWC(const std::shared_ptr & telegram) { has_update(telegram, wwTemp_, 0); // is * 10 has_bitupdate(telegram, wwPump_, 2, 0); has_update(telegram, wwStatus_, 11); // temp status } // Config message 0x313, has to be fetched -void Water::process_MMPLUSConfigMessage_WWC(std::shared_ptr telegram) { +void Water::process_MMPLUSConfigMessage_WWC(const std::shared_ptr & telegram) { has_update(telegram, wwRequiredTemp_, 4); has_update(telegram, wwRedTemp_, 5); has_update(telegram, wwDiffTemp_, 7); @@ -203,7 +203,7 @@ void Water::process_MMPLUSConfigMessage_WWC(std::shared_ptr tele // unknown, 2 examples from older threads // Thermostat(0x10) -> Mixer(0x28), ?(0x33B), data: 01 01 00 // Thermostat -> Mixing Module, type 0x023B, telegram: 90 28 FF 00 02 3B 00 02 00 (CRC=68) -void Water::process_MMPLUSSetMessage_WWC(std::shared_ptr telegram) { +void Water::process_MMPLUSSetMessage_WWC(const std::shared_ptr & telegram) { } // MMPLUS telegram 0x345 unknown @@ -216,7 +216,7 @@ void Water::process_MMPLUSSetMessage_WWC(std::shared_ptr telegra // 0x34 only 8 bytes long // Mixer(0x41) -> All(0x00), UBAMonitorWW(0x34), data: 37 02 1E 02 1E 00 00 00 00 -void Water::process_IPMMonitorWW(std::shared_ptr telegram) { +void Water::process_IPMMonitorWW(const std::shared_ptr & telegram) { has_update(telegram, wwSelTemp_, 0); has_update(telegram, wwTemp_, 1); has_update(telegram, wwTemp2_, 3); @@ -224,7 +224,7 @@ void Water::process_IPMMonitorWW(std::shared_ptr telegram) { } // Mixer(0x41) -> Me(0x0B), UBAParameterWW(0x33), data: 08 FF 46 FB FF 28 FF 07 46 00 FF 00 -void Water::process_IPMParameterWW(std::shared_ptr telegram) { +void Water::process_IPMParameterWW(const std::shared_ptr & telegram) { // has_update(telegram, wwActivated_, 1); // 0xFF means on // has_update(telegram, wwSelTemp_, 2); has_update(telegram, wwHystOn_, 3); // Hyst on (default -5) @@ -239,7 +239,7 @@ void Water::process_IPMParameterWW(std::shared_ptr telegram) { // 0x1E, only16 bit temperature // Mixer(0x41) -> Boiler(0x08), HydrTemp(0x1E), data: 01 D8 -void Water::process_IPMHydrTemp(std::shared_ptr telegram) { +void Water::process_IPMHydrTemp(const std::shared_ptr & telegram) { has_update(telegram, HydrTemp_, 0); } diff --git a/src/devices/water.h b/src/devices/water.h index d93b8a5a5..c1c6f28ea 100644 --- a/src/devices/water.h +++ b/src/devices/water.h @@ -82,23 +82,23 @@ class Water : public EMSdevice { uint8_t wwFlowTempOffset_; // default 40 - void process_SM100wwTemperature(std::shared_ptr telegram); - void process_SM100wwStatus(std::shared_ptr telegram); - void process_SM100wwStatus2(std::shared_ptr telegram); - void process_SM100wwCommand(std::shared_ptr telegram); - void process_SM100wwCirc(std::shared_ptr telegram); - void process_SM100wwParam(std::shared_ptr telegram); - void process_SM100wwParam2(std::shared_ptr telegram); - void process_SM100wwKeepWarm(std::shared_ptr telegram); - void process_SM100ValveStatus(std::shared_ptr telegram); + void process_SM100wwTemperature(const std::shared_ptr & telegram); + void process_SM100wwStatus(const std::shared_ptr & telegram); + void process_SM100wwStatus2(const std::shared_ptr & telegram); + void process_SM100wwCommand(const std::shared_ptr & telegram); + void process_SM100wwCirc(const std::shared_ptr & telegram); + void process_SM100wwParam(const std::shared_ptr & telegram); + void process_SM100wwParam2(const std::shared_ptr & telegram); + void process_SM100wwKeepWarm(const std::shared_ptr & telegram); + void process_SM100ValveStatus(const std::shared_ptr & telegram); - void process_MMPLUSStatusMessage_WWC(std::shared_ptr telegram); - void process_MMPLUSSetMessage_WWC(std::shared_ptr telegram); - void process_MMPLUSConfigMessage_WWC(std::shared_ptr telegram); + void process_MMPLUSStatusMessage_WWC(const std::shared_ptr & telegram); + void process_MMPLUSSetMessage_WWC(const std::shared_ptr & telegram); + void process_MMPLUSConfigMessage_WWC(const std::shared_ptr & telegram); - void process_IPMMonitorWW(std::shared_ptr telegram); - void process_IPMHydrTemp(std::shared_ptr telegram); - void process_IPMParameterWW(std::shared_ptr telegram); + void process_IPMMonitorWW(const std::shared_ptr & telegram); + void process_IPMHydrTemp(const std::shared_ptr & telegram); + void process_IPMParameterWW(const std::shared_ptr & telegram); bool set_wwSelTemp(const char * value, const int8_t id); diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 94c9bb024..1e386f1b4 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -705,7 +705,7 @@ void WebCustomEntityService::fetch() { } // called on process telegram, read from telegram -bool WebCustomEntityService::get_value(std::shared_ptr telegram) { +bool WebCustomEntityService::get_value(const std::shared_ptr & telegram) { bool has_change = false; // read-length of BOOL, INT8, UINT8, INT16, UINT16, UINT24, TIME, UINT32 const uint8_t len[] = {1, 1, 1, 2, 2, 3, 3, 4}; diff --git a/src/web/WebCustomEntityService.h b/src/web/WebCustomEntityService.h index 4cfec1ac4..e93d963d4 100644 --- a/src/web/WebCustomEntityService.h +++ b/src/web/WebCustomEntityService.h @@ -62,7 +62,7 @@ class WebCustomEntityService : public StatefulService { bool command_setvalue(const char * value, const int8_t id, const char * name); bool get_value_info(JsonObject output, const char * cmd); void get_value_json(JsonObject output, CustomEntityItem const & entity); - bool get_value(std::shared_ptr telegram); + bool get_value(const std::shared_ptr & telegram); void fetch(); void render_value(JsonObject output, CustomEntityItem const & entity, const bool useVal = false, const bool web = false, const bool add_uom = false); void show_values(JsonObject output); diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 4acfc18a2..5ea045dde 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -70,7 +70,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) { obj["id"] = emsdevice->unique_id(); // a unique id obj["tn"] = emsdevice->device_type_2_device_name_translated(); // translated device type name obj["t"] = emsdevice->device_type(); // device type number - obj["b"] = emsdevice->brand_to_char(); // brand + obj["b"] = emsdevice->brand_to_cstr(); // brand obj["n"] = emsdevice->name(); // custom name obj["d"] = emsdevice->device_id(); // deviceid obj["p"] = emsdevice->product_id(); // productid