From 0f14e9db3b2fe14217428649be96feb3fc5461fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Wed, 14 Aug 2024 16:52:19 +0300 Subject: [PATCH 01/17] Resolved conflicts, fixed indentation, renamed log parameters, implemented debug_log_messages functionality, and corrected repository source address in the YAML file. --- components/samsung_ac/__init__.py | 38 +++ components/samsung_ac/protocol.cpp | 4 +- components/samsung_ac/protocol.h | 8 +- components/samsung_ac/protocol_nasa.cpp | 345 ++++++++++++++------ components/samsung_ac/protocol_nasa.h | 3 + components/samsung_ac/protocol_non_nasa.cpp | 6 +- components/samsung_ac/samsung_ac.h | 29 +- components/samsung_ac/samsung_ac_device.h | 50 ++- example.yaml | 12 + 9 files changed, 377 insertions(+), 118 deletions(-) diff --git a/components/samsung_ac/__init__.py b/components/samsung_ac/__init__.py index e7251a3e..74088120 100644 --- a/components/samsung_ac/__init__.py +++ b/components/samsung_ac/__init__.py @@ -58,9 +58,12 @@ CONF_DEVICE_TARGET_TEMPERATURE = "target_temperature" CONF_DEVICE_WATER_OUTLET_TARGET = "water_outlet_target" CONF_DEVICE_OUTDOOR_TEMPERATURE = "outdoor_temperature" +CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE = "indoor_eva_in_temperature" +CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE = "indoor_eva_out_temperature" CONF_DEVICE_WATER_TEMPERATURE = "water_temperature" CONF_DEVICE_WATER_TARGET_TEMPERATURE = "water_target_temperature" CONF_DEVICE_POWER = "power" +CONF_DEVICE_AUTOMATIC_CLEANING = "automatic_cleaning" CONF_DEVICE_WATER_HEATER_POWER = "water_heater_power" CONF_DEVICE_MODE = "mode" CONF_DEVICE_WATER_HEATER_MODE = "water_heater_mode" @@ -182,11 +185,24 @@ def humidity_sensor_schema(message: int): accuracy_decimals=1, device_class=DEVICE_CLASS_TEMPERATURE, state_class=STATE_CLASS_MEASUREMENT, + ), + cv.Optional(CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE): sensor.sensor_schema( + unit_of_measurement=UNIT_CELSIUS, + accuracy_decimals=1, + device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, + ), + cv.Optional(CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE): sensor.sensor_schema( + unit_of_measurement=UNIT_CELSIUS, + accuracy_decimals=1, + device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, ), cv.Optional(CONF_DEVICE_TARGET_TEMPERATURE): NUMBER_SCHEMA, cv.Optional(CONF_DEVICE_WATER_OUTLET_TARGET): NUMBER_SCHEMA, cv.Optional(CONF_DEVICE_WATER_TARGET_TEMPERATURE): NUMBER_SCHEMA, cv.Optional(CONF_DEVICE_POWER): switch.switch_schema(Samsung_AC_Switch), + cv.Optional(CONF_DEVICE_AUTOMATIC_CLEANING): switch.switch_schema(Samsung_AC_Switch), cv.Optional(CONF_DEVICE_WATER_HEATER_POWER): switch.switch_schema(Samsung_AC_Switch), cv.Optional(CONF_DEVICE_MODE): SELECT_MODE_SCHEMA, cv.Optional(CONF_DEVICE_WATER_HEATER_MODE): SELECT_WATER_HEATER_MODE_SCHEMA, @@ -217,6 +233,9 @@ def humidity_sensor_schema(message: int): CONF_NON_NASA_KEEPALIVE = "non_nasa_keepalive" +CONF_DEBUG_LOG_UNDEFINED_MESSAGES = "debug_log_undefined_messages" + + CONFIG_SCHEMA = ( cv.Schema( { @@ -229,6 +248,7 @@ def humidity_sensor_schema(message: int): cv.Optional(CONF_DEBUG_LOG_MESSAGES, default=False): cv.boolean, cv.Optional(CONF_DEBUG_LOG_MESSAGES_RAW, default=False): cv.boolean, cv.Optional(CONF_NON_NASA_KEEPALIVE, default=False): cv.boolean, + cv.Optional(CONF_DEBUG_LOG_UNDEFINED_MESSAGES, default=False): cv.boolean, cv.Optional(CONF_CAPABILITIES): CAPABILITIES_SCHEMA, cv.Required(CONF_DEVICES): cv.ensure_list(DEVICE_SCHEMA), } @@ -300,6 +320,11 @@ async def to_code(config): sens = await switch.new_switch(conf) cg.add(var_dev.set_power_switch(sens)) + if CONF_DEVICE_AUTOMATIC_CLEANING in device: + conf = device[CONF_DEVICE_AUTOMATIC_CLEANING] + sens = await switch.new_switch(conf) + cg.add(var_dev.set_automatic_cleaning_switch(sens)) + if CONF_DEVICE_WATER_HEATER_POWER in device: conf = device[CONF_DEVICE_WATER_HEATER_POWER] sens = await switch.new_switch(conf) @@ -318,6 +343,16 @@ async def to_code(config): conf = device[CONF_DEVICE_OUTDOOR_TEMPERATURE] sens = await sensor.new_sensor(conf) cg.add(var_dev.set_outdoor_temperature_sensor(sens)) + + if CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE in device: + conf = device[CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE] + sens = await sensor.new_sensor(conf) + cg.add(var_dev.set_indoor_eva_in_temperature_sensor(sens)) + + if CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE in device: + conf = device[CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE] + sens = await sensor.new_sensor(conf) + cg.add(var_dev.set_indoor_eva_out_temperature_sensor(sens)) if CONF_DEVICE_WATER_TARGET_TEMPERATURE in device: conf = device[CONF_DEVICE_WATER_TARGET_TEMPERATURE] @@ -398,6 +433,9 @@ async def to_code(config): if (CONF_NON_NASA_KEEPALIVE in config): cg.add(var.set_non_nasa_keepalive(config[CONF_NON_NASA_KEEPALIVE])) + + if (CONF_DEBUG_LOG_UNDEFINED_MESSAGES in config): + cg.add(var.set_debug_log_undefined_messages(config[CONF_DEBUG_LOG_UNDEFINED_MESSAGES])) await cg.register_component(var, config) await uart.register_uart_device(var, config) diff --git a/components/samsung_ac/protocol.cpp b/components/samsung_ac/protocol.cpp index dbd67ba8..676a0524 100644 --- a/components/samsung_ac/protocol.cpp +++ b/components/samsung_ac/protocol.cpp @@ -8,9 +8,11 @@ namespace esphome { namespace samsung_ac { - bool debug_log_packets = false; + //bool debug_log_packets = false; bool debug_log_raw_bytes = false; bool non_nasa_keepalive = false; + bool debug_log_undefined_messages = false; + bool debug_log_messages = false; ProtocolProcessing protocol_processing = ProtocolProcessing::Auto; // This functions is designed to run after a new value was added diff --git a/components/samsung_ac/protocol.h b/components/samsung_ac/protocol.h index 6efda558..fbd83658 100644 --- a/components/samsung_ac/protocol.h +++ b/components/samsung_ac/protocol.h @@ -8,9 +8,11 @@ namespace esphome { namespace samsung_ac { - extern bool debug_log_packets; + //extern bool debug_log_packets; extern bool debug_log_raw_bytes; extern bool non_nasa_keepalive; + extern bool debug_log_undefined_messages; + extern bool debug_log_messages; enum class DecodeResult { @@ -76,11 +78,14 @@ namespace esphome virtual void publish_data(std::vector &data) = 0; virtual void register_address(const std::string address) = 0; virtual void set_power(const std::string address, bool value) = 0; + virtual void set_automatic_cleaning(const std::string address, bool value) = 0; virtual void set_water_heater_power(const std::string address, bool value) = 0; virtual void set_room_temperature(const std::string address, float value) = 0; virtual void set_target_temperature(const std::string address, float value) = 0; virtual void set_water_outlet_target(const std::string address, float value) = 0; virtual void set_outdoor_temperature(const std::string address, float value) = 0; + virtual void set_indoor_eva_in_temperature(const std::string address, float value) = 0; + virtual void set_indoor_eva_out_temperature(const std::string address, float value) = 0; virtual void set_target_water_temperature(const std::string address, float value) = 0; virtual void set_mode(const std::string address, Mode mode) = 0; virtual void set_water_heater_mode(const std::string address, WaterHeaterMode waterheatermode) = 0; @@ -96,6 +101,7 @@ namespace esphome { public: optional power; + optional automatic_cleaning; optional water_heater_power; optional mode; optional waterheatermode; diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index c0a4d3af..ae9ec189 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -379,7 +379,7 @@ namespace esphome mode.value = (int)request.mode.value(); packet.messages.push_back(mode); } - + if (request.waterheatermode) { request.water_heater_power = true; // ensure system turns on when mode is set @@ -396,6 +396,13 @@ namespace esphome packet.messages.push_back(power); } + if (request.automatic_cleaning) + { + MessageSet automatic_cleaning(MessageNumber::ENUM_in_operation_automatic_cleaning); + automatic_cleaning.value = request.automatic_cleaning.value() ? 1 : 0; + packet.messages.push_back(automatic_cleaning); + } + if (request.water_heater_power) { MessageSet waterheaterpower(MessageNumber::ENUM_in_water_heater_power); @@ -409,14 +416,14 @@ namespace esphome targettemp.value = request.target_temp.value() * 10.0; packet.messages.push_back(targettemp); } - + if (request.water_outlet_target) { MessageSet wateroutlettarget(MessageNumber::VAR_in_temp_water_outlet_target_f); wateroutlettarget.value = request.water_outlet_target.value() * 10.0; packet.messages.push_back(wateroutlettarget); } - + if (request.target_water_temp) { MessageSet targetwatertemp(MessageNumber::VAR_in_temp_water_heater_target_f); @@ -480,7 +487,7 @@ namespace esphome return Mode::Unknown; } } - + WaterHeaterMode water_heater_mode_to_waterheatermode(int value) { switch (value) @@ -532,17 +539,23 @@ namespace esphome { if (debug_mqtt_connected()) { - if (message.type == MessageSetType::Enum) - { - debug_mqtt_publish("samsung_ac/nasa/enum/" + long_to_hex((uint16_t)message.messageNumber), std::to_string(message.value)); - } - else if (message.type == MessageSetType::Variable) - { - debug_mqtt_publish("samsung_ac/nasa/var/" + long_to_hex((uint16_t)message.messageNumber), std::to_string(message.value)); - } - else if (message.type == MessageSetType::LongVariable) + std::string topic_prefix = "samsung_ac/nasa/"; + std::string topic_suffix = long_to_hex((uint16_t)message.messageNumber); + std::string payload = std::to_string(message.value); + + switch (message.type) { - debug_mqtt_publish("samsung_ac/nasa/var_long/" + long_to_hex((uint16_t)message.messageNumber), std::to_string(message.value)); + case MessageSetType::Enum: + debug_mqtt_publish(topic_prefix + "enum/" + topic_suffix, payload); + break; + case MessageSetType::Variable: + debug_mqtt_publish(topic_prefix + "var/" + topic_suffix, payload); + break; + case MessageSetType::LongVariable: + debug_mqtt_publish(topic_prefix + "var_long/" + topic_suffix, payload); + break; + default: + break; } } @@ -556,55 +569,88 @@ namespace esphome case MessageNumber::VAR_in_temp_room_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_room_f %f", source.c_str(), dest.c_str(), temp); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_room_f %f", source.c_str(), dest.c_str(), temp); + } target->set_room_temperature(source, temp); - return; + break; } case MessageNumber::VAR_in_temp_target_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - // if (value == 1) value = 'waterOutSetTemp'; //action in xml - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_target_f %f", source.c_str(), dest.c_str(), temp); + if (debug_log_messages) + { + // if (value == 1) value = 'waterOutSetTemp'; //action in xml + ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_target_f %f", source.c_str(), dest.c_str(), temp); + } target->set_target_temperature(source, temp); - return; + break; } case MessageNumber::VAR_in_temp_water_outlet_target_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_outlet_target_f %f", source.c_str(), dest.c_str(), temp); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_outlet_target_f %f", source.c_str(), dest.c_str(), temp); + } target->set_water_outlet_target(source, temp); - return; + break; } case MessageNumber::VAR_in_temp_water_heater_target_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_heater_target_f %f", source.c_str(), dest.c_str(), temp); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_heater_target_f %f", source.c_str(), dest.c_str(), temp); + } target->set_target_water_temperature(source, temp); - return; + break; } case MessageNumber::ENUM_in_state_humidity_percent: { - // XML Enum no value but in Code it adds unit - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_state_humidity_percent %li", source.c_str(), dest.c_str(), message.value); - return; + if (debug_log_messages) + { + // XML Enum no value but in Code it adds unit + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_state_humidity_percent %li", source.c_str(), dest.c_str(), message.value); + } + break; } case MessageNumber::ENUM_in_operation_power: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_power %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_power %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); + } target->set_power(source, message.value != 0); - return; + break; + } + case MessageNumber::ENUM_in_operation_automatic_cleaning: + { + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_automatic_cleaning %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); + } + target->set_automatic_cleaning(source, message.value != 0); + break; } case MessageNumber::ENUM_in_water_heater_power: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_water_heater_power %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_water_heater_power %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); + } target->set_water_heater_power(source, message.value != 0); - return; + break; } case MessageNumber::ENUM_in_operation_mode: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_mode %li", source.c_str(), dest.c_str(), message.value); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_mode %li", source.c_str(), dest.c_str(), message.value); + } target->set_mode(source, operation_mode_to_mode(message.value)); - return; + break; } case MessageNumber::ENUM_in_water_heater_mode: { @@ -614,7 +660,10 @@ namespace esphome } case MessageNumber::ENUM_in_fan_mode: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_mode %li", source.c_str(), dest.c_str(), message.value); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_mode %li", source.c_str(), dest.c_str(), message.value); + } FanMode mode = FanMode::Unknown; if (message.value == 0) mode = FanMode::Auto; @@ -627,112 +676,184 @@ namespace esphome else if (message.value == 4) mode = FanMode::Turbo; target->set_fanmode(source, mode); - return; + break; } case MessageNumber::ENUM_in_fan_mode_real: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_mode_real %li", source.c_str(), dest.c_str(), message.value); - return; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_mode_real %li", source.c_str(), dest.c_str(), message.value); + } + break; } case MessageNumber::ENUM_in_alt_mode: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_alt_mode %li", source.c_str(), dest.c_str(), message.value); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_alt_mode %li", source.c_str(), dest.c_str(), message.value); + } target->set_altmode(source, message.value); - return; + break; } case MessageNumber::ENUM_in_louver_hl_swing: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_hl_swing %li", source.c_str(), dest.c_str(), message.value); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_hl_swing %li", source.c_str(), dest.c_str(), message.value); + } target->set_swing_vertical(source, message.value == 1); - return; + break; } case MessageNumber::ENUM_in_louver_lr_swing: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_lr_swing %li", source.c_str(), dest.c_str(), message.value); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_lr_swing %li", source.c_str(), dest.c_str(), message.value); + } target->set_swing_horizontal(source, message.value == 1); - return; + break; } case MessageNumber::VAR_in_temp_water_tank_f: { - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_tank_f %li", source.c_str(), dest.c_str(), message.value); - return; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_tank_f %li", source.c_str(), dest.c_str(), message.value); + } + break; } case MessageNumber::VAR_out_sensor_airout: { double temp = (double)((int16_t)message.value) / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_out_sensor_airout %li", source.c_str(), dest.c_str(), message.value); + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_out_sensor_airout %li", source.c_str(), dest.c_str(), message.value); + } target->set_outdoor_temperature(source, temp); - return; + break; } - - default: + case MessageNumber::VAR_IN_TEMP_EVA_IN_F: { - if ((uint16_t)message.messageNumber == 0x4260) + double temp = ((int16_t)message.value) / 10.0; + if (debug_log_messages) { - // VAR_IN_FSV_3021 - double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3021 %f", source.c_str(), dest.c_str(), temp); - return; + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_TEMP_EVA_IN_F %li", source.c_str(), dest.c_str(), message.value); } - if ((uint16_t)message.messageNumber == 0x4261) + target->set_indoor_eva_in_temperature(source, temp); + break; + } + case MessageNumber::VAR_IN_TEMP_EVA_OUT_F: + { + double temp = ((int16_t)message.value) / 10.0; + if (debug_log_messages) { - // VAR_IN_FSV_3022 - double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3022 %f", source.c_str(), dest.c_str(), temp); - return; + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_TEMP_EVA_OUT_F %li", source.c_str(), dest.c_str(), message.value); } - if ((uint16_t)message.messageNumber == 0x4262) + target->set_indoor_eva_out_temperature(source, temp); + break; + } + default: + { + double value = 0; + switch ((uint16_t)message.messageNumber) { + case 0x4260: + // VAR_IN_FSV_3021 + value = (double)message.value / 10.0; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3021 %f", source.c_str(), dest.c_str(), value); + } + break; + + case 0x4261: + // VAR_IN_FSV_3022 + value = (double)message.value / 10.0; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3022 %f", source.c_str(), dest.c.str(), value); + } + break; + + case 0x4262: // VAR_IN_FSV_3023 - double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3023 %f", source.c_str(), dest.c_str(), temp); - return; - } + value = (double)message.value / 10.0; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3023 %f", source.c_str(), dest.c.str(), value); + } + break; - if ((uint16_t)message.messageNumber == 0x8414) - { - // LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM - double kwh = (double)message.value / (double)1000; - ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM %fkwh", source.c_str(), dest.c_str(), kwh); - return; - } - if ((uint16_t)message.messageNumber == 0x8413) - { - // LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM - double value = (double)message.value; - ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM %f", source.c_str(), dest.c_str(), value); - return; - } - if ((uint16_t)message.messageNumber == 0x8411) - { - double value = (double)message.value; - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT %f", source.c_str(), dest.c_str(), value); - return; - } - if ((uint16_t)message.messageNumber == 0x8427) - { - double value = (double)message.value; - ESP_LOGW(TAG, "s:%s d:%s total produced energy %f", source.c_str(), dest.c_str(), value); - return; - } - if ((uint16_t)message.messageNumber == 0x8426) - { - double value = (double)message.value; - ESP_LOGW(TAG, "s:%s d:%s actual produced energy %f", source.c_str(), dest.c_str(), value); - return; - } - if ((uint16_t)message.messageNumber == 0x8415) - { - double value = (double)message.value; - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM %f", source.c_str(), dest.c_str(), value); - return; - } - if ((uint16_t)message.messageNumber == 0x8416) - { - double value = (double)message.value; - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM %f", source.c_str(), dest.c_str(), value); - return; + case 0x8414: + // LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM + value = (double)message.value / 1000.0; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM %fkwh", source.c.str(), dest.c.str(), value); + } + break; + + case 0x8413: + // LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM + value = (double)message.value; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM %f", source.c.str(), dest.c.str(), value); + } + break; + + case 0x8411: + // NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT + value = (double)message.value; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT %f", source.c.str(), dest.c.str(), value); + } + break; + + case 0x8427: + // Total produced energy + value = (double)message.value; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s total produced energy %f", source.c.str(), dest.c.str(), value); + } + break; + + case 0x8426: + // Actual produced energy + value = (double)message.value; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s actual produced energy %f", source.c.str(), dest.c.str(), value); + } + break; + + case 0x8415: + // NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM + value = (double)message.value; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM %f", source.c.str(), dest.c.str(), value); + } + break; + + case 0x8416: + // NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM + value = (double)message.value; + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM %f", source.c.str(), dest.c.str(), value); + } + break; + + default: + if (debug_log_undefined_messages) + { + ESP_LOGW(TAG, "Undefined s:%s d:%s %s", source.c.str(), dest.c.str(), message.to_string().c.str()); + } + break; } + break; } } } @@ -749,7 +870,7 @@ namespace esphome target->register_address(source); - if (debug_log_packets) + if (debug_log_messages) { ESP_LOGW(TAG, "MSG: %s", packet_.to_string().c_str()); } @@ -1183,10 +1304,18 @@ namespace esphome case 0x600: // STR_ad_option_basic case 0x202: // VAR_ad_error_code1 case 0x42d1: // VAR_IN_DUST_SENSOR_PM10_0_VALUE + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM10_0_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); + return; // Ingore cause not important + } case 0x42d2: // VAR_IN_DUST_SENSOR_PM2_5_VALUE + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM2_5_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); + return; // Ingore cause not important + } case 0x42d3: // VAR_IN_DUST_SENSOR_PM1_0_VALUE { - // ESP_LOGW(TAG, "s:%s d:%s Ignore %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM1_0_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); return; // Ingore cause not important } diff --git a/components/samsung_ac/protocol_nasa.h b/components/samsung_ac/protocol_nasa.h index 4951cc48..bac55ffb 100644 --- a/components/samsung_ac/protocol_nasa.h +++ b/components/samsung_ac/protocol_nasa.h @@ -71,6 +71,7 @@ namespace esphome { Undefiend = 0, ENUM_in_operation_power = 0x4000, + ENUM_in_operation_automatic_cleaning = 0x4111, ENUM_in_water_heater_power = 0x4065, ENUM_in_operation_mode = 0x4001, ENUM_in_water_heater_mode = 0x4066, @@ -86,6 +87,8 @@ namespace esphome VAR_in_temp_water_tank_f = 0x4237, VAR_out_sensor_airout = 0x8204, VAR_in_temp_water_heater_target_f = 0x4235, + VAR_IN_TEMP_EVA_IN_F = 0x4205, + VAR_IN_TEMP_EVA_OUT_F = 0x4206, }; struct Address diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index af5d70ce..bc4aad13 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -538,7 +538,7 @@ namespace esphome void process_non_nasa_packet(MessageTarget *target) { - if (debug_log_packets) + if (debug_log_messages) { ESP_LOGW(TAG, "MSG: %s", nonpacket_.to_string().c_str()); } @@ -564,7 +564,7 @@ namespace esphome item.request.fanspeed == nonpacket_.command20.fanspeed && item.request.mode == nonpacket_.command20.mode && item.request.power == nonpacket_.command20.power; }); - + // If a state update comes through after a control message has been sent, but before it // has been acknowledged, it should be ignored. This prevents the UI status bouncing // between states after a command has been issued. @@ -591,7 +591,7 @@ namespace esphome // TODO target->set_water_heater_power(nonpacket_.src, false); target->set_mode(nonpacket_.src, nonnasa_mode_to_mode(nonpacket_.command20.mode)); - // TODO + // TODO target->set_water_heater_mode(nonpacket_.src, nonnasa_water_heater_mode_to_mode(-0)); target->set_fanmode(nonpacket_.src, nonnasa_fanspeed_to_fanmode(nonpacket_.command20.fanspeed)); // TODO diff --git a/components/samsung_ac/samsung_ac.h b/components/samsung_ac/samsung_ac.h index e8cb559e..800ec621 100644 --- a/components/samsung_ac/samsung_ac.h +++ b/components/samsung_ac/samsung_ac.h @@ -39,7 +39,7 @@ namespace esphome void set_debug_log_messages(bool value) { - debug_log_packets = value; + debug_log_messages = value; } void set_debug_log_messages_raw(bool value) @@ -51,7 +51,10 @@ namespace esphome { non_nasa_keepalive = value; } - + void set_debug_log_undefined_messages(bool value) + { + debug_log_undefined_messages = value; + } void register_device(Samsung_AC_Device *device); void /*MessageTarget::*/ register_address(const std::string address) override @@ -80,13 +83,27 @@ namespace esphome dev->update_outdoor_temperature(value); } + void /*MessageTarget::*/ set_indoor_eva_in_temperature(const std::string address, float value) override + { + Samsung_AC_Device *dev = find_device(address); + if (dev != nullptr) + dev->update_indoor_eva_in_temperature(value); + } + + void /*MessageTarget::*/ set_indoor_eva_out_temperature(const std::string address, float value) override + { + Samsung_AC_Device *dev = find_device(address); + if (dev != nullptr) + dev->update_indoor_eva_out_temperature(value); + } + void /*MessageTarget::*/ set_target_temperature(const std::string address, float value) override { Samsung_AC_Device *dev = find_device(address); if (dev != nullptr) dev->update_target_temperature(value); } - + void /*MessageTarget::*/ set_water_outlet_target(const std::string address, float value) override { Samsung_AC_Device *dev = find_device(address); @@ -107,6 +124,12 @@ namespace esphome if (dev != nullptr) dev->update_power(value); } + void /*MessageTarget::*/ set_automatic_cleaning(const std::string address, bool value) override + { + Samsung_AC_Device *dev = find_device(address); + if (dev != nullptr) + dev->update_automatic_cleaning(value); + } void /*MessageTarget::*/ set_water_heater_power(const std::string address, bool value) override { Samsung_AC_Device *dev = find_device(address); diff --git a/components/samsung_ac/samsung_ac_device.h b/components/samsung_ac/samsung_ac_device.h index b503dba5..376d3408 100644 --- a/components/samsung_ac/samsung_ac_device.h +++ b/components/samsung_ac/samsung_ac_device.h @@ -105,10 +105,13 @@ namespace esphome std::string address; sensor::Sensor *room_temperature{nullptr}; sensor::Sensor *outdoor_temperature{nullptr}; + sensor::Sensor *indoor_eva_in_temperature{nullptr}; + sensor::Sensor *indoor_eva_out_temperature{nullptr}; Samsung_AC_Number *target_temperature{nullptr}; Samsung_AC_Number *water_outlet_target{nullptr}; Samsung_AC_Number *target_water_temperature{nullptr}; Samsung_AC_Switch *power{nullptr}; + Samsung_AC_Switch *automatic_cleaning{nullptr}; Samsung_AC_Switch *water_heater_power{nullptr}; Samsung_AC_Mode_Select *mode{nullptr}; Samsung_AC_Water_Heater_Mode_Select *waterheatermode{nullptr}; @@ -126,6 +129,16 @@ namespace esphome outdoor_temperature = sensor; } + void set_indoor_eva_in_temperature_sensor(sensor::Sensor *sensor) + { + indoor_eva_in_temperature = sensor; + } + + void set_indoor_eva_out_temperature_sensor(sensor::Sensor *sensor) + { + indoor_eva_out_temperature = sensor; + } + void add_custom_sensor(int message_number, sensor::Sensor *sensor) { Samsung_AC_Sensor cust_sensor; @@ -153,6 +166,17 @@ namespace esphome }; } + void set_automatic_cleaning_switch(Samsung_AC_Switch *switch_) + { + automatic_cleaning = switch_; + automatic_cleaning->write_state_ = [this](bool value) + { + ProtocolRequest request; + request.automatic_cleaning = value; + publish_request(request); + }; + } + void set_water_heater_power_switch(Samsung_AC_Switch *switch_) { water_heater_power = switch_; @@ -196,7 +220,7 @@ namespace esphome publish_request(request); }; }; - + void set_water_outlet_target_number(Samsung_AC_Number *number) { water_outlet_target = number; @@ -235,7 +259,7 @@ namespace esphome climate->publish_state(); } } - + void update_water_outlet_target(float value) { if (water_outlet_target != nullptr) @@ -249,6 +273,7 @@ namespace esphome } optional _cur_power; + optional _cur_automatic_cleaning; optional _cur_water_heater_power; optional _cur_mode; optional _cur_water_heater_mode; @@ -262,6 +287,15 @@ namespace esphome calc_and_publish_mode(); } + void update_automatic_cleaning(bool value) + { + _cur_automatic_cleaning = value; + if (automatic_cleaning != nullptr) + automatic_cleaning->publish_state(value); + if (climate != nullptr) + calc_and_publish_mode(); + } + void update_water_heater_power(bool value) { _cur_water_heater_power = value; @@ -369,6 +403,18 @@ namespace esphome outdoor_temperature->publish_state(value); } + void update_indoor_eva_in_temperature(float value) + { + if (indoor_eva_in_temperature != nullptr) + indoor_eva_in_temperature->publish_state(value); + } + + void update_indoor_eva_out_temperature(float value) + { + if (indoor_eva_out_temperature != nullptr) + indoor_eva_out_temperature->publish_state(value); + } + void update_custom_sensor(uint16_t message_number, float value) { for (auto &sensor : custom_sensors) diff --git a/example.yaml b/example.yaml index b918c5e0..2d44a418 100644 --- a/example.yaml +++ b/example.yaml @@ -56,6 +56,12 @@ samsung_ac: # For NonNASA devices the following option can be enabled to prevent the device from sleeping when idle. This allows # values like internal and external temperature to continue to be tracked when the device isn't in use. non_nasa_keepalive: true + + #When enabled (set to true), this option will log the messages associated with undefined codes on the device. This is useful for debugging and identifying any unexpected or unknown codes that the device may receive during operation. + debug_log_undefined_messages: false + + #When enabled (set to true), this option logs messages associated with defined codes on the device. This helps in monitoring the behavior of the device by recording the activity related to known, expected codes. + debug_log_messages: false # Capabilities configure the features alle devices of your AC system have (all parts of this section are optional). # All capabilities are off by default, you need to enable only those your devices have. @@ -105,6 +111,12 @@ samsung_ac: mode: name: "Kitchen mode" + #Add automatic_cleaning mode for Samsung AC NASA + #- Added the "automatic_cleaning" feature to the Samsung AC integration. + #- This mode ensures hygienic drying of all moisture in the indoor unit after the cooling process is completed. + automatic_cleaning: + name: "Kitchen automatic clean" + # If your AC sits near or inside the ceiling, the reported room temperature is often a little bit heigher then whats # measured below. This property can be used to correct that value. room_temperature_offset: -1.4 From 00fade92f73d8d88c4340a993700434f025ec2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Wed, 14 Aug 2024 17:18:24 +0300 Subject: [PATCH 02/17] Fixed typo in logging code: corrected c.str() to c_str() for proper string formatting in ESP_LOGW calls. --- components/samsung_ac/protocol_nasa.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index ae9ec189..1b89da5e 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -770,7 +770,7 @@ namespace esphome value = (double)message.value / 10.0; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3022 %f", source.c_str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3022 %f", source.c_str(), dest.c_str(), value); } break; @@ -779,7 +779,7 @@ namespace esphome value = (double)message.value / 10.0; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3023 %f", source.c_str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3023 %f", source.c_str(), dest.c_str(), value); } break; @@ -788,7 +788,7 @@ namespace esphome value = (double)message.value / 1000.0; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM %fkwh", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM %fkwh", source.c_str(), dest.c_str(), value); } break; @@ -797,7 +797,7 @@ namespace esphome value = (double)message.value; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM %f", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM %f", source.c_str(), dest.c_str(), value); } break; @@ -806,7 +806,7 @@ namespace esphome value = (double)message.value; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT %f", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT %f", source.c_str(), dest.c_str(), value); } break; @@ -815,7 +815,7 @@ namespace esphome value = (double)message.value; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s total produced energy %f", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s total produced energy %f", source.c_str(), dest.c_str(), value); } break; @@ -824,7 +824,7 @@ namespace esphome value = (double)message.value; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s actual produced energy %f", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s actual produced energy %f", source.c_str(), dest.c_str(), value); } break; @@ -833,7 +833,7 @@ namespace esphome value = (double)message.value; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM %f", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM %f", source.c_str(), dest.c_str(), value); } break; @@ -842,14 +842,14 @@ namespace esphome value = (double)message.value; if (debug_log_messages) { - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM %f", source.c.str(), dest.c.str(), value); + ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM %f", source.c_str(), dest.c_str(), value); } break; default: if (debug_log_undefined_messages) { - ESP_LOGW(TAG, "Undefined s:%s d:%s %s", source.c.str(), dest.c.str(), message.to_string().c.str()); + ESP_LOGW(TAG, "Undefined s:%s d:%s %s", source.c_str(), dest.c_str(), message.to_string().c_str()); } break; } From 663e53f3b1e061daa65bcfaab5dce104e236383a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 19:20:01 +0300 Subject: [PATCH 03/17] Comment lines removed. Fix indentation issue in protocol.cpp --- components/samsung_ac/protocol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/samsung_ac/protocol.cpp b/components/samsung_ac/protocol.cpp index 676a0524..11b8e5c1 100644 --- a/components/samsung_ac/protocol.cpp +++ b/components/samsung_ac/protocol.cpp @@ -8,11 +8,11 @@ namespace esphome { namespace samsung_ac { - //bool debug_log_packets = false; bool debug_log_raw_bytes = false; bool non_nasa_keepalive = false; bool debug_log_undefined_messages = false; - bool debug_log_messages = false; + bool debug_log_messages = false; + ProtocolProcessing protocol_processing = ProtocolProcessing::Auto; // This functions is designed to run after a new value was added From ad3f7da81f87877542050ec496d72d3275b931c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 19:22:30 +0300 Subject: [PATCH 04/17] Remove unused debug_log_packets declaration from protocol.h --- components/samsung_ac/protocol.h | 1 - 1 file changed, 1 deletion(-) diff --git a/components/samsung_ac/protocol.h b/components/samsung_ac/protocol.h index fbd83658..87760425 100644 --- a/components/samsung_ac/protocol.h +++ b/components/samsung_ac/protocol.h @@ -8,7 +8,6 @@ namespace esphome { namespace samsung_ac { - //extern bool debug_log_packets; extern bool debug_log_raw_bytes; extern bool non_nasa_keepalive; extern bool debug_log_undefined_messages; From 365ff85a21aee30430e3ff03c3120263ce6e1fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 19:59:53 +0300 Subject: [PATCH 05/17] =?UTF-8?q?LOG=5FMESSAGE=20macro=20d=C3=BCzenlemesi?= =?UTF-8?q?=20ve=20Optimize=20string=20conversions=20for=20better=20perfor?= =?UTF-8?q?mance=20in=20protocol=5Fnasa.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/samsung_ac/protocol_nasa.cpp | 184 +++++++----------------- 1 file changed, 51 insertions(+), 133 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index 1b89da5e..a2df9a8e 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -21,6 +21,12 @@ namespace esphome return value - (int)65535 /*uint16 max*/ - 1.0; } +#define LOG_MESSAGE(message_name, temp, source, dest) \ + if (debug_log_messages) \ + { \ + ESP_LOGW(TAG, "s:%s d:%s " #message_name " %f", source.c_str(), dest.c_str(), temp); \ + } + uint16_t crc16(std::vector &data, int startIndex, int length) { uint16_t crc = 0; @@ -539,9 +545,20 @@ namespace esphome { if (debug_mqtt_connected()) { - std::string topic_prefix = "samsung_ac/nasa/"; - std::string topic_suffix = long_to_hex((uint16_t)message.messageNumber); - std::string payload = std::to_string(message.value); + static const std::string topic_prefix = "samsung_ac/nasa/"; + std::string topic_suffix; + std::string payload; + + if (message.messageNumber != 0) + { + topic_suffix = long_to_hex((uint16_t)message.messageNumber); + payload = std::to_string(message.value); + } + else + { + topic_suffix.clear(); + payload.clear(); + } switch (message.type) { @@ -566,104 +583,72 @@ namespace esphome switch (message.messageNumber) { - case MessageNumber::VAR_in_temp_room_f: // unit = 'Celsius' from XML + case MessageNumber::VAR_in_temp_room_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_room_f %f", source.c_str(), dest.c_str(), temp); - } + LOG_MESSAGE(VAR_in_temp_room_f, temp, source, dest); target->set_room_temperature(source, temp); break; } case MessageNumber::VAR_in_temp_target_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - if (debug_log_messages) - { - // if (value == 1) value = 'waterOutSetTemp'; //action in xml - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_target_f %f", source.c_str(), dest.c_str(), temp); - } + LOG_MESSAGE(VAR_in_temp_target_f, temp, source, dest); target->set_target_temperature(source, temp); break; } case MessageNumber::VAR_in_temp_water_outlet_target_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_outlet_target_f %f", source.c_str(), dest.c_str(), temp); - } + LOG_MESSAGE(VAR_in_temp_water_outlet_target_f, temp, source, dest); target->set_water_outlet_target(source, temp); break; } case MessageNumber::VAR_in_temp_water_heater_target_f: // unit = 'Celsius' from XML { double temp = (double)message.value / (double)10; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_heater_target_f %f", source.c_str(), dest.c_str(), temp); - } + LOG_MESSAGE(VAR_in_temp_water_heater_target_f, temp, source, dest); target->set_target_water_temperature(source, temp); break; } case MessageNumber::ENUM_in_state_humidity_percent: { - if (debug_log_messages) - { - // XML Enum no value but in Code it adds unit - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_state_humidity_percent %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_state_humidity_percent, (double)message.value, source, dest); break; } case MessageNumber::ENUM_in_operation_power: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_power %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); - } + LOG_MESSAGE(ENUM_in_operation_power, (double)message.value, source, dest); target->set_power(source, message.value != 0); break; } case MessageNumber::ENUM_in_operation_automatic_cleaning: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_automatic_cleaning %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); - } + LOG_MESSAGE(ENUM_in_operation_automatic_cleaning, (double)message.value, source, dest); target->set_automatic_cleaning(source, message.value != 0); break; } case MessageNumber::ENUM_in_water_heater_power: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_water_heater_power %s", source.c_str(), dest.c_str(), message.value == 0 ? "off" : "on"); - } + LOG_MESSAGE(ENUM_in_water_heater_power, (double)message.value, source, dest); target->set_water_heater_power(source, message.value != 0); break; } case MessageNumber::ENUM_in_operation_mode: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_mode %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_operation_mode, (double)message.value, source, dest); target->set_mode(source, operation_mode_to_mode(message.value)); break; } case MessageNumber::ENUM_in_water_heater_mode: { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_water_heater_mode %li", source.c_str(), dest.c_str(), message.value); + LOG_MESSAGE(ENUM_in_water_heater_mode, (double)message.value, source, dest); target->set_water_heater_mode(source, water_heater_mode_to_waterheatermode(message.value)); return; } case MessageNumber::ENUM_in_fan_mode: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_mode %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_fan_mode, (double)message.value, source, dest); FanMode mode = FanMode::Unknown; if (message.value == 0) mode = FanMode::Auto; @@ -680,74 +665,50 @@ namespace esphome } case MessageNumber::ENUM_in_fan_mode_real: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_mode_real %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_fan_mode_real, (double)message.value, source, dest); break; } case MessageNumber::ENUM_in_alt_mode: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_alt_mode %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_alt_mode, (double)message.value, source, dest); target->set_altmode(source, message.value); break; } case MessageNumber::ENUM_in_louver_hl_swing: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_hl_swing %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_louver_hl_swing, (double)message.value, source, dest); target->set_swing_vertical(source, message.value == 1); break; } case MessageNumber::ENUM_in_louver_lr_swing: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_lr_swing %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(ENUM_in_louver_lr_swing, (double)message.value, source, dest); target->set_swing_horizontal(source, message.value == 1); break; } case MessageNumber::VAR_in_temp_water_tank_f: { - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_water_tank_f %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(VAR_in_temp_water_tank_f, (double)message.value, source, dest); break; } case MessageNumber::VAR_out_sensor_airout: { double temp = (double)((int16_t)message.value) / (double)10; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_out_sensor_airout %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(VAR_out_sensor_airout, temp, source, dest); target->set_outdoor_temperature(source, temp); break; } case MessageNumber::VAR_IN_TEMP_EVA_IN_F: { double temp = ((int16_t)message.value) / 10.0; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_TEMP_EVA_IN_F %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(VAR_IN_TEMP_EVA_IN_F, temp, source, dest); target->set_indoor_eva_in_temperature(source, temp); break; } case MessageNumber::VAR_IN_TEMP_EVA_OUT_F: { double temp = ((int16_t)message.value) / 10.0; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_TEMP_EVA_OUT_F %li", source.c_str(), dest.c_str(), message.value); - } + LOG_MESSAGE(VAR_IN_TEMP_EVA_OUT_F, temp, source, dest); target->set_indoor_eva_out_temperature(source, temp); break; } @@ -757,93 +718,53 @@ namespace esphome switch ((uint16_t)message.messageNumber) { case 0x4260: - // VAR_IN_FSV_3021 value = (double)message.value / 10.0; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3021 %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(VAR_IN_FSV_3021, value, source, dest); break; case 0x4261: - // VAR_IN_FSV_3022 value = (double)message.value / 10.0; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3022 %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(VAR_IN_FSV_3022, value, source, dest); break; case 0x4262: - // VAR_IN_FSV_3023 value = (double)message.value / 10.0; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_FSV_3023 %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(VAR_IN_FSV_3023, value, source, dest); break; case 0x8414: - // LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM value = (double)message.value / 1000.0; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM %fkwh", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM, value, source, dest); break; case 0x8413: - // LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM value = (double)message.value; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM, value, source, dest); break; case 0x8411: - // NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT value = (double)message.value; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT, value, source, dest); break; case 0x8427: - // Total produced energy value = (double)message.value; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s total produced energy %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(total_produced_energy, value, source, dest); break; case 0x8426: - // Actual produced energy value = (double)message.value; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s actual produced energy %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(actual_produced_energy, value, source, dest); break; case 0x8415: - // NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM value = (double)message.value; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM, value, source, dest); break; case 0x8416: - // NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM value = (double)message.value; - if (debug_log_messages) - { - ESP_LOGW(TAG, "s:%s d:%s NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM %f", source.c_str(), dest.c_str(), value); - } + LOG_MESSAGE(NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM_ACCUM, value, source, dest); break; default: @@ -870,10 +791,7 @@ namespace esphome target->register_address(source); - if (debug_log_messages) - { - ESP_LOGW(TAG, "MSG: %s", packet_.to_string().c_str()); - } + LOG_MESSAGE(MSG, packet_.to_string().c_str(), "", ""); if (packet_.command.dataType == DataType::Ack) { From e31e0f6d500a0ef26b946a50eb50ee3dc1741418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 20:06:04 +0300 Subject: [PATCH 06/17] =?UTF-8?q?LOG=5FMESSAGE=20macro=20d=C3=BCzenlemesi?= =?UTF-8?q?=20ve=20Optimize=20string=20conversions=20for=20better=20perfor?= =?UTF-8?q?mance=20in=20protocol=5Fnasa.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/samsung_ac/protocol_nasa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index a2df9a8e..5b69f33e 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -549,7 +549,7 @@ namespace esphome std::string topic_suffix; std::string payload; - if (message.messageNumber != 0) + if (static_cast(message.messageNumber) != 0) { topic_suffix = long_to_hex((uint16_t)message.messageNumber); payload = std::to_string(message.value); @@ -791,7 +791,7 @@ namespace esphome target->register_address(source); - LOG_MESSAGE(MSG, packet_.to_string().c_str(), "", ""); + LOG_MESSAGE(MSG, packet_.to_string().c_str(), source.c_str(), dest.c_str()); if (packet_.command.dataType == DataType::Ack) { From f1dfa5ad2dc9e9e27324971d2e0af002a87f1c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 20:09:15 +0300 Subject: [PATCH 07/17] LOG_MESSAGE opt.. --- components/samsung_ac/protocol_nasa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index 5b69f33e..fef7d5a5 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -791,7 +791,7 @@ namespace esphome target->register_address(source); - LOG_MESSAGE(MSG, packet_.to_string().c_str(), source.c_str(), dest.c_str()); + LOG_MESSAGE(MSG, packet_.to_string().c_str(), source, dest); if (packet_.command.dataType == DataType::Ack) { From c4a656c3dd0c71668c3c0e0cb0fbdb6a4bff0c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 20:17:54 +0300 Subject: [PATCH 08/17] Synced casing for VAR_IN_TEMP_EVA_IN_F and VAR_IN_TEMP_EVA_OUT_F with other values in protocol_nasa.h --- components/samsung_ac/protocol_nasa.cpp | 8 ++++---- components/samsung_ac/protocol_nasa.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index fef7d5a5..fc285b00 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -698,17 +698,17 @@ namespace esphome target->set_outdoor_temperature(source, temp); break; } - case MessageNumber::VAR_IN_TEMP_EVA_IN_F: + case MessageNumber::VAR_in_temp_eva_in_f: { double temp = ((int16_t)message.value) / 10.0; - LOG_MESSAGE(VAR_IN_TEMP_EVA_IN_F, temp, source, dest); + LOG_MESSAGE(VAR_in_temp_eva_in_f, temp, source, dest); target->set_indoor_eva_in_temperature(source, temp); break; } - case MessageNumber::VAR_IN_TEMP_EVA_OUT_F: + case MessageNumber::VAR_in_temp_eva_out_f: { double temp = ((int16_t)message.value) / 10.0; - LOG_MESSAGE(VAR_IN_TEMP_EVA_OUT_F, temp, source, dest); + LOG_MESSAGE(VAR_in_temp_eva_out_f, temp, source, dest); target->set_indoor_eva_out_temperature(source, temp); break; } diff --git a/components/samsung_ac/protocol_nasa.h b/components/samsung_ac/protocol_nasa.h index bac55ffb..ff1fd25e 100644 --- a/components/samsung_ac/protocol_nasa.h +++ b/components/samsung_ac/protocol_nasa.h @@ -87,8 +87,8 @@ namespace esphome VAR_in_temp_water_tank_f = 0x4237, VAR_out_sensor_airout = 0x8204, VAR_in_temp_water_heater_target_f = 0x4235, - VAR_IN_TEMP_EVA_IN_F = 0x4205, - VAR_IN_TEMP_EVA_OUT_F = 0x4206, + VAR_in_temp_eva_in_f = 0x4205, + VAR_in_temp_eva_out_f = 0x4206, }; struct Address From dac91feb69c35379fd1b0d3745e54b5e50b59d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:14:41 +0300 Subject: [PATCH 09/17] debug_log_messages --- components/samsung_ac/protocol_nasa.cpp | 182 +++++++++++++----------- 1 file changed, 95 insertions(+), 87 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index fc285b00..4889889a 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -791,7 +791,10 @@ namespace esphome target->register_address(source); - LOG_MESSAGE(MSG, packet_.to_string().c_str(), source, dest); + if (debug_log_undefined_messages) + { + ESP_LOGW(TAG, "MSG: %s", packet_.to_string().c_str()); + } if (packet_.command.dataType == DataType::Ack) { @@ -847,67 +850,66 @@ namespace esphome void process_messageset_debug(std::string source, std::string dest, MessageSet &message, MessageTarget *target) { - if (source == "20.00.00" || - source == "20.00.01" || - source == "20.00.03") + if (source == "20.00.00" || source == "20.00.01" || source == "20.00.03") return; + if (((uint16_t)message.messageNumber) == 0x4003) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_OPERATION_VENT_POWER %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_OPERATION_VENT_POWER, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x4004) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_OPERATION_VENT_MODE %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_OPERATION_VENT_MODE, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x4011) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_LOUVER_HL_SWING %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x4012) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_louver_hl_part_swing %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_in_louver_hl_part_swing, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x4060) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_ALTERNATIVE_MODE %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_ALTERNATIVE_MODE, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x406E) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_QUIET_MODE %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_QUIET_MODE, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x4119) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_OPERATION_POWER_ZONE1 %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_OPERATION_POWER_ZONE1, message.value, source, dest); + break; } if (((uint16_t)message.messageNumber) == 0x411E) { - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_OPERATION_POWER_ZONE2 %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_OPERATION_POWER_ZONE2, message.value, source, dest); + break; } - return; + // return; //The use of return here was breaking the code here, I didn't understand why it was breaking it, so I made a temporary comment line. switch ((uint16_t)message.messageNumber) { case 0x4002: // ENUM_in_operation_mode_real { // Todo Map - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_operation_mode_real %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_in_operation_mode_real, message.value, source, dest); + break; } case 0x4008: // ENUM_in_fan_vent_mode { - ESP_LOGW(TAG, "s:%s d:%s ENUM_in_fan_vent_mode %li", source.c_str(), dest.c_str(), message.value); + LOG_MESSAGE(ENUM_in_fan_vent_mode, message.value, source, dest); // fan_vent_mode_to_fanmode(); - return; + break; } case 0x4011: // ENUM_IN_LOUVER_HL_SWING @@ -921,156 +923,156 @@ namespace esphome default: return undefined; */ - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_LOUVER_HL_SWING %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); + break; } case 0x4012: // ENUM_IN_LOUVER_HL_SWING { // Todo Map - ESP_LOGW(TAG, "s:%s d:%s ENUM_IN_LOUVER_HL_SWING %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); + break; } case 0x4205: // VAR_in_temp_eva_in_f unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_eva_in_f %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_in_temp_eva_in_f, temp, source, dest); + break; } case 0x4206: // VAR_in_temp_eva_out_f unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_in_temp_eva_out_f %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_in_temp_eva_out_f, temp, source, dest); + break; } case 0x4211: // VAR_in_capacity_request unit = 'kW' { double temp = (double)message.value / (double)8.6; - ESP_LOGW(TAG, "s:%s d:%s VAR_in_capacity_request %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_in_capacity_request, temp, source, dest); + break; } case 0x8001: // ENUM_out_operation_odu_mode { // Todo Map - ESP_LOGW(TAG, "s:%s d:%s ENUM_out_operation_odu_mode %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_out_operation_odu_mode, message.value, source, dest); + break; } case 0x8003: // ENUM_out_operation_heatcool { //['Undefined', 'Cool', 'Heat', 'CoolMain', 'HeatMain']; // Todo Map - ESP_LOGW(TAG, "s:%s d:%s ENUM_out_operation_heatcool %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_out_operation_heatcool, message.value, source, dest); + break; } case 0x801a: // ENUM_out_load_4way { - ESP_LOGW(TAG, "s:%s d:%s ENUM_out_load_4way %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(ENUM_out_load_4way, message.value, source, dest); + break; } case 0x8235: // VAR_out_error_code { - ESP_LOGW(TAG, "s:%s d:%s VAR_out_error_code %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(VAR_out_error_code, message.value, source, dest); + break; } case 0x8261: // VAR_OUT_SENSOR_PIPEIN3 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEIN3 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN3, temp, source, dest); + break; } case 0x8262: // VAR_OUT_SENSOR_PIPEIN4 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEIN4 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN4, temp, source, dest); + break; } case 0x8263: // VAR_OUT_SENSOR_PIPEIN5 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEIN5 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN5, temp, source, dest); + break; } case 0x8264: // VAR_OUT_SENSOR_PIPEOUT1 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEOUT1 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT1, temp, source, dest); + break; } case 0x8265: // VAR_OUT_SENSOR_PIPEOUT2 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEOUT2 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT2, temp, source, dest); + break; } case 0x8266: // VAR_OUT_SENSOR_PIPEOUT3 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEOUT3 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT3, temp, source, dest); + break; } case 0x8267: // VAR_OUT_SENSOR_PIPEOUT4 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEOUT4 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT4, temp, source, dest); + break; } case 0x8268: // VAR_OUT_SENSOR_PIPEOUT5 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_SENSOR_PIPEOUT5 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT5, temp, source, dest); + break; } case 0x8274: // VAR_out_control_order_cfreq_comp2 { - ESP_LOGW(TAG, "s:%s d:%s VAR_out_control_order_cfreq_comp2 %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(VAR_out_control_order_cfreq_comp2, message.value, source, dest); + break; } case 0x8275: // VAR_out_control_target_cfreq_comp2 { - ESP_LOGW(TAG, "s:%s d:%s VAR_out_control_target_cfreq_comp2 %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(VAR_out_control_target_cfreq_comp2, message.value, source, dest); + break; } case 0x82bc: // VAR_OUT_PROJECT_CODE { - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_PROJECT_CODE %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(VAR_OUT_PROJECT_CODE, message.value, source, dest); + break; } case 0x82e3: // VAR_OUT_PRODUCT_OPTION_CAPA { - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_PRODUCT_OPTION_CAPA %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(VAR_OUT_PRODUCT_OPTION_CAPA, message.value, source, dest); + break; } case 0x8280: // VAR_out_sensor_top1 unit = 'Celsius' { double temp = (double)message.value / (double)10; - ESP_LOGW(TAG, "s:%s d:%s VAR_out_sensor_top1 %f", source.c_str(), dest.c_str(), temp); - return; + LOG_MESSAGE(VAR_out_sensor_top1, temp, source, dest); + break; } case 0x82db: // VAR_OUT_PHASE_CURRENT { - ESP_LOGW(TAG, "s:%s d:%s VAR_OUT_PHASE_CURRENT %li", source.c_str(), dest.c_str(), message.value); - return; + LOG_MESSAGE(VAR_OUT_PHASE_CURRENT, message.value, source, dest); + break; } case 0x402: @@ -1212,7 +1214,7 @@ namespace esphome case 0x24fc: { // ESP_LOGW(TAG, "s:%s d:%s Todo %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); - return; // Todo + break; // Todo } case 0x8601: // STR_out_install_inverter_and_bootloader_info @@ -1222,20 +1224,23 @@ namespace esphome case 0x600: // STR_ad_option_basic case 0x202: // VAR_ad_error_code1 case 0x42d1: // VAR_IN_DUST_SENSOR_PM10_0_VALUE - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM10_0_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); - return; // Ingore cause not important - } + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM10_0_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); + } + break; // Ingore cause not important case 0x42d2: // VAR_IN_DUST_SENSOR_PM2_5_VALUE - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM2_5_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); - return; // Ingore cause not important - } + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM2_5_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); + } + break; // Ingore cause not important case 0x42d3: // VAR_IN_DUST_SENSOR_PM1_0_VALUE - { - ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM1_0_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); - return; // Ingore cause not important - } + if (debug_log_messages) + { + ESP_LOGW(TAG, "s:%s d:%s VAR_IN_DUST_SENSOR_PM1_0_VALUE %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); + } + break; // Ingore cause not important case 0x23: case 0x61d: @@ -1282,13 +1287,16 @@ namespace esphome case 0x4006: { // ESP_LOGW(TAG, "s:%s d:%s NoMap %s %li", source.c_str(), dest.c_str(), long_to_hex((int)message.messageNumber).c_str(), message.value); - return; // message types witch have no mapping in xml + break; // message types witch have no mapping in xml } default: - ESP_LOGW(TAG, "s:%s d:%s !! unknown %s", source.c_str(), dest.c_str(), message.to_string().c_str()); + if (debug_log_undefined_messages) + { + ESP_LOGW(TAG, "s:%s d:%s !! unknown %s", source.c_str(), dest.c_str(), message.to_string().c_str()); + } + break; } - return; } void NasaProtocol::protocol_update(MessageTarget *target) From 8563eb35219753a3024b86b29db1bdeeee1d704a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:24:59 +0300 Subject: [PATCH 10/17] switch case --- components/samsung_ac/protocol_nasa.cpp | 89 +++---------------------- 1 file changed, 11 insertions(+), 78 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index 4889889a..736a3336 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -853,65 +853,42 @@ namespace esphome if (source == "20.00.00" || source == "20.00.01" || source == "20.00.03") return; - if (((uint16_t)message.messageNumber) == 0x4003) + // return; //The use of return here was breaking the code here, I didn't understand why it was breaking it, so I made a temporary comment line. + + switch ((uint16_t)message.messageNumber) { + case 0x4003: LOG_MESSAGE(ENUM_IN_OPERATION_VENT_POWER, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x4004) - { + case 0x4004: LOG_MESSAGE(ENUM_IN_OPERATION_VENT_MODE, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x4011) - { + case == 0x4011: LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x4012) - { + case == 0x4012: LOG_MESSAGE(ENUM_in_louver_hl_part_swing, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x4060) - { + case 0x4060: LOG_MESSAGE(ENUM_IN_ALTERNATIVE_MODE, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x406E) - { + case 0x406E: LOG_MESSAGE(ENUM_IN_QUIET_MODE, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x4119) - { + case 0x4119: LOG_MESSAGE(ENUM_IN_OPERATION_POWER_ZONE1, message.value, source, dest); break; - } - if (((uint16_t)message.messageNumber) == 0x411E) - { + case 0x411E: LOG_MESSAGE(ENUM_IN_OPERATION_POWER_ZONE2, message.value, source, dest); break; - } - - // return; //The use of return here was breaking the code here, I didn't understand why it was breaking it, so I made a temporary comment line. - - switch ((uint16_t)message.messageNumber) - { case 0x4002: // ENUM_in_operation_mode_real - { // Todo Map LOG_MESSAGE(ENUM_in_operation_mode_real, message.value, source, dest); break; - } - case 0x4008: // ENUM_in_fan_vent_mode - { LOG_MESSAGE(ENUM_in_fan_vent_mode, message.value, source, dest); // fan_vent_mode_to_fanmode(); break; - } - case 0x4011: // ENUM_IN_LOUVER_HL_SWING { // Todo Map @@ -928,152 +905,108 @@ namespace esphome } case 0x4012: // ENUM_IN_LOUVER_HL_SWING - { // Todo Map LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); break; - } case 0x4205: // VAR_in_temp_eva_in_f unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_in_temp_eva_in_f, temp, source, dest); break; - } case 0x4206: // VAR_in_temp_eva_out_f unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_in_temp_eva_out_f, temp, source, dest); break; - } case 0x4211: // VAR_in_capacity_request unit = 'kW' - { double temp = (double)message.value / (double)8.6; LOG_MESSAGE(VAR_in_capacity_request, temp, source, dest); break; - } case 0x8001: // ENUM_out_operation_odu_mode - { // Todo Map LOG_MESSAGE(ENUM_out_operation_odu_mode, message.value, source, dest); break; - } case 0x8003: // ENUM_out_operation_heatcool - { //['Undefined', 'Cool', 'Heat', 'CoolMain', 'HeatMain']; // Todo Map LOG_MESSAGE(ENUM_out_operation_heatcool, message.value, source, dest); break; - } case 0x801a: // ENUM_out_load_4way - { LOG_MESSAGE(ENUM_out_load_4way, message.value, source, dest); break; - } case 0x8235: // VAR_out_error_code - { LOG_MESSAGE(VAR_out_error_code, message.value, source, dest); break; - } case 0x8261: // VAR_OUT_SENSOR_PIPEIN3 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN3, temp, source, dest); break; - } case 0x8262: // VAR_OUT_SENSOR_PIPEIN4 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN4, temp, source, dest); break; - } case 0x8263: // VAR_OUT_SENSOR_PIPEIN5 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN5, temp, source, dest); break; - } case 0x8264: // VAR_OUT_SENSOR_PIPEOUT1 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT1, temp, source, dest); break; - } case 0x8265: // VAR_OUT_SENSOR_PIPEOUT2 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT2, temp, source, dest); break; - } case 0x8266: // VAR_OUT_SENSOR_PIPEOUT3 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT3, temp, source, dest); break; - } case 0x8267: // VAR_OUT_SENSOR_PIPEOUT4 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT4, temp, source, dest); break; - } case 0x8268: // VAR_OUT_SENSOR_PIPEOUT5 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT5, temp, source, dest); break; - } case 0x8274: // VAR_out_control_order_cfreq_comp2 - { LOG_MESSAGE(VAR_out_control_order_cfreq_comp2, message.value, source, dest); break; - } case 0x8275: // VAR_out_control_target_cfreq_comp2 - { LOG_MESSAGE(VAR_out_control_target_cfreq_comp2, message.value, source, dest); break; - } case 0x82bc: // VAR_OUT_PROJECT_CODE - { LOG_MESSAGE(VAR_OUT_PROJECT_CODE, message.value, source, dest); break; - } case 0x82e3: // VAR_OUT_PRODUCT_OPTION_CAPA - { LOG_MESSAGE(VAR_OUT_PRODUCT_OPTION_CAPA, message.value, source, dest); break; - } case 0x8280: // VAR_out_sensor_top1 unit = 'Celsius' - { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_out_sensor_top1, temp, source, dest); break; - } case 0x82db: // VAR_OUT_PHASE_CURRENT - { LOG_MESSAGE(VAR_OUT_PHASE_CURRENT, message.value, source, dest); break; - } case 0x402: case 0x409: From 5ecd3c9657ba82f3b9993b913c69b139f86c42ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:25:54 +0300 Subject: [PATCH 11/17] :) --- components/samsung_ac/protocol_nasa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index 736a3336..c5ac1f0e 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -853,7 +853,7 @@ namespace esphome if (source == "20.00.00" || source == "20.00.01" || source == "20.00.03") return; - // return; //The use of return here was breaking the code here, I didn't understand why it was breaking it, so I made a temporary comment line. + return; // :) switch ((uint16_t)message.messageNumber) { From 152a85f58adef27fad2a86878f5e329e692ed069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:27:54 +0300 Subject: [PATCH 12/17] :) --- components/samsung_ac/protocol_nasa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index c5ac1f0e..a2231526 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -863,10 +863,10 @@ namespace esphome case 0x4004: LOG_MESSAGE(ENUM_IN_OPERATION_VENT_MODE, message.value, source, dest); break; - case == 0x4011: + case 0x4011: LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); break; - case == 0x4012: + case 0x4012: LOG_MESSAGE(ENUM_in_louver_hl_part_swing, message.value, source, dest); break; case 0x4060: From 76c9a6cc464373869abdb618cb57e918dd0693ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:31:46 +0300 Subject: [PATCH 13/17] . --- components/samsung_ac/protocol_nasa.cpp | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index a2231526..4dc72935 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -911,20 +911,23 @@ namespace esphome break; case 0x4205: // VAR_in_temp_eva_in_f unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_in_temp_eva_in_f, temp, source, dest); break; - + } case 0x4206: // VAR_in_temp_eva_out_f unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_in_temp_eva_out_f, temp, source, dest); break; - + } case 0x4211: // VAR_in_capacity_request unit = 'kW' + { double temp = (double)message.value / (double)8.6; LOG_MESSAGE(VAR_in_capacity_request, temp, source, dest); break; - + } case 0x8001: // ENUM_out_operation_odu_mode // Todo Map LOG_MESSAGE(ENUM_out_operation_odu_mode, message.value, source, dest); @@ -945,45 +948,53 @@ namespace esphome break; case 0x8261: // VAR_OUT_SENSOR_PIPEIN3 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN3, temp, source, dest); break; - + } case 0x8262: // VAR_OUT_SENSOR_PIPEIN4 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN4, temp, source, dest); break; - + } case 0x8263: // VAR_OUT_SENSOR_PIPEIN5 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEIN5, temp, source, dest); break; - + } case 0x8264: // VAR_OUT_SENSOR_PIPEOUT1 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT1, temp, source, dest); break; - + } case 0x8265: // VAR_OUT_SENSOR_PIPEOUT2 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT2, temp, source, dest); break; - + } case 0x8266: // VAR_OUT_SENSOR_PIPEOUT3 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT3, temp, source, dest); break; - + } case 0x8267: // VAR_OUT_SENSOR_PIPEOUT4 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT4, temp, source, dest); break; - + } case 0x8268: // VAR_OUT_SENSOR_PIPEOUT5 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_OUT_SENSOR_PIPEOUT5, temp, source, dest); break; - + } case 0x8274: // VAR_out_control_order_cfreq_comp2 LOG_MESSAGE(VAR_out_control_order_cfreq_comp2, message.value, source, dest); break; @@ -1000,10 +1011,11 @@ namespace esphome break; case 0x8280: // VAR_out_sensor_top1 unit = 'Celsius' + { double temp = (double)message.value / (double)10; LOG_MESSAGE(VAR_out_sensor_top1, temp, source, dest); break; - + } case 0x82db: // VAR_OUT_PHASE_CURRENT LOG_MESSAGE(VAR_OUT_PHASE_CURRENT, message.value, source, dest); break; From dfe51d966a0b62e0f2951c974eb1339ac5c899c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:34:40 +0300 Subject: [PATCH 14/17] repeated messagenumber --- components/samsung_ac/protocol_nasa.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index 4dc72935..5984bffc 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -889,27 +889,6 @@ namespace esphome LOG_MESSAGE(ENUM_in_fan_vent_mode, message.value, source, dest); // fan_vent_mode_to_fanmode(); break; - case 0x4011: // ENUM_IN_LOUVER_HL_SWING - { - // Todo Map - /* - case 0: - return 'Off'; - case 1: - return 'On'; - default: - return undefined; - */ - LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); - break; - } - - case 0x4012: // ENUM_IN_LOUVER_HL_SWING - // Todo Map - - LOG_MESSAGE(ENUM_IN_LOUVER_HL_SWING, message.value, source, dest); - break; - case 0x4205: // VAR_in_temp_eva_in_f unit = 'Celsius' { double temp = (double)message.value / (double)10; @@ -1057,7 +1036,6 @@ namespace esphome case 0x4047: case 0x4048: case 0x4059: - case 0x4060: case 0x4074: case 0x407d: case 0x407e: From b75d921bd15de70d8a165fbd07e3386880b48222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 21:36:51 +0300 Subject: [PATCH 15/17] process_messageset_debug return disable --- components/samsung_ac/protocol_nasa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index 5984bffc..7e43a53e 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -853,7 +853,7 @@ namespace esphome if (source == "20.00.00" || source == "20.00.01" || source == "20.00.03") return; - return; // :) + // return; // :) switch ((uint16_t)message.messageNumber) { From 1dd4edcf4deab2bad5a863001bbf3297e8208b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Fri, 16 Aug 2024 22:01:18 +0300 Subject: [PATCH 16/17] protocol_non_nasa.cpp debug_log_messages changes --- components/samsung_ac/protocol_non_nasa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index bc4aad13..2e9bdc13 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -538,7 +538,7 @@ namespace esphome void process_non_nasa_packet(MessageTarget *target) { - if (debug_log_messages) + if (debug_log_undefined_messages) { ESP_LOGW(TAG, "MSG: %s", nonpacket_.to_string().c_str()); } From 2dc2554a9a50a66dd0117d704017ba6e6e9a2cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20ARAN?= Date: Sat, 17 Aug 2024 01:37:22 +0300 Subject: [PATCH 17/17] Added debug_log_messages check for update messages received every 30 seconds --- components/samsung_ac/samsung_ac.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/samsung_ac/samsung_ac.cpp b/components/samsung_ac/samsung_ac.cpp index d445db81..d0215fd8 100644 --- a/components/samsung_ac/samsung_ac.cpp +++ b/components/samsung_ac/samsung_ac.cpp @@ -10,12 +10,18 @@ namespace esphome { void Samsung_AC::setup() { - ESP_LOGW(TAG, "setup"); + if (debug_log_messages) + { + ESP_LOGW(TAG, "setup"); + } } void Samsung_AC::update() { - ESP_LOGW(TAG, "update"); + if (debug_log_messages) + { + ESP_LOGW(TAG, "update"); + } debug_mqtt_connect(debug_mqtt_host, debug_mqtt_port, debug_mqtt_username, debug_mqtt_password);