Exemple #1
0
        /// <summary>
        /// Sets a group to be on/off/scene select
        /// </summary>
        /// <param name="action">"true", "false", "scene"</param>
        public void GroupAction(string actiontype, string actioncmd, string effect)
        {
            try
            {
                if (HueBridge.Authorized == true && HueBridge.Populated == true)
                {
                    String json        = HueBridge.SetOnOff("groups", RoomID, actioncmd, "action", effect);
                    JArray JReturn     = JArray.Parse(json);
                    string tokenreturn = "/groups/" + RoomID + "/action/" + actiontype;
                    foreach (var Jobj in JReturn)
                    {
                        var    myaction   = Jobj["success"];
                        string whodidwhat = myaction.ToString();
                        if (whodidwhat.Contains(tokenreturn))
                        {
                            HueBridge.HueGroups[RoomID - 1].On = (bool)myaction[tokenreturn];
                            GroupIsOn = (ushort)(HueBridge.HueGroups[RoomID - 1].On ? 1 : 0);
                        }
                    }

                    /*
                     * for (int i = 0; i < JReturn.Count; i++)
                     * {
                     *  if (json.Contains("success"))
                     *  {
                     *      var JData = JReturn[i].SelectToken("success");
                     *      //string tokenreturn = "/groups/" + RoomID + "/action/" + actiontype;
                     *      string tokenreturn = "/groups/" + RoomID + "/action/on";
                     *      if (JData.Contains(tokenreturn))
                     *      {
                     *
                     *          break;
                     *      }
                     *  }
                     * }*/
                }
                else
                {
                    CrestronConsole.PrintLine("Bridge not authorized");
                }
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Exception is {0}", e);
            }
        }
 public void LightsOn()
 {
     try
     {
         if (HueBridge.Authorized == true)
         {
             String json = HueBridge.SetOnOff("lights", BulbID, "true", "state", "none");
             if (json.Contains("success"))
             {
                 HueBridge.HueBulbs[BulbID - 1].On = true;
                 BulbIsOn = 1;
             }
         }
         else
         {
             CrestronConsole.PrintLine("Bridge not authorized");
         }
     }
     catch (Exception e)
     {
         CrestronConsole.PrintLine("Exception is {0}", e);
     }
 }