示例#1
0
        public void GetLights()
        {
            try
            {
                PhilipsHueBridge.SendCommand(String.Format("http://{0}/api/{1}", PhilipsHueBridge.IPAddress, PhilipsHueBridge.Username), "", RequestType.Get, 1, 0);
            }

            catch (Exception e)
            {
                CrestronConsole.PrintLine(e.Message + "\n" + e.StackTrace);
            }
        }
示例#2
0
        public void GroupState(string type, ushort state1, ushort state2, ushort state3)
        {
            try
            {
                string body = "";

                if (type == "on")
                {
                    if (state1 == 0)
                    {
                        body = "{\"on\":false}";
                    }
                    else if (state1 == 1)
                    {
                        body = "{\"on\":true}";
                    }
                }
                else if (type == "bri")
                {
                    body = String.Format("{{\"bri\":{0}}}", state1);
                }
                else if (type == "hue")
                {
                    body = String.Format("{{\"hue\":{0}}}", state1);
                }
                else if (type == "sat")
                {
                    body = String.Format("{{\"sat\":{0}}}", state1);
                }
                else if (type == "xy")
                {
                    double red   = state1 / 255;
                    double green = state2 / 255;
                    double blue  = state3 / 255;

                    ColourConverter.RGBColour RGB   = new ColourConverter.RGBColour(red, green, blue);
                    ColourConverter.Point     point = ColourConverter.RgbToXY(RGB, "LCT001");

                    body = String.Format("{{\"xy\":[{0}, {1}]}}", point.x, point.y);
                }

                //CrestronConsole.PrintLine(body);

                PhilipsHueBridge.SendCommand(String.Format("http://{0}/api/{1}/groups/{2}/action", PhilipsHueBridge.IPAddress, PhilipsHueBridge.Username, ID),
                                             body, RequestType.Put, 2, 0);
            }

            catch (Exception e)
            {
                CrestronConsole.PrintLine(e.Message + "\n" + e.StackTrace);
            }
        }
示例#3
0
        public void Link(string user)
        {
            try
            {
                if (CrestronDataStoreStatic.GetLocalStringValue("username", out PhilipsHueBridge.Username) == CrestronDataStore.CDS_ERROR.CDS_RECORD_NOT_FOUND)
                {
                    User u = new User();
                    u.devicetype = string.Format("crestron#{0}", user);
                    string body = JsonConvert.SerializeObject(u);

                    PhilipsHueBridge.SendCommand(String.Format("http://{0}/api", PhilipsHueBridge.IPAddress /*, PhilipsHueBridge.Username*/), body, RequestType.Post, 1, 0);
                }
                else
                {
                    GetLights();
                }
            }

            catch (Exception e)
            {
                CrestronConsole.PrintLine(e.Message + "\n" + e.StackTrace);
            }
        }
示例#4
0
 public void GetGroup()
 {
     PhilipsHueBridge.SendCommand(String.Format("http://{0}/api/{1}/groups/{2}", PhilipsHueBridge.IPAddress, PhilipsHueBridge.Username, ID), "",
                                  RequestType.Get, 4, ID);
 }