Feature: Turn off LED 1 if no inverters are enabled for polling

This means that e.g. at night, when polling at night is disabled, LED 1 will be turned off now.
This commit is contained in:
Thomas Basler 2023-07-10 18:30:10 +02:00
parent 0ffbba0cf5
commit fe3d6588bc
3 changed files with 19 additions and 1 deletions

View File

@ -50,6 +50,9 @@ public:
// True if at least one inverter is producing // True if at least one inverter is producing
bool getIsAtLeastOneProducing(); bool getIsAtLeastOneProducing();
// True if at least one inverter is enabled for polling
bool getIsAtLeastOnePollEnabled();
// True if all enabled inverters are producing // True if all enabled inverters are producing
bool getIsAllEnabledProducing(); bool getIsAllEnabledProducing();
@ -75,6 +78,7 @@ private:
bool _isAtLeastOneProducing = false; bool _isAtLeastOneProducing = false;
bool _isAllEnabledProducing = false; bool _isAllEnabledProducing = false;
bool _isAllEnabledReachable = false; bool _isAllEnabledReachable = false;
bool _isAtLeastOnePollEnabled = false;
}; };
extern DatastoreClass Datastore; extern DatastoreClass Datastore;

View File

@ -30,6 +30,7 @@ void DatastoreClass::loop()
uint8_t isProducing = 0; uint8_t isProducing = 0;
uint8_t isReachable = 0; uint8_t isReachable = 0;
uint8_t pollEnabledCount = 0;
DAT_SEMAPHORE_TAKE(); DAT_SEMAPHORE_TAKE();
@ -62,6 +63,10 @@ void DatastoreClass::loop()
continue; continue;
} }
if (inv->getEnablePolling()) {
pollEnabledCount++;
}
if (inv->isProducing()) { if (inv->isProducing()) {
isProducing++; isProducing++;
} else { } else {
@ -107,6 +112,7 @@ void DatastoreClass::loop()
_isAtLeastOneProducing = isProducing > 0; _isAtLeastOneProducing = isProducing > 0;
_isAtLeastOneReachable = isReachable > 0; _isAtLeastOneReachable = isReachable > 0;
_isAtLeastOnePollEnabled = pollEnabledCount > 0;
_totalDcIrradiation = _totalDcIrradiationInstalled > 0 ? _totalDcPowerIrradiation / _totalDcIrradiationInstalled * 100.0f : 0; _totalDcIrradiation = _totalDcIrradiationInstalled > 0 ? _totalDcPowerIrradiation / _totalDcIrradiationInstalled * 100.0f : 0;
@ -235,3 +241,11 @@ bool DatastoreClass::getIsAllEnabledReachable()
DAT_SEMAPHORE_GIVE(); DAT_SEMAPHORE_GIVE();
return retval; return retval;
} }
bool DatastoreClass::getIsAtLeastOnePollEnabled()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAtLeastOnePollEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
}

View File

@ -57,7 +57,7 @@ void LedSingleClass::loop()
// Update inverter status // Update inverter status
_ledState[1] = LedState_t::Off; _ledState[1] = LedState_t::Off;
if (Hoymiles.getNumInverters()) { if (Hoymiles.getNumInverters() && Datastore.getIsAtLeastOnePollEnabled()) {
// set LED status // set LED status
if (Datastore.getIsAllEnabledReachable() && Datastore.getIsAllEnabledProducing()) { if (Datastore.getIsAllEnabledReachable() && Datastore.getIsAllEnabledProducing()) {
_ledState[1] = LedState_t::On; _ledState[1] = LedState_t::On;