From 8df2c16cce6e9877fd5a10f90cf63df79007e75e Mon Sep 17 00:00:00 2001 From: helgeerbe Date: Thu, 9 Mar 2023 10:22:08 +0100 Subject: [PATCH] ensure STATE_DISCOVER if PowerLimter is enabled --- include/MqttHandleVedirect.h | 2 +- lib/VeDirectFrameHandler/VeDirectFrameHandler.h | 8 ++++---- src/PowerLimiter.cpp | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/MqttHandleVedirect.h b/include/MqttHandleVedirect.h index 087ec621..9011b01b 100644 --- a/include/MqttHandleVedirect.h +++ b/include/MqttHandleVedirect.h @@ -18,7 +18,7 @@ public: void init(); void loop(); private: - veStruct _kvFrame; + veStruct _kvFrame{}; uint32_t _lastPublish; }; diff --git a/lib/VeDirectFrameHandler/VeDirectFrameHandler.h b/lib/VeDirectFrameHandler/VeDirectFrameHandler.h index 6ac4c700..fc732c0c 100644 --- a/lib/VeDirectFrameHandler/VeDirectFrameHandler.h +++ b/lib/VeDirectFrameHandler/VeDirectFrameHandler.h @@ -37,7 +37,7 @@ typedef struct { double V; // battery voltage in V double I; // battery current in A double VPV; // panel voltage in V - double PPV; // panel power in W + uint16_t PPV; // panel power in W double H19; // yield total kWh double H20; // yield today kWh uint16_t H21; // maximum power today W @@ -61,13 +61,13 @@ public: String getOrAsString(uint32_t offReason); // off reason as string String getMpptAsString(uint8_t mppt); // state of mppt as string - veStruct veFrame; // public map for received name and value pairs + veStruct veFrame{}; // public struct for received name and value pairs private: void setLastUpdate(); // set timestampt after successful frame read void rxData(uint8_t inbyte); // byte of serial data void textRxEvent(char *, char *); - void frameEndEvent(bool); // copy temp map to public map + void frameEndEvent(bool); // copy temp struct to public struct void logE(const char *, const char *); bool hexRxEvent(uint8_t); @@ -77,7 +77,7 @@ private: char * _textPointer; // pointer to the private buffer we're writing to, name or value char _name[VE_MAX_VALUE_LEN]; // buffer for the field name char _value[VE_MAX_VALUE_LEN]; // buffer for the field value - veStruct _tmpFrame; // private struct for received name and value pairs + veStruct _tmpFrame{}; // private struct for received name and value pairs unsigned long _pollInterval; unsigned long _lastPoll; }; diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index 2c490e96..aee657e6 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -75,13 +75,14 @@ void PowerLimiterClass::loop() || !Hoymiles.getRadio()->isIdle() || (millis() - _lastCommandSent) < (config.PowerLimiter_Interval * 1000) || (millis() - _lastLoop) < (config.PowerLimiter_Interval * 1000)) { + if (!config.PowerLimiter_Enabled) + _plState = STATE_DISCOVER; // ensure STATE_DISCOVER is set, if PowerLimiter will be enabled. return; } _lastLoop = millis(); std::shared_ptr inverter = Hoymiles.getInverterByPos(config.PowerLimiter_InverterId); - if (inverter == nullptr || !inverter->isReachable()) { return; }