Skip to content

Commit

Permalink
ensure STATE_DISCOVER if PowerLimter is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Mar 9, 2023
1 parent 418fea2 commit 8df2c16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/MqttHandleVedirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MqttHandleVedirectClass {
void init();
void loop();
private:
veStruct _kvFrame;
veStruct _kvFrame{};
uint32_t _lastPublish;
};

Expand Down
8 changes: 4 additions & 4 deletions lib/VeDirectFrameHandler/VeDirectFrameHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -61,13 +61,13 @@ class VeDirectFrameHandler {
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);

Expand All @@ -77,7 +77,7 @@ class VeDirectFrameHandler {
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;
};
Expand Down
3 changes: 2 additions & 1 deletion src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InverterAbstract> inverter = Hoymiles.getInverterByPos(config.PowerLimiter_InverterId);

if (inverter == nullptr || !inverter->isReachable()) {
return;
}
Expand Down

0 comments on commit 8df2c16

Please sign in to comment.