Ejemplo n.º 1
0
        public async Task <Result> Left()
        {
            var sb          = new StringBuilder();
            var powerStatus = await YamahaService.PowerStatus();

            if (powerStatus == PowerStatusEnum.On)
            {
                var mpdState = MpdService.GetStatus().State;
                var state    = await SmartHouseService.GetCurrentState();

                if (state == SmartHouseState.Music && (mpdState == MpdState.Play || mpdState == MpdState.Pause))
                {
                    MpdService.Previous();
                    sb.AppendLine("MPD Previous song");
                }
                else if (state == SmartHouseState.Pandora)
                {
                    PandoraService.Next();
                    sb.AppendLine("Pandora next song. Pandora can't go previous");
                }
                else if (state == SmartHouseState.TV)
                {
                    await TVService.Left();

                    sb.AppendLine("TV Rewind");
                }
            }
            else
            {
                sb.AppendLine("Yamaha is turned off. Operation canceled");
                PushNotification("Yamaha is turned off. Operation canceled");
            }

            return(new Result()
            {
                ErrorCode = 0,
                Message = sb.ToString(),
                Ok = true
            });
        }
Ejemplo n.º 2
0
 public MpdStatus GetStatus()
 {
     return(MpdService.GetStatus());
 }
Ejemplo n.º 3
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
            });
        }