Browse Source

Handle relay status tracking in scheduler

fastled
Xose Pérez 7 years ago
parent
commit
97a27310e2
1 changed files with 9 additions and 5 deletions
  1. +9
    -5
      code/espurna/relay.ino

+ 9
- 5
code/espurna/relay.ino View File

@ -153,7 +153,15 @@ bool relayStatus(unsigned char id, bool status, bool report) {
bool changed = false; bool changed = false;
#if TRACK_RELAY_STATUS #if TRACK_RELAY_STATUS
if (relayStatus(id) != status) {
if (relayStatus(id) == status) {
if (_relays[id].scheduled) {
DEBUG_MSG_P(PSTR("[RELAY] #%d scheduled change cancelled\n"), id);
_relays[id].scheduled = false;
_relays[id].scheduledStatus = status;
_relays[id].scheduledReport = false;
changed = true;
}
} else {
#endif #endif
unsigned int currentTime = millis(); unsigned int currentTime = millis();
@ -467,11 +475,7 @@ void relayLoop(void) {
unsigned int currentTime = millis(); unsigned int currentTime = millis();
bool status = _relays[id].scheduledStatus; bool status = _relays[id].scheduledStatus;
#if TRACK_RELAY_STATUS
if (relayStatus(id) != status && currentTime >= _relays[id].scheduledStatusTime) {
#else
if (_relays[id].scheduled && currentTime >= _relays[id].scheduledStatusTime) { if (_relays[id].scheduled && currentTime >= _relays[id].scheduledStatusTime) {
#endif
DEBUG_MSG_P(PSTR("[RELAY] #%d set to %s\n"), id, status ? "ON" : "OFF"); DEBUG_MSG_P(PSTR("[RELAY] #%d set to %s\n"), id, status ? "ON" : "OFF");


Loading…
Cancel
Save