Welcome to HueLib Wiki.
I will explain here how to use HueLib properly.
Here is the simple steps needed to contact the bridge and send commands :
1. Discover the bridges present on your network.
The Class DiscoveredBridge is used to store 1 bridge detected via the bridge api itself. Use the function DetectBridge() present in the static class Hue to discover the bridge present. The function will return a list of detected bridge ( mostlikely only 1 ).
List<DiscoveredBridge> discoveredbridge = Hue.DetectBridge();
2. Create a new bridge :
Bridge newBridge = new Bridge(IPAddress.Parse(discoveredbridge.internalipaddress), "your api/user code here");
The bridge constructor require 2 things : an IPAddress and a string which represent your user/api code.
It is not important if you do not have access to the bridge yet. I suggest you chose this username before getting to step 3 because you will need it there.
3. Create you own user :
The only thing left to do here is register as a user :
The first string the device type is only for information purpose.
The second string is you username. it is optional to add one since the bridge will return a username in case you don't chose one. Otherwise use the same as you entered in step 2. Before executing this line of code be sure to press the link button on the bridge otherwise you will get an exception LinkButtonNotPressed.
4. Send a command :
The important classes here are :
Light -> for hue lights.
Group -> for a hue groups.
Schedule -> for schedules.
State -> for a light state.
Action -> for a group state.
for example if you want to set a light to red and on :
The first parameter is the id of the Light the second parameter is the state you want to set the light to. It is not needed to set all the light state variable the same applies to the other classes. If you do not set them they will stay null and will not be sent to the bridge.
5. Get a list of lights available :
HueResultMessage hrm = newBridge.GetLightList(out newLightList);
The only parameter for this function is where the list will be stored. For those not familiar with the out keyword it means that the variable you have given will be used to store the result of the command. You might ask why this ? Because GetLightList might return in some case an error/success and this error/success is in the form a HueResultMessage class. This class contains Error and Success for the command you just sent. Theoratically it could be possible for a command to have both many success' and many errors.