Beispiel #1
0
        public async Task <DashboardData> Dashboard()
        {
            var nowPlaying = await NowPlaying();

            var currentInput = await _smartHouseService.GetCurrentState();

            var telemetryData = await _telemetryService.GetLastTemperature();

            var isTurnOn = (await _yamahaService.PowerStatus()) == PowerStatusEnum.On;
            var volume   = await _yamahaService.GetVolume();

            var isLightsTurnOn = await _smartBulbService.IsTurnOn();

            var isAirConditionerTurnOn = (await _telemetryService.GetAirConditionState()) == 1;

            return(new DashboardData
            {
                NowPlaying = nowPlaying,
                CurrentInput = currentInput.ToString(),
                TelemetryData = telemetryData,
                IsTurnOn = isTurnOn,
                Volume = volume,
                IsAirConditionerTurnOn = isAirConditionerTurnOn,
                IsLightsTurnOn = isLightsTurnOn
            });
        }
Beispiel #2
0
        public async Task <Result> TurnOff()
        {
            var sb          = new StringBuilder();
            var powerStatus = await _yamahaService.PowerStatus();

            if (_pandoraService.IsPlaying())
            {
                _pandoraService.Pause();
                sb.AppendLine("Pausing pandora 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.PowerOff();
            }

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

            return(new Result()
            {
                ErrorCode = 0,
                Message = sb.ToString(),
                Ok = true
            });
        }
Beispiel #3
0
 public async Task <byte> GetAirConditionState()
 {
     return(await TelemetryService.GetAirConditionState());
 }