public HueLightingSystem(string name, string ip) { //var bridges = GetBridges(); _client = new HueClient(ip); _client.RegisterAsync("ubilight", "ubilightkey"); _client.Initialize("ubilightkey"); Name = name; }
//private BridgeInfo _hueBridge; public ReleaseNight() { InitializeComponent(); _navigationHelper = new NavigationHelper(this); _navigationHelper.LoadState += NavigationHelperOnLoadState; _navigationHelper.SaveState += (sender, args) => { MediaSimple.MediaPlayer.Pause(); }; //Task.Run(() => this.GetHueInfo()).Wait(); //_hueClient = new LocalHueClient(_hueBridge.internalipaddress); //_hueClient.Initialize(""); _hueClient = new LocalHueClient("10.10.10.193"); _hueClient.Initialize("CqnjoQvPHKdy1IkFVJggaTdflgWBF1HWQTOZYf2p"); }
public HueBuildLight(string ip, IEnumerable <string> lights, string intensity) { _hueClient = new HueClient(ip); _hueClient.Initialize(AppKey); _lights = lights.ToList(); int parsedInt; if (int.TryParse(intensity, out parsedInt)) { _intensity = parsedInt; } else { _intensity = MAX_INTENSITY; } }
public void SetBridge(string bridgeIP, string appKey, bool alreadyRegistered) { _hue = new HueClient(bridgeIP); if (alreadyRegistered) { _hue.Initialize(appKey); } else { var retryCount = 0; var regOk = false; while (!regOk || retryCount >= RETRY_MAX) { var reg = _hue.RegisterAsync(APP_NAME, appKey); reg.Wait(); if (!reg.Result) { ShowWarning("Please press the button on the bridge to register the application", 30); } else { regOk = true; } retryCount++; if (!regOk && retryCount < RETRY_MAX) { Thread.Sleep(RETRY_DELAY); } } if (!regOk) { ShowError("Failed to register application with bridge", 30); } } var lights = _hue.GetLightsAsync(); lights.Wait(); var choices = lights.Result.Select(x => new Tuple <string, string>(x.Id, string.Format("{0} ({1})", x.Name, x.Type))).ToList(); UpdateLightChoice(choices); }
//private BridgeInfo _hueBridge; public RedAlert() { InitializeComponent(); _navigationHelper = new NavigationHelper(this); _navigationHelper.LoadState += NavigationHelperOnLoadState; _navigationHelper.SaveState += (sender, args) => { MediaSimple.MediaPlayer.Pause(); }; //Task.Run(() => this.GetHueInfo()).Wait(); //_hueClient = new LocalHueClient(_hueBridge.internalipaddress); //_hueClient.Initialize(""); //TODO: Complete Hue bridge self discovery //Until then I utilized the instructions at https://developers.meethue.com/documentation/getting-started // to hard code my info gathered from my router. _hueClient = new LocalHueClient("10.10.10.193"); _hueClient.Initialize("CqnjoQvPHKdy1IkFVJggaTdflgWBF1HWQTOZYf2p"); }
public override int Run(string[] remainingArguments) { var hueClient = new HueClient(_ip); var result = hueClient.RegisterAsync(HueBuildLight.AppName, HueBuildLight.AppKey).Result; if (result) { Console.WriteLine("Registered correctly."); return(0); } //If we failed to register, attempt to initialise and see if we succeed as we may already be registered. hueClient.Initialize(HueBuildLight.AppKey); var initialised = hueClient.IsInitialized; Console.WriteLine(initialised ? "Already registered." : "Failed to register"); return(initialised ? 0 : 1); }
/// <summary> /// Called when the package is started. /// </summary> public override void OnStart() { PackageHost.WriteInfo("Connecting to " + PackageHost.GetSettingValue <string>("BridgeAddress")); hueClient = new HueClient(PackageHost.GetSettingValue <string>("BridgeAddress")); hueClient.Initialize(PackageHost.GetSettingValue <string>("BridgeUsername")); PackageHost.WriteInfo("Getting configuration"); var bridge = hueClient.GetBridgeAsync().GetAwaiter().GetResult(); PackageHost.PushStateObject <BridgeConfig>("BridgeConfig", bridge.Config); foreach (Light light in bridge.Lights) { PackageHost.PushStateObject <Light>(light.Name, light); } PackageHost.WriteInfo("Starting query process"); Task.Factory.StartNew(() => { int pause = 1000; while (PackageHost.IsRunning) { try { var lights = hueClient.GetLightsAsync().GetAwaiter().GetResult(); foreach (Light light in lights) { PackageHost.PushStateObject <Light>(light.Name, light); } pause = 1000; } catch (Exception ex) { if (pause < 60000) { pause *= 2; } PackageHost.WriteError("Error to query lights : {0}", ex.ToString()); } Thread.Sleep(pause); } }); PackageHost.WriteInfo("Connected to {0}", hueClient.ApiBase); }
//private BridgeInfo _hueBridge; public Imperial() { InitializeComponent(); _navigationHelper = new NavigationHelper(this); _navigationHelper.LoadState += NavigationHelperOnLoadState; //_navigationHelper.SaveState += (sender, args) => { MediaSimple.MediaPlayer.Pause(); }; //Task.Run(() => this.GetHueInfo()).Wait(); //_hueClient = new LocalHueClient(_hueBridge.internalipaddress); //_hueClient.Initialize(""); BitmapImage bitmapImage = new BitmapImage(); // Call BaseUri on the root Page element and combine it with a relative path // to consruct an absolute URI. bitmapImage.UriSource = new Uri(BaseUri, "/Assets/vadar2.jpg"); IMImage.Source = bitmapImage; _hueClient = new LocalHueClient("10.10.10.193"); _hueClient.Initialize("CqnjoQvPHKdy1IkFVJggaTdflgWBF1HWQTOZYf2p"); }
internal void Initialize(string p) { _hueClient.Initialize(p); }