diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-11-29 16:52:27 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-11-29 16:52:27 +0300 |
commit | 6003eaa6756b7f97ff5c41fb3bc62cc63fcc4648 (patch) | |
tree | d1cc5a9b0564bad1d07d4614f93ae95f085c5a53 /src/p18 | |
parent | d74a2a3e78a631aa46ec6c1d6049a04d4bd5a4ba (diff) |
p18/get-p-status: don't output max_temp if inverter doesn't return it
Diffstat (limited to 'src/p18')
-rw-r--r-- | src/p18/response.cc | 17 | ||||
-rw-r--r-- | src/p18/response.h | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/p18/response.cc b/src/p18/response.cc index 453272c..e2cd9f4 100644 --- a/src/p18/response.cc +++ b/src/p18/response.cc @@ -742,12 +742,14 @@ void ParallelGeneralStatus::unpack() { battery_power_direction = static_cast<BatteryPowerDirection>(stou(list[25])); dc_ac_power_direction = static_cast<DC_AC_PowerDirection>(stou(list[26])); line_power_direction = static_cast<LinePowerDirection>(stou(list[27])); - if (list.size() >= 29) + if (list.size() >= 29) { + max_temp_present = true; max_temp = stou(list[28]); + } } formattable_ptr ParallelGeneralStatus::format(formatter::Format format) { - RETURN_TABLE({ + auto table = new formatter::Table<VariantHolder>(format, { LINE("parallel_id_connection_status", "Parallel ID connection status", parallel_id_connection_status), LINE("mode", "Working mode", work_mode), LINE("fault_code", "Fault code", fault_code), @@ -774,8 +776,15 @@ formattable_ptr ParallelGeneralStatus::format(formatter::Format format) { LINE("battery_power_direction", "Battery power direction", battery_power_direction), LINE("dc_ac_power_direction", "DC/AC power direction", dc_ac_power_direction), LINE("line_power_direction", "Line power direction", line_power_direction), - LINE("max_temp", "Max. temperature", max_temp), - }) + }); + + if (max_temp_present) { + table->push( + LINE("max_temp", "Max. temperature", max_temp) + ); + } + + return std::shared_ptr<formatter::Table<VariantHolder>>(table); } diff --git a/src/p18/response.h b/src/p18/response.h index 42b84b8..3ffc6d4 100644 --- a/src/p18/response.h +++ b/src/p18/response.h @@ -484,6 +484,8 @@ public: p18::BatteryPowerDirection battery_power_direction; p18::DC_AC_PowerDirection dc_ac_power_direction; p18::LinePowerDirection line_power_direction; + + bool max_temp_present = false; unsigned max_temp; /* unit: C */ }; |