コード例 #1
0
        private async Task GarageDoorStateChanged(object sender)
        {
            if (sender is Sensor sensor)
            {
                if (_alarmState.SensorArmed(sensor.Type) && GarageDoorOpen())
                {
                    await _alarmState.Tripped(sensor.Type);
                }
                else if (GarageDoorOpen())
                {
                    _timerEvents.UpdateEvent(TimedEvent.GarageDoorOperatedEnd, new Domain.TimedEvent(_clock.Now.AddTimeSpan(5.Minutes()), true));
                }

                await _mediator.Send(new UpdateReportedPropertyCommand(nameof(GarageDoorOpen), GarageDoorOpen()));
            }
        }
コード例 #2
0
        public async Task Handle(PollDoorbellMotionCommand notification, CancellationToken cancellationToken)
        {
            async Task PollActiveDings()
            {
                var dings = await _ringService.PollActiveDings(cancellationToken);

                if (dings.Any(ding => ding.Kind.ToLower(CultureInfo.InvariantCulture) == "motion"))
                {
                    await _alarmState.Tripped(Sensor.FrontDoorMotion);
                }
            }

            await PollActiveDings();
        }