Skip to content

Commit

Permalink
Merge pull request #620 from mcnewton/relayactivate
Browse files Browse the repository at this point in the history
Fix activation logic for extra relays
  • Loading branch information
matjack1 authored Mar 24, 2024
2 parents c0f8fdd + 8c1f85a commit 7e2ac41
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/rfid.esp
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,25 @@ void rfidProcess()
processingState = notValid;
}

/*
* If user is valid and opening hour time is allowed, go through each relay
* in turn to see if it needs to be activated
*/
if (processingState == valid || processingState == validAdmin)
{
for (int currentRelay = 0; currentRelay < config.numRelays; currentRelay++)
{
// Get user data JSON access type entry for this relay
if (currentRelay == 0) {
activateRelay[currentRelay] = true;
accountTypes[currentRelay] = json["acctype"];
} else {
bool isRelayActive = accountTypes[currentRelay] == ACCESS_GRANTED;
activateRelay[currentRelay] = isRelayActive;
accountTypes[currentRelay] = json["acctype" + String(currentRelay + 1)];
}

// Enable activation if permissions are correct
activateRelay[currentRelay] = (accountTypes[currentRelay] == ACCESS_GRANTED);

// ...except Admin, which always activates everything
if (processingState == validAdmin)
{
activateRelay[currentRelay] = true;
Expand Down

0 comments on commit 7e2ac41

Please sign in to comment.