| 86 | } |
| 87 | |
| 88 | void IS_DoorControl::beSmart(const String &str) |
| 89 | { |
| 90 | String s = str.substring(str.indexOf(' ') + 1); |
| 91 | if (st::InterruptSensor::debug) { |
| 92 | Serial.print(F("IS_ContactRelay::beSmart s = ")); |
| 93 | Serial.println(s); |
| 94 | } |
| 95 | if (s == F("on")) |
| 96 | { |
| 97 | m_bCurrentState = HIGH; |
| 98 | |
| 99 | //Save time turned on |
| 100 | m_lTimeTurnedOn = millis(); |
| 101 | |
| 102 | //Increment number of active timers |
| 103 | if (!m_bTimerPending) |
| 104 | { |
| 105 | st::Everything::bTimersPending++; |
| 106 | m_bTimerPending = true; |
| 107 | } |
| 108 | //Queue the door status update the ST Cloud |
| 109 | Everything::sendSmartStringNow(getName() + (getStatus() ? F(" opening") : F(" closing"))); |
| 110 | } |
| 111 | else if (s == F("off")) |
| 112 | { |
| 113 | m_bCurrentState = LOW; |
| 114 | |
| 115 | //Decrement number of active timers |
| 116 | if (st::Everything::bTimersPending > 0) st::Everything::bTimersPending--; |
| 117 | m_bTimerPending = false; |
| 118 | } |
| 119 | |
| 120 | //update the digital output |
| 121 | writeStateToPin(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | //called periodically by Everything class to ensure ST Cloud is kept consistent with the state of the contact sensor |