Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 2.17 KB

Q42.HueApi.ClipV1.md

File metadata and controls

68 lines (50 loc) · 2.17 KB

Legacy documentation for Q42.HueApi

Q42.HueApi is deprecated. Please use the new HueApi package.

Bridge

Before you can communicate with the Philips Hue Bridge, you need to find the bridge and register your application:

	IBridgeLocator locator = new HttpBridgeLocator(); //Or: LocalNetworkScanBridgeLocator, MdnsBridgeLocator, MUdpBasedBridgeLocator
	var bridges  = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(5));

	//Advanced Bridge Discovery options:
	bridges = await HueBridgeDiscovery.CompleteDiscoveryAsync(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
	bridges	= await HueBridgeDiscovery.FastDiscoveryWithNetworkScanFallbackAsync(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
	bridges = await HueBridgeDiscovery.CompleteDiscoveryAsync(TimeSpan.FromSeconds(5));

Register your application

	ILocalHueClient client = new LocalHueClient("ip");
	//Make sure the user has pressed the button on the bridge before calling RegisterAsync
	//It will throw an LinkButtonNotPressedException if the user did not press the button
	var appKey = await client.RegisterAsync("mypersonalappname", "mydevicename");
	//Save the app key for later use

If you already registered an appname, you can initialize the HueClient with the app's key:

	client.Initialize("mypersonalappkey");

Control the lights

Main usage of this library is to be able to control your lights. We use a LightCommand for that. A LightCommand can be send to one or more / multiple lights. A LightCommand can hold a color, effect, on/off etc.

	var command = new LightCommand();
	command.On = true;

There are some helpers to set a color on a command:

	//Turn the light on and set a Hex color for the command (see the section about Color Converters)
    command.TurnOn().SetColor(new RGBColor("FF00AA"))

LightCommands also support Effects and Alerts

	//Blink once
	command.Alert = Alert.Once;
	
	//Or start a colorloop
	command.Effect = Effect.ColorLoop;

Once you have composed your command, send it to one or more lights

	client.SendCommandAsync(command, new List<string> { "1" });

Or send it to all lights

	client.SendCommandAsync(command);