From 1427ac7098ee2a177214306c35521a7ed947b3ee Mon Sep 17 00:00:00 2001 From: cerise21 <40767429+cerise21@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:19:22 +0200 Subject: [PATCH 1/6] Add files via upload 1. Versuch zu: https://github.com/helgeerbe/OpenDTU-OnBattery/issues/724#issuecomment-2157512882 --- MqttHandlePowerLimiter.cpp | 189 +++++++++++++++++++++++++++++++++++++ MqttHandlePowerLimiter.h | 44 +++++++++ 2 files changed, 233 insertions(+) create mode 100644 MqttHandlePowerLimiter.cpp create mode 100644 MqttHandlePowerLimiter.h diff --git a/MqttHandlePowerLimiter.cpp b/MqttHandlePowerLimiter.cpp new file mode 100644 index 000000000..ccfa41075 --- /dev/null +++ b/MqttHandlePowerLimiter.cpp @@ -0,0 +1,189 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2022 Thomas Basler, Malte Schmidt and others + */ +#include "MessageOutput.h" +#include "MqttSettings.h" +#include "MqttHandlePowerLimiter.h" +#include "PowerLimiter.h" +#include +#include + +MqttHandlePowerLimiterClass MqttHandlePowerLimiter; + +void MqttHandlePowerLimiterClass::init(Scheduler& scheduler) +{ + scheduler.addTask(_loopTask); + _loopTask.setCallback(std::bind(&MqttHandlePowerLimiterClass::loop, this)); + _loopTask.setIterations(TASK_FOREVER); + _loopTask.enable(); + + using std::placeholders::_1; + using std::placeholders::_2; + using std::placeholders::_3; + using std::placeholders::_4; + using std::placeholders::_5; + using std::placeholders::_6; + + String const& prefix = MqttSettings.getPrefix(); + + auto subscribe = [&prefix, this](char const* subTopic, MqttPowerLimiterCommand command) { + String fullTopic(prefix + "powerlimiter/cmd/" + subTopic); + MqttSettings.subscribe(fullTopic.c_str(), 0, + std::bind(&MqttHandlePowerLimiterClass::onMqttCmd, this, command, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4, + std::placeholders::_5, std::placeholders::_6)); + }; + + subscribe("threshold/soc/start", MqttPowerLimiterCommand::BatterySoCStartThreshold); + subscribe("threshold/soc/stop", MqttPowerLimiterCommand::BatterySoCStopThreshold); + subscribe("threshold/soc/full_solar_passthrough", MqttPowerLimiterCommand::FullSolarPassthroughSoC); + subscribe("threshold/voltage/start", MqttPowerLimiterCommand::VoltageStartThreshold); + subscribe("threshold/voltage/stop", MqttPowerLimiterCommand::VoltageStopThreshold); + subscribe("threshold/voltage/full_solar_passthrough_start", MqttPowerLimiterCommand::FullSolarPassThroughStartVoltage); + subscribe("threshold/voltage/full_solar_passthrough_stop", MqttPowerLimiterCommand::FullSolarPassThroughStopVoltage); + subscribe("mode", MqttPowerLimiterCommand::Mode); + subscribe("upper_power_limit", MqttPowerLimiterCommand::UpperPowerLimit); + + _lastPublish = millis(); +} + + +void MqttHandlePowerLimiterClass::loop() +{ + std::unique_lock mqttLock(_mqttMutex); + + const CONFIG_T& config = Configuration.get(); + + if (!config.PowerLimiter.Enabled) { + _mqttCallbacks.clear(); + return; + } + + for (auto& callback : _mqttCallbacks) { callback(); } + _mqttCallbacks.clear(); + + mqttLock.unlock(); + + if (!MqttSettings.getConnected() ) { return; } + + if ((millis() - _lastPublish) < (config.Mqtt.PublishInterval * 1000)) { + return; + } + + _lastPublish = millis(); + + auto val = static_cast(PowerLimiter.getMode()); + MqttSettings.publish("powerlimiter/status/mode", String(val)); + + MqttSettings.publish("powerlimiter/status/upper_power_limit", String(config.PowerLimiter.UpperPowerLimit)); + + MqttSettings.publish("powerlimiter/status/inverter_update_timeouts", String(PowerLimiter.getInverterUpdateTimeouts())); + + // no thresholds are relevant for setups without a battery + if (config.PowerLimiter.IsInverterSolarPowered) { return; } + + MqttSettings.publish("powerlimiter/status/threshold/voltage/start", String(config.PowerLimiter.VoltageStartThreshold)); + MqttSettings.publish("powerlimiter/status/threshold/voltage/stop", String(config.PowerLimiter.VoltageStopThreshold)); + + if (config.Vedirect.Enabled) { + MqttSettings.publish("powerlimiter/status/threshold/voltage/full_solar_passthrough_start", String(config.PowerLimiter.FullSolarPassThroughStartVoltage)); + MqttSettings.publish("powerlimiter/status/threshold/voltage/full_solar_passthrough_stop", String(config.PowerLimiter.FullSolarPassThroughStopVoltage)); + } + + if (!config.Battery.Enabled || config.PowerLimiter.IgnoreSoc) { return; } + + MqttSettings.publish("powerlimiter/status/threshold/soc/start", String(config.PowerLimiter.BatterySocStartThreshold)); + MqttSettings.publish("powerlimiter/status/threshold/soc/stop", String(config.PowerLimiter.BatterySocStopThreshold)); + + if (config.Vedirect.Enabled) { + MqttSettings.publish("powerlimiter/status/threshold/soc/full_solar_passthrough", String(config.PowerLimiter.FullSolarPassThroughSoc)); + } +} + +void MqttHandlePowerLimiterClass::onMqttCmd(MqttPowerLimiterCommand command, const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total) +{ + CONFIG_T& config = Configuration.get(); + + std::string strValue(reinterpret_cast(payload), len); + float payload_val = -1; + try { + payload_val = std::stof(strValue); + } + catch (std::invalid_argument const& e) { + MessageOutput.printf("PowerLimiter MQTT handler: cannot parse payload of topic '%s' as float: %s\r\n", + topic, strValue.c_str()); + return; + } + const int intValue = static_cast(payload_val); + + std::lock_guard mqttLock(_mqttMutex); + + switch (command) { + case MqttPowerLimiterCommand::Mode: + { + using Mode = PowerLimiterClass::Mode; + Mode mode = static_cast(intValue); + if (mode == Mode::UnconditionalFullSolarPassthrough) { + MessageOutput.println("Power limiter unconditional full solar PT"); + _mqttCallbacks.push_back(std::bind(&PowerLimiterClass::setMode, + &PowerLimiter, Mode::UnconditionalFullSolarPassthrough)); + } else if (mode == Mode::Disabled) { + MessageOutput.println("Power limiter disabled (override)"); + _mqttCallbacks.push_back(std::bind(&PowerLimiterClass::setMode, + &PowerLimiter, Mode::Disabled)); + } else if (mode == Mode::Normal) { + MessageOutput.println("Power limiter normal operation"); + _mqttCallbacks.push_back(std::bind(&PowerLimiterClass::setMode, + &PowerLimiter, Mode::Normal)); + } else { + MessageOutput.printf("PowerLimiter - unknown mode %d\r\n", intValue); + } + return; + } + case MqttPowerLimiterCommand::BatterySoCStartThreshold: + if (config.PowerLimiter.BatterySocStartThreshold == intValue) { return; } + MessageOutput.printf("Setting battery SoC start threshold to: %d %%\r\n", intValue); + config.PowerLimiter.BatterySocStartThreshold = intValue; + break; + case MqttPowerLimiterCommand::BatterySoCStopThreshold: + if (config.PowerLimiter.BatterySocStopThreshold == intValue) { return; } + MessageOutput.printf("Setting battery SoC stop threshold to: %d %%\r\n", intValue); + config.PowerLimiter.BatterySocStopThreshold = intValue; + break; + case MqttPowerLimiterCommand::FullSolarPassthroughSoC: + if (config.PowerLimiter.FullSolarPassThroughSoc == intValue) { return; } + MessageOutput.printf("Setting full solar passthrough SoC to: %d %%\r\n", intValue); + config.PowerLimiter.FullSolarPassThroughSoc = intValue; + break; + case MqttPowerLimiterCommand::VoltageStartThreshold: + if (config.PowerLimiter.VoltageStartThreshold == payload_val) { return; } + MessageOutput.printf("Setting voltage start threshold to: %.2f V\r\n", payload_val); + config.PowerLimiter.VoltageStartThreshold = payload_val; + break; + case MqttPowerLimiterCommand::VoltageStopThreshold: + if (config.PowerLimiter.VoltageStopThreshold == payload_val) { return; } + MessageOutput.printf("Setting voltage stop threshold to: %.2f V\r\n", payload_val); + config.PowerLimiter.VoltageStopThreshold = payload_val; + break; + case MqttPowerLimiterCommand::FullSolarPassThroughStartVoltage: + if (config.PowerLimiter.FullSolarPassThroughStartVoltage == payload_val) { return; } + MessageOutput.printf("Setting full solar passthrough start voltage to: %.2f V\r\n", payload_val); + config.PowerLimiter.FullSolarPassThroughStartVoltage = payload_val; + break; + case MqttPowerLimiterCommand::FullSolarPassThroughStopVoltage: + if (config.PowerLimiter.FullSolarPassThroughStopVoltage == payload_val) { return; } + MessageOutput.printf("Setting full solar passthrough stop voltage to: %.2f V\r\n", payload_val); + config.PowerLimiter.FullSolarPassThroughStopVoltage = payload_val; + break; + case MqttPowerLimiterCommand::UpperPowerLimit: + if (config.PowerLimiter.UpperPowerLimit == payload_val) { return; } + MessageOutput.printf("Setting upper power limit to: %.0f W\r\n", payload_val); + config.PowerLimiter.UpperPowerLimit = payload_val; + break; + } + + // not reached if the value did not change + Configuration.write(); +} diff --git a/MqttHandlePowerLimiter.h b/MqttHandlePowerLimiter.h new file mode 100644 index 000000000..fd35b5798 --- /dev/null +++ b/MqttHandlePowerLimiter.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include "Configuration.h" +#include +#include +#include +#include +#include + +class MqttHandlePowerLimiterClass { +public: + void init(Scheduler& scheduler); + +private: + void loop(); + + enum class MqttPowerLimiterCommand : unsigned { + Mode, + BatterySoCStartThreshold, + BatterySoCStopThreshold, + FullSolarPassthroughSoC, + VoltageStartThreshold, + VoltageStopThreshold, + FullSolarPassThroughStartVoltage, + FullSolarPassThroughStopVoltage, + UpperPowerLimit + }; + + void onMqttCmd(MqttPowerLimiterCommand command, const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total); + + Task _loopTask; + + uint32_t _lastPublishStats; + uint32_t _lastPublish; + + // MQTT callbacks to process updates on subscribed topics are executed in + // the MQTT thread's context. we use this queue to switch processing the + // user requests into the main loop's context (TaskScheduler context). + mutable std::mutex _mqttMutex; + std::deque> _mqttCallbacks; +}; + +extern MqttHandlePowerLimiterClass MqttHandlePowerLimiter; From 257ae2a1e89bd715c75514c75f5dc558ffc820d2 Mon Sep 17 00:00:00 2001 From: cerise21 <40767429+cerise21@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:27:57 +0200 Subject: [PATCH 2/6] Delete include/MqttHandlePowerLimiter.h --- include/MqttHandlePowerLimiter.h | 43 -------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 include/MqttHandlePowerLimiter.h diff --git a/include/MqttHandlePowerLimiter.h b/include/MqttHandlePowerLimiter.h deleted file mode 100644 index fa7ef12cc..000000000 --- a/include/MqttHandlePowerLimiter.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#pragma once - -#include "Configuration.h" -#include -#include -#include -#include -#include - -class MqttHandlePowerLimiterClass { -public: - void init(Scheduler& scheduler); - -private: - void loop(); - - enum class MqttPowerLimiterCommand : unsigned { - Mode, - BatterySoCStartThreshold, - BatterySoCStopThreshold, - FullSolarPassthroughSoC, - VoltageStartThreshold, - VoltageStopThreshold, - FullSolarPassThroughStartVoltage, - FullSolarPassThroughStopVoltage - }; - - void onMqttCmd(MqttPowerLimiterCommand command, const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total); - - Task _loopTask; - - uint32_t _lastPublishStats; - uint32_t _lastPublish; - - // MQTT callbacks to process updates on subscribed topics are executed in - // the MQTT thread's context. we use this queue to switch processing the - // user requests into the main loop's context (TaskScheduler context). - mutable std::mutex _mqttMutex; - std::deque> _mqttCallbacks; -}; - -extern MqttHandlePowerLimiterClass MqttHandlePowerLimiter; From d086055f019b2e1163f06a8a48b678302d21153a Mon Sep 17 00:00:00 2001 From: cerise21 <40767429+cerise21@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:28:15 +0200 Subject: [PATCH 3/6] Delete src/MqttHandlePowerLimiter.cpp --- src/MqttHandlePowerLimiter.cpp | 181 --------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 src/MqttHandlePowerLimiter.cpp diff --git a/src/MqttHandlePowerLimiter.cpp b/src/MqttHandlePowerLimiter.cpp deleted file mode 100644 index 95f90db2f..000000000 --- a/src/MqttHandlePowerLimiter.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2022 Thomas Basler, Malte Schmidt and others - */ -#include "MessageOutput.h" -#include "MqttSettings.h" -#include "MqttHandlePowerLimiter.h" -#include "PowerLimiter.h" -#include -#include - -MqttHandlePowerLimiterClass MqttHandlePowerLimiter; - -void MqttHandlePowerLimiterClass::init(Scheduler& scheduler) -{ - scheduler.addTask(_loopTask); - _loopTask.setCallback(std::bind(&MqttHandlePowerLimiterClass::loop, this)); - _loopTask.setIterations(TASK_FOREVER); - _loopTask.enable(); - - using std::placeholders::_1; - using std::placeholders::_2; - using std::placeholders::_3; - using std::placeholders::_4; - using std::placeholders::_5; - using std::placeholders::_6; - - String const& prefix = MqttSettings.getPrefix(); - - auto subscribe = [&prefix, this](char const* subTopic, MqttPowerLimiterCommand command) { - String fullTopic(prefix + "powerlimiter/cmd/" + subTopic); - MqttSettings.subscribe(fullTopic.c_str(), 0, - std::bind(&MqttHandlePowerLimiterClass::onMqttCmd, this, command, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, std::placeholders::_4, - std::placeholders::_5, std::placeholders::_6)); - }; - - subscribe("threshold/soc/start", MqttPowerLimiterCommand::BatterySoCStartThreshold); - subscribe("threshold/soc/stop", MqttPowerLimiterCommand::BatterySoCStopThreshold); - subscribe("threshold/soc/full_solar_passthrough", MqttPowerLimiterCommand::FullSolarPassthroughSoC); - subscribe("threshold/voltage/start", MqttPowerLimiterCommand::VoltageStartThreshold); - subscribe("threshold/voltage/stop", MqttPowerLimiterCommand::VoltageStopThreshold); - subscribe("threshold/voltage/full_solar_passthrough_start", MqttPowerLimiterCommand::FullSolarPassThroughStartVoltage); - subscribe("threshold/voltage/full_solar_passthrough_stop", MqttPowerLimiterCommand::FullSolarPassThroughStopVoltage); - subscribe("mode", MqttPowerLimiterCommand::Mode); - - _lastPublish = millis(); -} - - -void MqttHandlePowerLimiterClass::loop() -{ - std::unique_lock mqttLock(_mqttMutex); - - const CONFIG_T& config = Configuration.get(); - - if (!config.PowerLimiter.Enabled) { - _mqttCallbacks.clear(); - return; - } - - for (auto& callback : _mqttCallbacks) { callback(); } - _mqttCallbacks.clear(); - - mqttLock.unlock(); - - if (!MqttSettings.getConnected() ) { return; } - - if ((millis() - _lastPublish) < (config.Mqtt.PublishInterval * 1000)) { - return; - } - - _lastPublish = millis(); - - auto val = static_cast(PowerLimiter.getMode()); - MqttSettings.publish("powerlimiter/status/mode", String(val)); - - MqttSettings.publish("powerlimiter/status/inverter_update_timeouts", String(PowerLimiter.getInverterUpdateTimeouts())); - - // no thresholds are relevant for setups without a battery - if (config.PowerLimiter.IsInverterSolarPowered) { return; } - - MqttSettings.publish("powerlimiter/status/threshold/voltage/start", String(config.PowerLimiter.VoltageStartThreshold)); - MqttSettings.publish("powerlimiter/status/threshold/voltage/stop", String(config.PowerLimiter.VoltageStopThreshold)); - - if (config.Vedirect.Enabled) { - MqttSettings.publish("powerlimiter/status/threshold/voltage/full_solar_passthrough_start", String(config.PowerLimiter.FullSolarPassThroughStartVoltage)); - MqttSettings.publish("powerlimiter/status/threshold/voltage/full_solar_passthrough_stop", String(config.PowerLimiter.FullSolarPassThroughStopVoltage)); - } - - if (!config.Battery.Enabled || config.PowerLimiter.IgnoreSoc) { return; } - - MqttSettings.publish("powerlimiter/status/threshold/soc/start", String(config.PowerLimiter.BatterySocStartThreshold)); - MqttSettings.publish("powerlimiter/status/threshold/soc/stop", String(config.PowerLimiter.BatterySocStopThreshold)); - - if (config.Vedirect.Enabled) { - MqttSettings.publish("powerlimiter/status/threshold/soc/full_solar_passthrough", String(config.PowerLimiter.FullSolarPassThroughSoc)); - } -} - -void MqttHandlePowerLimiterClass::onMqttCmd(MqttPowerLimiterCommand command, const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total) -{ - CONFIG_T& config = Configuration.get(); - - std::string strValue(reinterpret_cast(payload), len); - float payload_val = -1; - try { - payload_val = std::stof(strValue); - } - catch (std::invalid_argument const& e) { - MessageOutput.printf("PowerLimiter MQTT handler: cannot parse payload of topic '%s' as float: %s\r\n", - topic, strValue.c_str()); - return; - } - const int intValue = static_cast(payload_val); - - std::lock_guard mqttLock(_mqttMutex); - - switch (command) { - case MqttPowerLimiterCommand::Mode: - { - using Mode = PowerLimiterClass::Mode; - Mode mode = static_cast(intValue); - if (mode == Mode::UnconditionalFullSolarPassthrough) { - MessageOutput.println("Power limiter unconditional full solar PT"); - _mqttCallbacks.push_back(std::bind(&PowerLimiterClass::setMode, - &PowerLimiter, Mode::UnconditionalFullSolarPassthrough)); - } else if (mode == Mode::Disabled) { - MessageOutput.println("Power limiter disabled (override)"); - _mqttCallbacks.push_back(std::bind(&PowerLimiterClass::setMode, - &PowerLimiter, Mode::Disabled)); - } else if (mode == Mode::Normal) { - MessageOutput.println("Power limiter normal operation"); - _mqttCallbacks.push_back(std::bind(&PowerLimiterClass::setMode, - &PowerLimiter, Mode::Normal)); - } else { - MessageOutput.printf("PowerLimiter - unknown mode %d\r\n", intValue); - } - return; - } - case MqttPowerLimiterCommand::BatterySoCStartThreshold: - if (config.PowerLimiter.BatterySocStartThreshold == intValue) { return; } - MessageOutput.printf("Setting battery SoC start threshold to: %d %%\r\n", intValue); - config.PowerLimiter.BatterySocStartThreshold = intValue; - break; - case MqttPowerLimiterCommand::BatterySoCStopThreshold: - if (config.PowerLimiter.BatterySocStopThreshold == intValue) { return; } - MessageOutput.printf("Setting battery SoC stop threshold to: %d %%\r\n", intValue); - config.PowerLimiter.BatterySocStopThreshold = intValue; - break; - case MqttPowerLimiterCommand::FullSolarPassthroughSoC: - if (config.PowerLimiter.FullSolarPassThroughSoc == intValue) { return; } - MessageOutput.printf("Setting full solar passthrough SoC to: %d %%\r\n", intValue); - config.PowerLimiter.FullSolarPassThroughSoc = intValue; - break; - case MqttPowerLimiterCommand::VoltageStartThreshold: - if (config.PowerLimiter.VoltageStartThreshold == payload_val) { return; } - MessageOutput.printf("Setting voltage start threshold to: %.2f V\r\n", payload_val); - config.PowerLimiter.VoltageStartThreshold = payload_val; - break; - case MqttPowerLimiterCommand::VoltageStopThreshold: - if (config.PowerLimiter.VoltageStopThreshold == payload_val) { return; } - MessageOutput.printf("Setting voltage stop threshold to: %.2f V\r\n", payload_val); - config.PowerLimiter.VoltageStopThreshold = payload_val; - break; - case MqttPowerLimiterCommand::FullSolarPassThroughStartVoltage: - if (config.PowerLimiter.FullSolarPassThroughStartVoltage == payload_val) { return; } - MessageOutput.printf("Setting full solar passthrough start voltage to: %.2f V\r\n", payload_val); - config.PowerLimiter.FullSolarPassThroughStartVoltage = payload_val; - break; - case MqttPowerLimiterCommand::FullSolarPassThroughStopVoltage: - if (config.PowerLimiter.FullSolarPassThroughStopVoltage == payload_val) { return; } - MessageOutput.printf("Setting full solar passthrough stop voltage to: %.2f V\r\n", payload_val); - config.PowerLimiter.FullSolarPassThroughStopVoltage = payload_val; - break; - } - - // not reached if the value did not change - Configuration.write(); -} From cc5fab286f3bd11d855e271fdc21d2f4263e77c1 Mon Sep 17 00:00:00 2001 From: cerise21 <40767429+cerise21@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:32:14 +0200 Subject: [PATCH 4/6] Update and rename MqttHandlePowerLimiter.h to include/MqttHandlePowerLimiter.h --- MqttHandlePowerLimiter.h => include/MqttHandlePowerLimiter.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename MqttHandlePowerLimiter.h => include/MqttHandlePowerLimiter.h (100%) diff --git a/MqttHandlePowerLimiter.h b/include/MqttHandlePowerLimiter.h similarity index 100% rename from MqttHandlePowerLimiter.h rename to include/MqttHandlePowerLimiter.h From 46d279bb8c043f76755df484948a9b66f1e44139 Mon Sep 17 00:00:00 2001 From: cerise21 <40767429+cerise21@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:32:44 +0200 Subject: [PATCH 5/6] Update and rename MqttHandlePowerLimiter.cpp to src/MqttHandlePowerLimiter.cpp --- MqttHandlePowerLimiter.cpp => src/MqttHandlePowerLimiter.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename MqttHandlePowerLimiter.cpp => src/MqttHandlePowerLimiter.cpp (100%) diff --git a/MqttHandlePowerLimiter.cpp b/src/MqttHandlePowerLimiter.cpp similarity index 100% rename from MqttHandlePowerLimiter.cpp rename to src/MqttHandlePowerLimiter.cpp From ff3cf14117c687c64d733a2059aa40910f882f32 Mon Sep 17 00:00:00 2001 From: cerise21 <40767429+cerise21@users.noreply.github.com> Date: Fri, 14 Jun 2024 23:02:13 +0200 Subject: [PATCH 6/6] payload -> intValue --- src/MqttHandlePowerLimiter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MqttHandlePowerLimiter.cpp b/src/MqttHandlePowerLimiter.cpp index ccfa41075..dd1c96dd3 100644 --- a/src/MqttHandlePowerLimiter.cpp +++ b/src/MqttHandlePowerLimiter.cpp @@ -178,9 +178,9 @@ void MqttHandlePowerLimiterClass::onMqttCmd(MqttPowerLimiterCommand command, con config.PowerLimiter.FullSolarPassThroughStopVoltage = payload_val; break; case MqttPowerLimiterCommand::UpperPowerLimit: - if (config.PowerLimiter.UpperPowerLimit == payload_val) { return; } - MessageOutput.printf("Setting upper power limit to: %.0f W\r\n", payload_val); - config.PowerLimiter.UpperPowerLimit = payload_val; + if (config.PowerLimiter.UpperPowerLimit == intValue) { return; } + MessageOutput.printf("Setting upper power limit to: %d W\r\n", intValue); + config.PowerLimiter.UpperPowerLimit = intValue; break; }