예제 #1
0
        private async Task OnLoggedIn()
        {
            State = NestViewModelState.Loading;

            var result = await _nestWebService.UpdateTransportUrlAsync();

            if (IsErrorHandled(result.Error, result.Exception))
            {
                return;
            }

            _getStatusResult = await _nestWebService.GetFullStatusAsync();

            if (IsErrorHandled(_getStatusResult.Error, _getStatusResult.Exception))
            {
                return;
            }

            State = NestViewModelState.LoggedIn;

            UpdateViewModelFromGetStatusResult(_getStatusResult);

            _statusUpdater.CurrentStructure = _getStatusResult.Structures.ElementAt(0);
            _statusUpdater.Start();
            _statusProvider.Start();
        }
예제 #2
0
        private async Task RaiseTemperatureAsync(TemperatureMode temperatureMode)
        {
            double temperature = GetTemperatureValue(temperatureMode);

            if (temperature >= MaxTemperature)
            {
                return;
            }

            try {
                _statusProvider.Stop();

                var thermostat = GetFirstThermostat();

                double desiredTemperature = temperature + 1.0d;
                SetTemperatureValue(temperatureMode, desiredTemperature);
                SetThermostatTemperatureValue(temperatureMode, thermostat, desiredTemperature);

                var result = await _nestWebService.ChangeTemperatureAsync(thermostat, desiredTemperature, temperatureMode);

                if (_exceptionHandler.IsErrorHandled(result.Error, result.Exception))
                {
                    return;
                }

                await _statusUpdater.UpdateStatusAsync();
            }
            finally {
                _statusProvider.Start();
            }
        }