Skip to content

Commit

Permalink
Feature: Turn off LED 1 if no inverters are enabled for polling
Browse files Browse the repository at this point in the history
This means that e.g. at night, when polling at night is disabled, LED 1 will be turned off now.
  • Loading branch information
tbnobody committed Jul 10, 2023
1 parent 0ffbba0 commit fe3d658
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/Datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class DatastoreClass {
// True if at least one inverter is producing
bool getIsAtLeastOneProducing();

// True if at least one inverter is enabled for polling
bool getIsAtLeastOnePollEnabled();

// True if all enabled inverters are producing
bool getIsAllEnabledProducing();

Expand All @@ -75,6 +78,7 @@ class DatastoreClass {
bool _isAtLeastOneProducing = false;
bool _isAllEnabledProducing = false;
bool _isAllEnabledReachable = false;
bool _isAtLeastOnePollEnabled = false;
};

extern DatastoreClass Datastore;
14 changes: 14 additions & 0 deletions src/Datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void DatastoreClass::loop()

uint8_t isProducing = 0;
uint8_t isReachable = 0;
uint8_t pollEnabledCount = 0;

DAT_SEMAPHORE_TAKE();

Expand Down Expand Up @@ -62,6 +63,10 @@ void DatastoreClass::loop()
continue;
}

if (inv->getEnablePolling()) {
pollEnabledCount++;
}

if (inv->isProducing()) {
isProducing++;
} else {
Expand Down Expand Up @@ -107,6 +112,7 @@ void DatastoreClass::loop()

_isAtLeastOneProducing = isProducing > 0;
_isAtLeastOneReachable = isReachable > 0;
_isAtLeastOnePollEnabled = pollEnabledCount > 0;

_totalDcIrradiation = _totalDcIrradiationInstalled > 0 ? _totalDcPowerIrradiation / _totalDcIrradiationInstalled * 100.0f : 0;

Expand Down Expand Up @@ -235,3 +241,11 @@ bool DatastoreClass::getIsAllEnabledReachable()
DAT_SEMAPHORE_GIVE();
return retval;
}

bool DatastoreClass::getIsAtLeastOnePollEnabled()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAtLeastOnePollEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
}
2 changes: 1 addition & 1 deletion src/Led_Single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void LedSingleClass::loop()

// Update inverter status
_ledState[1] = LedState_t::Off;
if (Hoymiles.getNumInverters()) {
if (Hoymiles.getNumInverters() && Datastore.getIsAtLeastOnePollEnabled()) {
// set LED status
if (Datastore.getIsAllEnabledReachable() && Datastore.getIsAllEnabledProducing()) {
_ledState[1] = LedState_t::On;
Expand Down

0 comments on commit fe3d658

Please sign in to comment.