Skip to content

Commit

Permalink
Fix: Re-Request grid profile parameters if received data are invalid …
Browse files Browse the repository at this point in the history
…/ to short

Fixes #1874
  • Loading branch information
tbnobody committed Mar 31, 2024
1 parent 6f3b8fb commit 1888054
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void HoymilesClass::loop()
}

// Fetch grid profile
if (iv->Statistics()->getLastUpdate() > 0 && iv->GridProfile()->getLastUpdate() == 0) {
if (iv->Statistics()->getLastUpdate() > 0 && (iv->GridProfile()->getLastUpdate() == 0 || !iv->GridProfile()->containsValidData())) {
iv->sendGridOnProFileParaRequest();
}

Expand Down
7 changes: 6 additions & 1 deletion lib/Hoymiles/src/parser/GridProfileParser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2023 Thomas Basler and others
* Copyright (C) 2023 - 2024 Thomas Basler and others
*/
#include "GridProfileParser.h"
#include "../Hoymiles.h"
Expand Down Expand Up @@ -446,6 +446,11 @@ std::list<GridProfileSection_t> GridProfileParser::getProfile() const
return l;
}

bool GridProfileParser::containsValidData() const
{
return _gridProfileLength > 6;
}

uint8_t GridProfileParser::getSectionSize(const uint8_t section_id, const uint8_t section_version)
{
uint8_t count = 0;
Expand Down
4 changes: 3 additions & 1 deletion lib/Hoymiles/src/parser/GridProfileParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class GridProfileParser : public Parser {

std::list<GridProfileSection_t> getProfile() const;

bool containsValidData() const;

private:
static uint8_t getSectionSize(const uint8_t section_id, const uint8_t section_version);
static int16_t getSectionStart(const uint8_t section_id, const uint8_t section_version);
Expand All @@ -52,4 +54,4 @@ class GridProfileParser : public Parser {

static const std::array<const ProfileType_t, PROFILE_TYPE_COUNT> _profileTypes;
static const std::array<const GridProfileValue_t, SECTION_VALUE_COUNT> _profileValues;
};
};

0 comments on commit 1888054

Please sign in to comment.