public async Task<string> SetState(int device, bool state)
        {
            const string SECRET = @"ZmxeZ1k0LjY4RnZ7R2lvXiRoXWI+KGJMfS9AZSYzQV4=";
            SetPinStateRequestFactory pinStateRequestFactory = new SetPinStateRequestFactory(new HmacSha256(SECRET));
            SetPinStateRequest request = pinStateRequestFactory.CreateRequest(device, state, "WindowsClient");

            Dictionary<string, string> parameters = new Dictionary<string, string>()
            {
                {"requestString", HttpUtility.UrlEncode(request.RequestString)},                
                {"hmac", HttpUtility.UrlEncode(request.Hmac)},
            };

            StringBuilder urlBuilder = new StringBuilder();
            urlBuilder
                .Append("http://")
                .Append(this.Server)
                .Append("/?");

            foreach (KeyValuePair<string, string> parameter in parameters)
            {
                urlBuilder
                    .Append(parameter.Key)
                    .Append("=")
                    .Append(parameter.Value)
                    .Append("&");
            }

            urlBuilder.Remove(urlBuilder.Length - 1, 1);

            using (HttpClient httpClient = new HttpClient())
            {
                string response = await httpClient.GetStringAsync(urlBuilder.ToString());
                return response;
            }
        }
        private Task ChangePhysicalDeviceState()
        {
            string serverName = MainPage.Instance.ViewModel.ServerName;
            if (!string.IsNullOrWhiteSpace(serverName))
            {
                const string SECRET = @"MmUrQCMobGhvMypqbmRuVlNvZWlnL2wvZltJTV02dSQ=";
                SetPinStateRequestFactory pinStateRequestFactory = new SetPinStateRequestFactory(new HmacSha256(SECRET));
                SetPinStateRequest request = pinStateRequestFactory.CreateRequest(this.Pin, this.State, "WindowsPhoneClient");

                Dictionary<string, string> parameters = new Dictionary<string, string>()
                {
                    {"requestString", HttpUtility.UrlEncode(request.RequestString)},
                    {"hmac", HttpUtility.UrlEncode(request.Hmac)},
                };

                StringBuilder urlBuilder = new StringBuilder();
                urlBuilder
                    .Append("http://")
                    .Append(serverName)
                    .Append("/?");

                foreach (KeyValuePair<string, string> parameter in parameters)
                {
                    urlBuilder
                        .Append(parameter.Key)
                        .Append("=")
                        .Append(parameter.Value)
                        .Append("&");
                }

                urlBuilder.Remove(urlBuilder.Length - 1, 1);

                var tcs = new TaskCompletionSource<DownloadStringCompletedEventArgs>();

                WebClient webClient = new WebClient();
                webClient.DownloadStringCompleted += (sender, args) =>
                {
                    tcs.SetResult(args);
                };

                webClient.DownloadStringAsync(new Uri(urlBuilder.ToString()));
                return tcs.Task;
            }

            return null;
        }