Exemplo n.º 1
0
        /// <summary>
        /// test
        /// </summary>
        /// <param name="settype"></param>
        /// <param name="lvltype"></param>
        /// <param name="val"></param>
        public void LightsVal(string settype, string lvltype, ushort val)
        {
            try
            {
                if (HueBridge.Authorized == true && HueBridge.Populated == true)
                {
                    String cmdval = "{\"" + lvltype + "\":" + val.ToString() + "}";
                    String json   = HueBridge.SetLvl(settype, RoomID, "action", cmdval);
                    if (json.Contains("success"))
                    {
                        JArray JData   = JArray.Parse(json);
                        string NodeVal = "/" + settype + "/" + RoomID + "/action/" + lvltype;
                        switch (lvltype)
                        {
                        case "bri":
                        {
                            HueBridge.HueGroups[RoomID - 1].Bri = (uint)JData[0]["success"][NodeVal];
                            RoomBri = (ushort)HueBridge.HueGroups[RoomID - 1].Bri;
                            TriggerRoomBriUpdate();
                            break;
                        }

                        case "hue":
                        {
                            HueBridge.HueGroups[RoomID - 1].Hue = (uint)JData[0]["success"][NodeVal];
                            RoomHue = (ushort)HueBridge.HueGroups[RoomID - 1].Hue;
                            TriggerRoomHueUpdate();
                            break;
                        }

                        case "sat":
                        {
                            HueBridge.HueGroups[RoomID - 1].Sat = (uint)JData[0]["success"][NodeVal];
                            RoomSat = (ushort)HueBridge.HueGroups[RoomID - 1].Sat;
                            TriggerRoomSatUpdate();
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                else
                {
                    CrestronConsole.PrintLine("Bridge not authorized");
                }
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Exception is {0}", e);
            }
        }
Exemplo n.º 2
0
        public void LightsVal(string settype, string lvltype, ushort val)
        {
            try
            {
                if (HueBridge.Authorized == true)
                {
                    String cmdval = "{\"" + lvltype + "\":" + val.ToString() + "}";
                    String json   = HueBridge.SetLvl(settype, BulbID, "state", cmdval);
                    if (json.Contains("success"))
                    {
                        JArray JData   = JArray.Parse(json);
                        string NodeVal = "/" + settype + "/" + BulbID + "/state/" + lvltype;
                        HueBridge.HueBulbs[BulbID - 1].Bri = (uint)JData[0]["success"][NodeVal];
                        switch (lvltype)
                        {
                        case "bri":
                        {
                            BulbBri = (ushort)HueBridge.HueBulbs[BulbID - 1].Bri;
                            break;
                        }

                        case "hue":
                        {
                            BulbHue = (ushort)HueBridge.HueBulbs[BulbID - 1].Hue;
                            break;
                        }

                        case "sat":
                        {
                            BulbSat = (ushort)HueBridge.HueBulbs[BulbID - 1].Sat;
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                else
                {
                    CrestronConsole.PrintLine("Bridge not authorized");
                }
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Exception is {0}", e);
            }
        }
Exemplo n.º 3
0
 public void XYVal(string settype, ushort xval, ushort yval)
 {
     try
     {
         if (HueBridge.Authorized == true && HueBridge.Populated == true)
         {
             decimal x      = (decimal)xval / 100;
             decimal y      = (decimal)yval / 100;
             String  cmdval = "{\"xy\":[" + x.ToString() + "," + y.ToString() + "]}";
             String  json   = HueBridge.SetLvl(settype, RoomID, "action", cmdval);
         }
     }
     catch (Exception e)
     {
         CrestronConsole.PrintLine("Exception is {0}", e);
     }
 }