Esempio n. 1
0
 public async Task <string> SetInput(string input)
 {
     return(await YamahaService.SetInput(input));
 }
Esempio n. 2
0
        public async Task <Result> TurnOn()
        {
            var sb          = new StringBuilder();
            var powerStatus = await _yamahaService.PowerStatus();

            if (powerStatus == PowerStatusEnum.StandBy)
            {
                PushNotification("Please wait...");

                await _tvService.Power();

                sb.AppendLine("Turning on TV");

                await _yamahaService.TurnOn();

                sb.AppendLine("Yamaha Turn on");

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

                    await _smartBulbService.PowerOn();

                    sb.AppendLine("Smart blub turn on");
                }

                await Task.Delay(TimeSpan.FromSeconds(8));
            }

            if (!DefaultVolumeSetterState.IsDefaultVolumeSetted())
            {
                await _smartHouseService.SetMode(ModeEnum.Normal, VolumeChangeNotify);

                sb.AppendLine("Setting Normal mode");

                DefaultVolumeSetterState.DefaultVolumeSetted();
            }

            var state = await _smartHouseService.GetCurrentState();

            if (state == SmartHouseState.Music && _mpdService.GetStatus().State != Libmpc.MpdState.Play)
            {
                if (_pandoraService.IsPlaying())
                {
                    _pandoraService.Pause();
                }

                await _yamahaService.SetInput("HDMI1");

                sb.AppendLine("Setting HDMI1 input");

                _mpdService.Play();
                sb.AppendLine("Playing MPD");
            }

            else if (state == SmartHouseState.Pandora)
            {
                await _yamahaService.SetInput("HDMI1");

                sb.AppendLine("Setting HDMI1 input");

                if (!_pandoraService.IsPlaying())
                {
                    await _pandoraService.StartTcp();

                    _pandoraService.Play();
                    sb.AppendLine("Playing pandora radio");
                }
            }
            else if (state == SmartHouseState.TV)
            {
                await Task.Delay(TimeSpan.FromSeconds(2));

                await _tvService.Home();

                sb.AppendLine("TV Home IR button");

                await _yamahaService.SetInput("AUDIO1");

                sb.AppendLine("Setting AUDIO1 input");
            }

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

            return(new Result()
            {
                ErrorCode = 0,
                Message = sb.ToString(),
                Ok = true
            });
        }