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); } }
public async Task Tripped(Sensor sensor) { var sensorDetails = SensorDetails(sensor); if (sensor.IsSensorTamper()) { Log.Information($"[ALARMSTATE] TRIPPED Sensor: {sensor}"); TrippedSensors.Add(sensor); _relayBoard .Relay(Enums.Relay.AlarmStrobe) .Relay(Enums.Relay.AlarmSiren) .On(); TurnLightsOnAtNight(); _timerEvents.UpdateEvent(Enums.TimedEvent.StrobeOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.StrobeAlarm), true)); _timerEvents.UpdateEvent(Enums.TimedEvent.SirenOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.SirenAlarm), true)); await _mediator.Publish(new SendRichPushNotificationCommand { Title = sensorDetails.Title, Body = "Sensor has been tampered with...", CameraId = sensorDetails.CameraId }); } if (sensor.IsSensorOutdoor()) { Log.Information($"[ALARMSTATE] TRIPPED Sensor: {sensor}"); TrippedSensors.Add(sensor); _relayBoard .Relay(Enums.Relay.AlarmStrobe) .Relay(Enums.Relay.AlarmSiren) .On(); TurnLightsOnAtNight(); _timerEvents.UpdateEvent(Enums.TimedEvent.StrobeOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.StrobeAlarm), true)); _timerEvents.UpdateEvent(Enums.TimedEvent.SirenOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.SirenAlarm), true)); await _mediator.Publish(new SendRichPushNotificationCommand { Title = sensorDetails.Title, Body = "Outdoor ALARM", CameraId = sensorDetails.CameraId }); } if (sensor.IsFrontDoor()) { var strobeOn = "OFF"; if (SensorArmed(Sensor.FrontDoorMotion)) { Log.Information($"[ALARMSTATE] TRIPPED Sensor: {sensor}"); TrippedSensors.Add(sensor); _relayBoard.On(Enums.Relay.AlarmStrobe); _timerEvents.UpdateEvent(Enums.TimedEvent.StrobeOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.StrobeAlarm), true)); strobeOn = "ON"; } await _mediator.Publish(new SendRichPushNotificationCommand { Title = sensorDetails.Title, Body = $"Alarm strobe is {strobeOn}", CameraId = sensorDetails.CameraId }); } if (sensor.IsGarageDoor()) { Log.Information($"[ALARMSTATE] TRIPPED Sensor: {sensor}"); TrippedSensors.Add(sensor); _relayBoard .Relay(Enums.Relay.AlarmStrobe) .Relay(Enums.Relay.AlarmSiren) .On(); _timerEvents.UpdateEvent(Enums.TimedEvent.StrobeOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.StrobeAlarm), true)); _timerEvents.UpdateEvent(Enums.TimedEvent.SirenOff, new TimedEvent(_clock.Now.AddTimeSpan(Config.SirenAlarm), true)); await _mediator.Publish(new SendRichPushNotificationCommand { Title = sensorDetails.Title, Body = "Alarm ACTIVATED", CameraId = sensorDetails.CameraId }); } void TurnLightsOnAtNight() { if (Config.ArmedState.ArmedAwayNight || Config.ArmedState.ArmedSleeping) { _relayBoard .Relay(Enums.Relay.LightsGarden) .On(); } } }