From 61384bc4fc62277af6951ac04be598d35b0696b4 Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 20:36:53 +0100 Subject: [PATCH 01/15] included cmd c0 c1 f0 and f1 --- components/samsung_ac/protocol_non_nasa.h | 63 +++++++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.h b/components/samsung_ac/protocol_non_nasa.h index 7177e73f..e426dc6f 100644 --- a/components/samsung_ac/protocol_non_nasa.h +++ b/components/samsung_ac/protocol_non_nasa.h @@ -37,7 +37,7 @@ namespace esphome Stop = 31 }; - struct NonNasaCommand20 + struct NonNasaCommand20 // from indoor units { uint8_t target_temp = 0; uint8_t room_temp = 0; @@ -53,6 +53,27 @@ namespace esphome std::string to_string(); }; + struct NonNasaCommandC0 // from outdoor unit + { + uint8_t outdoor_unit_operation_mode = 0; + bool outdoor_unit_4_way_valve = false; + bool outdoor_unit_hot_gas_bypass = false; + bool outdoor_unit_compressor = false; + bool outdoor_unit_ac_fan = false; + uint8_t outdoor_unit_outdoor_temp_c = 0; + uint8_t outdoor_unit_discharge_temp_c = 0; + uint8_t outdoor_unit_condenser_mid_temp_c = 0; + + std::string to_string(); + }; + + struct NonNasaCommandC1 // from outdoor unit + { + uint8_t outdoor_unit_sump_temp_c = 0; + + std::string to_string(); + }; + struct NonNasaCommandC6 { bool control_status = false; @@ -62,7 +83,34 @@ namespace esphome }; }; - struct NonNasaCommandF3 + struct NonNasaCommandF0 // from outdoor unit + { + bool outdoor_unit_freeze_protection = false; + bool outdoor_unit_heating_overload = false; + bool outdoor_unit_defrost_control = false; + bool outdoor_unit_discharge_protection = false; + bool outdoor_unit_current_control = false; + uint8_t inverter_order_frequency_hz = 0; + uint8_t inverter_target_frequency_hz = 0; + uint8_t inverter_current_frequency_hz = 0; + bool outdoor_unit_bldc_fan = false; + uint8_t outdoor_unit_error_code = 0; + + std::string to_string(); + }; + + struct NonNasaCommandF1 // from outdoor unit + { + uint16_t outdoor_unit_EEV_A = 0; + uint16_t outdoor_unit_EEV_B = 0; + uint16_t outdoor_unit_EEV_C = 0; + uint16_t outdoor_unit_EEV_D = 0; + + std::string to_string(); + }; + + + struct NonNasaCommandF3 // from outdoor unit { uint8_t inverter_max_frequency_hz = 0; float inverter_total_capacity_requirement_kw = 0; @@ -73,7 +121,6 @@ namespace esphome std::string to_string(); }; - struct NonNasaCommandRaw { uint8_t length; @@ -89,8 +136,12 @@ namespace esphome enum class NonNasaCommand : uint8_t { Cmd20 = 0x20, + CmdC0 = 0xc0, + CmdC1 = 0xc1, CmdC6 = 0xc6, - CmdF3 = 0xf3, + CmdF0 = 0xf0, + CmdF1 = 0xf1, + CmdF3 = 0xf3, CmdF8 = 0xF8, }; @@ -108,7 +159,11 @@ namespace esphome union { NonNasaCommand20 command20; + NonNasaCommandC0 commandC0; + NonNasaCommandC1 commandC1; NonNasaCommandC6 commandC6; + NonNasaCommandF0 commandF0; + NonNasaCommandF1 commandF1; NonNasaCommandF3 commandF3; NonNasaCommandRaw commandF8; // Unknown structure for now NonNasaCommandRaw commandRaw; From 5a22882bd1dddedffd52ae7374cce15cdf671edf Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:03:23 +0100 Subject: [PATCH 02/15] added debug-strings for c0 c1 f0 and f1 --- components/samsung_ac/protocol_non_nasa.cpp | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index d6408daa..cbfef256 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -39,6 +39,54 @@ namespace esphome return str; } + std::string NonNasaCommandC0::to_string() + { + std::string str; + str += "ou_operation_mode:" + long_to_hex((uint8_t)outdoor_unit_operation_mode) + ";"; + str += "ou_4way_valve:" + std::to_string(outdoor_unit_4_way_valve ? 1 : 0) + ";"; + str += "ou_hot_gas_bypass:" + std::to_string(outdoor_unit_hot_gas_bypass ? 1 : 0) + ";"; + str += "ou_compressor:" + std::to_string(outdoor_unit_compressor ? 1 : 0) + ";"; + str += "ou_ac_fan:" + std::to_string(outdoor_unit_ac_fan ? 1 : 0) + ";"; + str += "ou_outdoor_temp[°C]:" + std::to_string(outdoor_unit_outdoor_temp_c) + ";"; + str += "ou_discharge_temp[°C]:" + std::to_string(outdoor_unit_discharge_temp_c) + ";"; + str += "ou_condenser_mid_temp[°C]:" + std::to_string(outdoor_unit_condenser_mid_temp_c) + ";"; + return str; + } + + std::string NonNasaCommandC1::to_string() + { + std::string str; + str += "ou_sump_temp[°C]:" + std::to_string(outdoor_unit_sump_temp_c) + ";"; + return str; + } + + std::string NonNasaCommandF0::to_string() + { + std::string str; + str += "ou_freeze_protection:" + std::to_string(outdoor_unit_freeze_protection ? 1 : 0) + ";"; + str += "ou_heating_overload:" + std::to_string(outdoor_unit_heating_overload ? 1 : 0) + ";"; + str += "ou_defrost_control:" + std::to_string(outdoor_unit_defrost_control ? 1 : 0) + ";"; + str += "ou_discharge_protection:" + std::to_string(outdoor_unit_discharge_protectionn ? 1 : 0) + ";"; + str += "ou_current_control:" + std::to_string(outdoor_unit_current_control ? 1 : 0) + ";"; + str += "inverter_order_frequency[Hz]:" + std::to_string(inverter_order_frequency_hz) + ";"; + str += "inverter_target_frequency[Hz]:" + std::to_string(inverter_target_frequency_hz) + ";"; + str += "inverter_current_frequency[Hz]:" + std::to_string(inverter_current_frequency_hz) + ";"; + str += "ou_bldc_fan:" + std::to_string(outdoor_unit_bldc_fan ? 1 : 0) + ";"; + str += "ou_error_code:" + long_to_hex((uint8_t)outdoor_unit_error_code) + ";"; + return str; + } + + std::string NonNasaCommandF1::to_string() + { + std::string str; + str += "Electronic Expansion Valves: " + str += "EEV_A:" + std::to_string(outdoor_unit_EEV_A) + ";"; + str += "EEV_B:" + std::to_string(outdoor_unit_EEV_B) + ";"; + str += "EEV_C:" + std::to_string(outdoor_unit_EEV_C) + ";"; + str += "EEV_D:" + std::to_string(outdoor_unit_EEV_D) + ";"; + return str; + } + std::string NonNasaCommandF3::to_string() { std::string str; From 02f03cd37fe4bc3b991e32163fdb08d3c71746f3 Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:05:52 +0100 Subject: [PATCH 03/15] debug-string calls --- components/samsung_ac/protocol_non_nasa.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index cbfef256..0dd811c8 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -112,11 +112,31 @@ namespace esphome str += "command20:{" + command20.to_string() + "}"; break; } + case NonNasaCommand::CmdC0: + { + str += "commandC0:{" + commandC0.to_string() + "}"; + break; + } + case NonNasaCommand::CmdC1: + { + str += "commandC1:{" + commandC1.to_string() + "}"; + break; + } case NonNasaCommand::CmdC6: { str += "commandC6:{" + commandC6.to_string() + "}"; break; } + case NonNasaCommand::CmdF0: + { + str += "commandF0:{" + commandF0.to_string() + "}"; + break; + } + case NonNasaCommand::CmdF1: + { + str += "commandF1:{" + commandF1.to_string() + "}"; + break; + } case NonNasaCommand::CmdF3: { str += "commandF3:{" + commandF3.to_string() + "}"; From ff668b1af587eeaff9bf70ed1adcd8c7b1aecb94 Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:17:00 +0100 Subject: [PATCH 04/15] decode cmd c0 --- components/samsung_ac/protocol_non_nasa.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 0dd811c8..cfc48e2b 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -199,6 +199,19 @@ namespace esphome return DecodeResult::Ok; } + case NonNasaCommand::CmdC0: // temperatures + { + commandC0.outdoor_unit_operation_mode = data[4]; // modes need to be specified + commandC0.outdoor_unit_4_way_valve = data[6] & 0b10000000; + commandC0.outdoor_unit_hot_gas_bypass = data[6] & 0b00100000; + commandC0.outdoor_unit_compressor = data[6] & 0b00000100; + commandC0.outdoor_unit_ac_fan = data[7] & 0b00000011; + commandC0.outdoor_unit_outdoor_temp_c = data[8] - 55; + commandC0.outdoor_unit_discharge_temp_c = data[10] - 55; + commandC0.outdoor_unit_condenser_mid_temp_c = data[11] - 55; + + return DecodeResult::Ok; + } case NonNasaCommand::CmdC6: { commandC6.control_status = data[4]; From ff4967f676e42a879332dc1245a29152eb9fceee Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:19:19 +0100 Subject: [PATCH 05/15] added de --- components/samsung_ac/protocol_non_nasa.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index cfc48e2b..7d290d1b 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -199,7 +199,7 @@ namespace esphome return DecodeResult::Ok; } - case NonNasaCommand::CmdC0: // temperatures + case NonNasaCommand::CmdC0: // outdoor unit data { commandC0.outdoor_unit_operation_mode = data[4]; // modes need to be specified commandC0.outdoor_unit_4_way_valve = data[6] & 0b10000000; @@ -209,7 +209,11 @@ namespace esphome commandC0.outdoor_unit_outdoor_temp_c = data[8] - 55; commandC0.outdoor_unit_discharge_temp_c = data[10] - 55; commandC0.outdoor_unit_condenser_mid_temp_c = data[11] - 55; - + return DecodeResult::Ok; + } + case NonNasaCommand::CmdC1: // outdoor unit data + { + commandC1.outdoor_unit_sump_temp_c = data[8] - 55; return DecodeResult::Ok; } case NonNasaCommand::CmdC6: From 595b41640631a5bd3c893f5ff9881dac654ac956 Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:30:20 +0100 Subject: [PATCH 06/15] decode cmd f0 --- components/samsung_ac/protocol_non_nasa.cpp | 24 ++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 7d290d1b..356847ca 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -221,18 +221,32 @@ namespace esphome commandC6.control_status = data[4]; return DecodeResult::Ok; } + case NonNasaCommand::CmdF0: // outdoor unit data + { + commandF0.outdoor_unit_freeze_protection = data[4] & 0b10000000; + commandF0.outdoor_unit_heating_overload = data[4] & 0b01000000; + commandF0.outdoor_unit_defrost_control = data[4] & 0b00100000; + commandF0.outdoor_unit_discharge_protection = data[4] & 0b00010000; + commandF0.outdoor_unit_current_control = data[4] & 0b00001000; + commandF0.inverter_order_frequency_hz = data[5]; + commandF0.inverter_target_frequency_hz = data[6]; + commandF0.inverter_current_frequency_hz = data[7]; + commandF0.outdoor_unit_bldc_fan = data[8] & 0b00000011; // not sure if correct, i have no ou with BLDC-fan + commandF0.outdoor_unit_error_code = data[10]; + return DecodeResult::Ok; + } case NonNasaCommand::CmdF3: // power consumption { // Maximum frequency for Inverter (compressor-motor of outdoor-unit) in Hz - commandF3.inverter_max_frequency_hz = data[4]; + commandF3.inverter_max_frequency_hz = data[4]; // Sum of required heating/cooling capacity ordered by the indoor-units in kW - commandF3.inverter_total_capacity_requirement_kw = (float)data[5] / 10; + commandF3.inverter_total_capacity_requirement_kw = (float)data[5] / 10; // DC-current to the inverter of outdoor-unit in A - commandF3.inverter_current_a = (float)data[8] / 10; + commandF3.inverter_current_a = (float)data[8] / 10; // voltage of the DC-link to inverter in V - commandF3.inverter_voltage_v = (float)data[9] * 2; + commandF3.inverter_voltage_v = (float)data[9] * 2; //Power consumption of the outdoo unit inverter in W - commandF3.inverter_power_w = commandF3.inverter_current_a * commandF3.inverter_voltage_v; + commandF3.inverter_power_w = commandF3.inverter_current_a * commandF3.inverter_voltage_v; return DecodeResult::Ok; } default: From 50f711c47640cbf24001d4077dcb7ed8c4b44092 Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:33:39 +0100 Subject: [PATCH 07/15] decode cmdf1 --- components/samsung_ac/protocol_non_nasa.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 356847ca..b9a086dc 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -235,6 +235,14 @@ namespace esphome commandF0.outdoor_unit_error_code = data[10]; return DecodeResult::Ok; } + case NonNasaCommand::CmdF1: // outdoor unit eev-values + { + commandF1.outdoor_unit_EEV_A = (data[4] * 256) + data[5]); + commandF1.outdoor_unit_EEV_B = (data[6] * 256) + data[7]); + commandF1.outdoor_unit_EEV_C = (data[8] * 256) + data[9]); + commandF1.outdoor_unit_EEV_D = (data[10] * 256) + data[11]); + return DecodeResult::Ok; + } case NonNasaCommand::CmdF3: // power consumption { // Maximum frequency for Inverter (compressor-motor of outdoor-unit) in Hz From 4e790df4b64936ce51f017ba3c8d3d653a41556e Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:36:58 +0100 Subject: [PATCH 08/15] solved typing errors --- components/samsung_ac/protocol_non_nasa.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index b9a086dc..68b47dad 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -66,7 +66,7 @@ namespace esphome str += "ou_freeze_protection:" + std::to_string(outdoor_unit_freeze_protection ? 1 : 0) + ";"; str += "ou_heating_overload:" + std::to_string(outdoor_unit_heating_overload ? 1 : 0) + ";"; str += "ou_defrost_control:" + std::to_string(outdoor_unit_defrost_control ? 1 : 0) + ";"; - str += "ou_discharge_protection:" + std::to_string(outdoor_unit_discharge_protectionn ? 1 : 0) + ";"; + str += "ou_discharge_protection:" + std::to_string(outdoor_unit_discharge_protection ? 1 : 0) + ";"; str += "ou_current_control:" + std::to_string(outdoor_unit_current_control ? 1 : 0) + ";"; str += "inverter_order_frequency[Hz]:" + std::to_string(inverter_order_frequency_hz) + ";"; str += "inverter_target_frequency[Hz]:" + std::to_string(inverter_target_frequency_hz) + ";"; @@ -79,7 +79,7 @@ namespace esphome std::string NonNasaCommandF1::to_string() { std::string str; - str += "Electronic Expansion Valves: " + str += "Electronic Expansion Valves: "; str += "EEV_A:" + std::to_string(outdoor_unit_EEV_A) + ";"; str += "EEV_B:" + std::to_string(outdoor_unit_EEV_B) + ";"; str += "EEV_C:" + std::to_string(outdoor_unit_EEV_C) + ";"; @@ -237,10 +237,10 @@ namespace esphome } case NonNasaCommand::CmdF1: // outdoor unit eev-values { - commandF1.outdoor_unit_EEV_A = (data[4] * 256) + data[5]); - commandF1.outdoor_unit_EEV_B = (data[6] * 256) + data[7]); - commandF1.outdoor_unit_EEV_C = (data[8] * 256) + data[9]); - commandF1.outdoor_unit_EEV_D = (data[10] * 256) + data[11]); + commandF1.outdoor_unit_EEV_A = (data[4] * 256) + data[5]; + commandF1.outdoor_unit_EEV_B = (data[6] * 256) + data[7]; + commandF1.outdoor_unit_EEV_C = (data[8] * 256) + data[9]; + commandF1.outdoor_unit_EEV_D = (data[10] * 256) + data[11]; return DecodeResult::Ok; } case NonNasaCommand::CmdF3: // power consumption From 6f30042bd1ddf7aa948e90b235565933c8606a83 Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:45:29 +0100 Subject: [PATCH 09/15] Show F8 as raw, no decoded data --- components/samsung_ac/protocol_non_nasa.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 68b47dad..78fcbc6a 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -142,11 +142,6 @@ namespace esphome str += "commandF3:{" + commandF3.to_string() + "}"; break; } - case NonNasaCommand::CmdF8: - { - str += "commandF8:{" + commandF8.to_string() + "}"; - break; - } default: { str += "raw:" + commandRaw.to_string(); From 47db288133d21d617f3c9786150a2c2bfe7496dc Mon Sep 17 00:00:00 2001 From: matthias882 <30553262+matthias882@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:49:17 +0100 Subject: [PATCH 10/15] spaces in debug-log for better readability --- components/samsung_ac/protocol_non_nasa.cpp | 72 ++++++++++----------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 78fcbc6a..112fa9f3 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -28,51 +28,51 @@ namespace esphome std::string NonNasaCommand20::to_string() { std::string str; - str += "target_temp:" + std::to_string(target_temp) + ";"; - str += "room_temp:" + std::to_string(room_temp) + ";"; - str += "pipe_in:" + std::to_string(pipe_in) + ";"; - str += "pipe_out:" + std::to_string(pipe_out) + ";"; - str += "power:" + std::to_string(power ? 1 : 0) + ";"; - str += "wind_direction:" + std::to_string((uint8_t)wind_direction) + ";"; - str += "fanspeed:" + std::to_string((uint8_t)fanspeed) + ";"; - str += "mode:" + long_to_hex((uint8_t)mode) + ";"; + str += "target_temp:" + std::to_string(target_temp) + "; "; + str += "room_temp:" + std::to_string(room_temp) + "; "; + str += "pipe_in:" + std::to_string(pipe_in) + "; "; + str += "pipe_out:" + std::to_string(pipe_out) + "; "; + str += "power:" + std::to_string(power ? 1 : 0) + "; "; + str += "wind_direction:" + std::to_string((uint8_t)wind_direction) + "; "; + str += "fanspeed:" + std::to_string((uint8_t)fanspeed) + "; "; + str += "mode:" + long_to_hex((uint8_t)mode); return str; } std::string NonNasaCommandC0::to_string() { std::string str; - str += "ou_operation_mode:" + long_to_hex((uint8_t)outdoor_unit_operation_mode) + ";"; - str += "ou_4way_valve:" + std::to_string(outdoor_unit_4_way_valve ? 1 : 0) + ";"; - str += "ou_hot_gas_bypass:" + std::to_string(outdoor_unit_hot_gas_bypass ? 1 : 0) + ";"; - str += "ou_compressor:" + std::to_string(outdoor_unit_compressor ? 1 : 0) + ";"; - str += "ou_ac_fan:" + std::to_string(outdoor_unit_ac_fan ? 1 : 0) + ";"; - str += "ou_outdoor_temp[°C]:" + std::to_string(outdoor_unit_outdoor_temp_c) + ";"; - str += "ou_discharge_temp[°C]:" + std::to_string(outdoor_unit_discharge_temp_c) + ";"; - str += "ou_condenser_mid_temp[°C]:" + std::to_string(outdoor_unit_condenser_mid_temp_c) + ";"; + str += "ou_operation_mode:" + long_to_hex((uint8_t)outdoor_unit_operation_mode) + "; "; + str += "ou_4way_valve:" + std::to_string(outdoor_unit_4_way_valve ? 1 : 0) + "; "; + str += "ou_hot_gas_bypass:" + std::to_string(outdoor_unit_hot_gas_bypass ? 1 : 0) + "; "; + str += "ou_compressor:" + std::to_string(outdoor_unit_compressor ? 1 : 0) + "; "; + str += "ou_ac_fan:" + std::to_string(outdoor_unit_ac_fan ? 1 : 0) + "; "; + str += "ou_outdoor_temp[°C]:" + std::to_string(outdoor_unit_outdoor_temp_c) + "; "; + str += "ou_discharge_temp[°C]:" + std::to_string(outdoor_unit_discharge_temp_c) + "; "; + str += "ou_condenser_mid_temp[°C]:" + std::to_string(outdoor_unit_condenser_mid_temp_c); return str; } std::string NonNasaCommandC1::to_string() { std::string str; - str += "ou_sump_temp[°C]:" + std::to_string(outdoor_unit_sump_temp_c) + ";"; + str += "ou_sump_temp[°C]:" + std::to_string(outdoor_unit_sump_temp_c); return str; } std::string NonNasaCommandF0::to_string() { std::string str; - str += "ou_freeze_protection:" + std::to_string(outdoor_unit_freeze_protection ? 1 : 0) + ";"; - str += "ou_heating_overload:" + std::to_string(outdoor_unit_heating_overload ? 1 : 0) + ";"; - str += "ou_defrost_control:" + std::to_string(outdoor_unit_defrost_control ? 1 : 0) + ";"; - str += "ou_discharge_protection:" + std::to_string(outdoor_unit_discharge_protection ? 1 : 0) + ";"; - str += "ou_current_control:" + std::to_string(outdoor_unit_current_control ? 1 : 0) + ";"; - str += "inverter_order_frequency[Hz]:" + std::to_string(inverter_order_frequency_hz) + ";"; - str += "inverter_target_frequency[Hz]:" + std::to_string(inverter_target_frequency_hz) + ";"; - str += "inverter_current_frequency[Hz]:" + std::to_string(inverter_current_frequency_hz) + ";"; - str += "ou_bldc_fan:" + std::to_string(outdoor_unit_bldc_fan ? 1 : 0) + ";"; - str += "ou_error_code:" + long_to_hex((uint8_t)outdoor_unit_error_code) + ";"; + str += "ou_freeze_protection:" + std::to_string(outdoor_unit_freeze_protection ? 1 : 0) + "; "; + str += "ou_heating_overload:" + std::to_string(outdoor_unit_heating_overload ? 1 : 0) + "; "; + str += "ou_defrost_control:" + std::to_string(outdoor_unit_defrost_control ? 1 : 0) + "; "; + str += "ou_discharge_protection:" + std::to_string(outdoor_unit_discharge_protection ? 1 : 0) + "; "; + str += "ou_current_control:" + std::to_string(outdoor_unit_current_control ? 1 : 0) + "; "; + str += "inverter_order_frequency[Hz]:" + std::to_string(inverter_order_frequency_hz) + "; "; + str += "inverter_target_frequency[Hz]:" + std::to_string(inverter_target_frequency_hz) + "; "; + str += "inverter_current_frequency[Hz]:" + std::to_string(inverter_current_frequency_hz) + "; "; + str += "ou_bldc_fan:" + std::to_string(outdoor_unit_bldc_fan ? 1 : 0) + "; "; + str += "ou_error_code:" + long_to_hex((uint8_t)outdoor_unit_error_code); return str; } @@ -80,21 +80,21 @@ namespace esphome { std::string str; str += "Electronic Expansion Valves: "; - str += "EEV_A:" + std::to_string(outdoor_unit_EEV_A) + ";"; - str += "EEV_B:" + std::to_string(outdoor_unit_EEV_B) + ";"; - str += "EEV_C:" + std::to_string(outdoor_unit_EEV_C) + ";"; - str += "EEV_D:" + std::to_string(outdoor_unit_EEV_D) + ";"; + str += "EEV_A:" + std::to_string(outdoor_unit_EEV_A) + "; "; + str += "EEV_B:" + std::to_string(outdoor_unit_EEV_B) + "; "; + str += "EEV_C:" + std::to_string(outdoor_unit_EEV_C) + "; "; + str += "EEV_D:" + std::to_string(outdoor_unit_EEV_D); return str; } std::string NonNasaCommandF3::to_string() { std::string str; - str += "inverter_max_frequency[Hz]:" + std::to_string(inverter_max_frequency_hz) + ";"; - str += "inverter_total_capacity_requirement[kW]:" + std::to_string(inverter_total_capacity_requirement_kw) + ";"; - str += "inverter_current[ADC]:" + std::to_string(inverter_current_a) + ";"; - str += "inverter_voltage[VDC]:" + std::to_string(inverter_voltage_v) + ";"; - str += "inverter_power[W]:" + std::to_string(inverter_power_w) + ";"; + str += "inverter_max_frequency[Hz]:" + std::to_string(inverter_max_frequency_hz) + "; "; + str += "inverter_total_capacity_requirement[kW]:" + std::to_string(inverter_total_capacity_requirement_kw) + "; "; + str += "inverter_current[ADC]:" + std::to_string(inverter_current_a) + "; "; + str += "inverter_voltage[VDC]:" + std::to_string(inverter_voltage_v) + "; "; + str += "inverter_power[W]:" + std::to_string(inverter_power_w); return str; } From c3f4807ffa501cb4e80c2eb7ad83e7cef0133657 Mon Sep 17 00:00:00 2001 From: Steve Wagner Date: Thu, 8 Feb 2024 08:37:28 +0100 Subject: [PATCH 11/15] Remove experimental/optional --- components/samsung_ac/util.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/components/samsung_ac/util.h b/components/samsung_ac/util.h index 1f213678..fbe8fba4 100644 --- a/components/samsung_ac/util.h +++ b/components/samsung_ac/util.h @@ -6,7 +6,6 @@ #include #include #include -#include namespace esphome { @@ -19,12 +18,5 @@ namespace esphome std::string bytes_to_hex(const std::vector &data); std::vector hex_to_bytes(const std::string &hex); void print_bits_8(uint8_t value); - - // esphome optional did not work in tests and std::optional is not available in c++ 14. - template - using opt = std::experimental::optional; - using opt_null_t = std::experimental::nullopt_t; - constexpr auto nullopt = std::experimental::nullopt; - } // namespace samsung_ac } // namespace esphome From 0e2462ffcdcf19698281feb1b0dc18a6309ac2ba Mon Sep 17 00:00:00 2001 From: mbo18 Date: Thu, 8 Feb 2024 08:57:14 +0100 Subject: [PATCH 12/15] Rename converions.cpp to conversions.cpp Small typo in the file name --- components/samsung_ac/{converions.cpp => conversions.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename components/samsung_ac/{converions.cpp => conversions.cpp} (100%) diff --git a/components/samsung_ac/converions.cpp b/components/samsung_ac/conversions.cpp similarity index 100% rename from components/samsung_ac/converions.cpp rename to components/samsung_ac/conversions.cpp From e757a266f94a18977f1916cbbaa1bda8325fab05 Mon Sep 17 00:00:00 2001 From: Steve Wagner Date: Thu, 8 Feb 2024 11:22:14 +0100 Subject: [PATCH 13/15] Allow package sending for c6 also --- components/samsung_ac/protocol_non_nasa.cpp | 36 ++++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 112fa9f3..8b90cd21 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -248,7 +248,7 @@ namespace esphome commandF3.inverter_current_a = (float)data[8] / 10; // voltage of the DC-link to inverter in V commandF3.inverter_voltage_v = (float)data[9] * 2; - //Power consumption of the outdoo unit inverter in W + // Power consumption of the outdoo unit inverter in W commandF3.inverter_power_w = commandF3.inverter_current_a * commandF3.inverter_voltage_v; return DecodeResult::Ok; } @@ -475,6 +475,17 @@ namespace esphome return nonpacket_.decode(data); } + void send_packages(MessageTarget *target, uint8_t delay_ms) + { + while (nonnasa_requests.size() > 0) + { + delay(delay_ms); + auto data = nonnasa_requests.front().encode(); + target->publish_data(data); + nonnasa_requests.pop(); + } + } + void process_non_nasa_packet(MessageTarget *target) { if (debug_log_packets) @@ -501,19 +512,20 @@ namespace esphome else if (nonpacket_.cmd == NonNasaCommand::CmdF8) { // After cmd F8 (src:c8 dst:f0) is a lage gap in communication, time to send data - if (nonpacket_.src == "c8" && nonpacket_.dst == "f0") { - while (nonnasa_requests.size() > 0) - { - auto data = nonnasa_requests.front().encode(); - // the communication needs a delay from cmdf8 to send the data. - // series of test-delay-times: 1ms: no reaction, 7ms reactions half the time, 10ms very often a reaction (95%) -> delay on 20ms should be safe - // the gap is around ~300ms - delay(20); - target->publish_data(data); - nonnasa_requests.pop(); - } + // the communication needs a delay from cmdf8 to send the data. + // series of test-delay-times: 1ms: no reaction, 7ms reactions half the time, 10ms very often a reaction (95%) -> delay on 20ms should be safe + // the gap is around ~300ms + send_packages(target, 20); + } + } + else if (nonpacket_.cmd == NonNasaCommand::CmdC6) + { + // If the control status is set we can send also + if (nonpacket_.src == "c8" && nonpacket_.dst == "d0" && nonpacket_.commandC6.control_status == true) + { + send_packages(target, 20); } } } From b29d941df4c6c7bc05b42320744426ddfa58f488 Mon Sep 17 00:00:00 2001 From: Steve Wagner Date: Thu, 8 Feb 2024 11:25:42 +0100 Subject: [PATCH 14/15] fix name --- components/samsung_ac/protocol_non_nasa.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 8b90cd21..7e609128 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -475,7 +475,7 @@ namespace esphome return nonpacket_.decode(data); } - void send_packages(MessageTarget *target, uint8_t delay_ms) + void send_requests(MessageTarget *target, uint8_t delay_ms) { while (nonnasa_requests.size() > 0) { @@ -517,7 +517,7 @@ namespace esphome // the communication needs a delay from cmdf8 to send the data. // series of test-delay-times: 1ms: no reaction, 7ms reactions half the time, 10ms very often a reaction (95%) -> delay on 20ms should be safe // the gap is around ~300ms - send_packages(target, 20); + send_requests(target, 20); } } else if (nonpacket_.cmd == NonNasaCommand::CmdC6) @@ -525,7 +525,7 @@ namespace esphome // If the control status is set we can send also if (nonpacket_.src == "c8" && nonpacket_.dst == "d0" && nonpacket_.commandC6.control_status == true) { - send_packages(target, 20); + send_requests(target, 20); } } } From af9304bf018b235fbd86ea326810b216dcc27fd0 Mon Sep 17 00:00:00 2001 From: Steve Wagner Date: Thu, 8 Feb 2024 13:42:17 +0100 Subject: [PATCH 15/15] Add logging for missing swing mode --- components/samsung_ac/protocol_non_nasa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/samsung_ac/protocol_non_nasa.cpp b/components/samsung_ac/protocol_non_nasa.cpp index 7e609128..9a31f8c3 100644 --- a/components/samsung_ac/protocol_non_nasa.cpp +++ b/components/samsung_ac/protocol_non_nasa.cpp @@ -425,12 +425,12 @@ namespace esphome void NonNasaProtocol::publish_altmode_message(MessageTarget *target, const std::string &address, AltMode value) { - // TODO + ESP_LOGW(TAG, "change altmode is currently not implemented"); } void NonNasaProtocol::publish_swing_mode_message(MessageTarget *target, const std::string &address, SwingMode value) { - // TODO + ESP_LOGW(TAG, "change swingmode is currently not implemented"); } Mode nonnasa_mode_to_mode(NonNasaMode value)