private void btnLogin_Click(object sender, RoutedEventArgs e) { _nest = new Nest(txtLogin.Text, txtPassword.Password); _nest.AuthenticationComplete += new EventHandler<EventArgs>(Nest_AuthenticationComplete); _nest.StatusUpdated += new EventHandler<NestStatusUpdatedEventArgs>(Nest_StatusUpdated); _nest.BeginAuthenticate(); }
private void btnLogin_Click(object sender, RoutedEventArgs e) { #if DEBUG _nest = new Nest("test@example", "password"); // you'll need your own test file (you can build one by grabbing the output of the calls string body = File.ReadAllText(@"d:\Aaron\Documents\nest-login1.txt"); _nest.ParseAuthenticationResponse(body); // you'll need your own test file (you can build one by grabbing the output of the calls body = File.ReadAllText(@"d:\Aaron\Documents\nest-status1.txt"); _nest.DeconstructStatus(body); UpdateDevices(); #else _nest = new Nest(txtLogin.Text, txtPassword.Password); _nest.AuthenticationComplete += new EventHandler<EventArgs>(Nest_AuthenticationComplete); _nest.StatusUpdated += new EventHandler<NestStatusUpdatedEventArgs>(Nest_StatusUpdated); _nest.BeginAuthenticate(); #endif }
static void Main(string[] args) { Nest nest = new Nest("test@example", "password"); // you'll need to create your own sample files! string body = File.ReadAllText(@"d:\Aaron\Documents\nest-login1.txt"); nest.ParseAuthenticationResponse(body); // you'll need to create your own sample files! body = File.ReadAllText(@"d:\Aaron\Documents\nest-status1.txt"); nest.DeconstructStatus(body); foreach (var structure in nest.Structures) { Console.WriteLine("===== Structure {0}", structure.Id); foreach (var device in structure.Devices) { Console.WriteLine("Device {0}", device.AllProperties.name); Console.WriteLine("-- Current Temp: {0} ({1})", device.AllProperties.current_temperature, Nest.CelsiusToFohrenheit((double)device.AllProperties.current_temperature)); } } Console.WriteLine("Done"); Console.ReadKey(); }