MaxBeauchemin
1/3/2018 - 11:47 PM

Philips Hue API

Some basic code for interacting with the Philips Hue API

var baseUrl = "http://192.168.1.023";
var userKey = "2haogjnoiwejaoiheoaiwhfjawoihg-auighaewroiuhjoiajg";

var template = "{0}/api/{1}/lights/10/state";

var fullUrl = String.Format(template, baseUrl, userKey);

var client = new HttpClient();

var body = new HueObj();

var request = new HttpRequestMessage(HttpMethod.Put, fullUrl)
{
    Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json")
};

class HueObj
{
    public int hue { get; set; }
    public int sat { get; set; }
    public int bri { get; set; }
}