public async Task PressGarageDoorRemoteButton() { _relayBoard.On(Enums.Relay.GarageRemoteButton); await Task.Delay(Config.MomentaryButtonPressMilliseconds); _relayBoard.Off(Enums.Relay.GarageRemoteButton); }
private bool Toggle(Enums.Relay relay) { if (_relayBoard.IsOn(relay)) { _relayBoard.Off(relay); } else { _relayBoard.On(relay); } return(_relayBoard.IsOn(relay)); }
public void Reset(Sensor sensor, bool enableAlarmActivatedLed = true) { if (sensor.IsSensorTamper() && TrippedSensors.Contains(sensor)) { if (TrippedSensors.Count == 1) { Log.Information($"[ALARMSTATE] RESET Sensor: {sensor}"); _relayBoard .Relay(Enums.Relay.AlarmStrobe) .Relay(Enums.Relay.AlarmSiren) .Off(); } TrippedSensors.Remove(sensor); } if (sensor.IsFrontDoor() && TrippedSensors.Contains(sensor)) { if (TrippedSensors.Count == 1) { Log.Information($"[ALARMSTATE] RESET Sensor: {sensor}"); _relayBoard.Off(Enums.Relay.AlarmStrobe); } TrippedSensors.Remove(sensor); } if (sensor.IsGarageDoor() && TrippedSensors.Contains(sensor)) { if (TrippedSensors.Count == 1) { Log.Information($"[ALARMSTATE] RESET Sensor: {sensor}"); _relayBoard .Relay(Enums.Relay.AlarmStrobe) .Off(); } TrippedSensors.Remove(sensor); } if (sensor.IsSensorOutdoor() && TrippedSensors.Contains(sensor)) { Log.Information($"[ALARMSTATE] RESET Sensor: {sensor}"); _relayBoard .Relay(Enums.Relay.AlarmStrobe) .Relay(Enums.Relay.AlarmSiren) .Off(); TrippedSensors.Remove(sensor); } }
private async Task CheckForTriggeredEvents(TimeSpan timeSpanNow) { bool TriggeredEvent(KeyValuePair <Enums.TimedEvent, TimedEvent> evt) { return(evt.Value.TriggerTime == timeSpanNow && evt.Value.Enabled); } void DisableEvent(KeyValuePair <Enums.TimedEvent, TimedEvent> evt) { _timerEvents.DisableEvent(evt.Key); } foreach (var evt in _timerEvents.GetEnabledEvents()) { switch (evt.Key) { case Enums.TimedEvent.UpdateSunsetSunrise: if (TriggeredEvent(evt)) { await _mediator.Publish(new UpdateSunriseSunsetCommand()); } break; case Enums.TimedEvent.OnSunset: if (TriggeredEvent(evt)) { _lightsController.OnSunset(); } break; case Enums.TimedEvent.OnLightsOff: if (TriggeredEvent(evt)) { await _lightsController.LightsOff(); } break; case Enums.TimedEvent.OnSunrise: if (TriggeredEvent(evt)) { _lightsController.OnSunrise(); } break; case Enums.TimedEvent.StrobeOff: if (TriggeredEvent(evt)) { _relayBoard.Off(Relay.AlarmStrobe); DisableEvent(evt); } break; case Enums.TimedEvent.SirenOff: if (TriggeredEvent(evt)) { _relayBoard .Relay(Relay.AlarmSiren) .Off(); DisableEvent(evt); } break; case Enums.TimedEvent.GarageDoorOperatedEnd: if (TriggeredEvent(evt)) { Config.GarageDoorOperated = false; DisableEvent(evt); } break; default: break; } } }