Example #1
0
        public static string ControlLight(string LightID, string Value)
        {
            string resp       = "";
            bool   errorstate = false;

            try
            {
                resp += "Attempting to control light " + LightID + " and set its value to " + Value + "\n";
                Devices.Light light = Variables.lights[Convert.ToInt32(LightID)];
                switch (light.Type)
                {
                case "LUTRON":
                    resp += "Issuing command to lutron module\n";
                    resp += ControlLutronDimmableLight(light.ID, Value);
                    break;

                case "RELAY":
                    resp += "Issuing command to relay module\n";
                    if (Convert.ToInt32(Value) > 1)
                    {
                        Value = "1";
                    }
                    Control.Relay.SetState(light.RelayID, Convert.ToBoolean(Value));
                    break;
                }
            }
            catch (Exception ex)
            {
                Variables.logger.LogLine(ex.Message);
                errorstate = true;
            }
            if (errorstate)
            {
                return("Error: ControlLight encountered an error, please review logs.\n");
            }
            else
            {
                return(resp);
            }
        }
 public LightOffCommand(Devices.Light light)
 {
     _light = light;
 }