예제 #1
0
        public async Task <Result> TurnOff()
        {
            var sb          = new StringBuilder();
            var powerStatus = await _yamahaService.PowerStatus();

            PushNotification("Please wait...");

            if (await _playerService.IsPlaying())
            {
                _playerService.Stop();
                sb.AppendLine("Stoping radio");
            }

            if (_mpdService.GetStatus().State == Libmpc.MpdState.Play)
            {
                _mpdService.Stop();
                sb.AppendLine("Stopping MPD");
            }

            if (powerStatus == PowerStatusEnum.On)
            {
                await Task.Delay(TimeSpan.FromSeconds(1));

                await _yamahaService.TurnOff();

                sb.AppendLine("Yamaha Turn Off");

                await _tvService.Power();
            }

            if (await _telemetryService.GetAirConditionState() == 1)
            {
                await _telemetryService.AirCondition(0);
            }

            if (await _sunriseSunsetService.IsNight())
            {
                await _smartBulbService.Initialize();

                await _smartBulbService.TurnOff();
            }

            NotifyClients();
            PushNotification("Smart house is turn off");

            return(new Result()
            {
                ErrorCode = 0,
                Message = sb.ToString(),
                Ok = true
            });
        }
예제 #2
0
        public async Task Stop()
        {
            var powerStatus = await YamahaService.PowerStatus();

            var smartHouseState = await SmartHouseService.GetCurrentState();

            if (powerStatus == PowerStatusEnum.StandBy)
            {
                PushNotification("Smarthouse is turn off");
                return;
            }

            if (smartHouseState == SmartHouseState.Pandora)
            {
                await PandoraService.StopTcp();

                PushNotification("Pianobar has exited");
            }
            else if (smartHouseState == SmartHouseState.Music)
            {
                MpdService.Stop();
            }
            else if (smartHouseState == SmartHouseState.TV)
            {
                await TVService.Stop();
            }
        }
예제 #3
0
 public Result Stop()
 {
     return(MpdService.Stop());
 }