예제 #1
0
 /// <summary>
 /// Triggers a breathing ("fade") effect on the light. During each cycle the light fades between two colors ("fromColor" and "color"). As documented here: https://api.developer.lifx.com/docs/breathe-effect.
 /// </summary>
 /// <param name="color">Color which the light fades to. Light alternates between this and fromColor.</param>
 /// <param name="period">The time (in seconds) to complete one cycle of the effect.</param>
 /// <param name="cycles">The number of times to repeat the effect.</param>
 /// <param name="fromColor">Color which the light begins on and changes back to at the start of the next cycle. If omitted, this will be the current color of the light. Set to LifxColor.OffState to toggle between an off state and your chosen color (which must have a brightness level set above 0... default named colors will result in the light staying "off").</param>
 /// <param name="persist">If false, this sets the light back to its previous state when the effect ends. If true the light remains on the last color of the effect.</param>
 /// <param name="powerOn">If true, turn the bulb on if it is not already on.</param>
 /// <param name="peak">Defines where in a period the target color is at its maximum. Minimum 0.0, maximum 1.0.</param>
 /// <returns></returns>
 public async Task <ApiResults> BreatheEffect(LifxColor color, double period, double cycles, LifxColor fromColor = LifxClient.DEFAULT_FROM_COLOR, bool persist = LifxClient.DEFAULT_PERSIST, bool powerOn = LifxClient.DEFAULT_POWER_ON, double peak = LifxClient.DEFAULT_PEAK)
 {
     if (client == null)
     {
         return(new ApiResults());
     }
     return(await client.BreatheEffect(this, color, period, cycles, fromColor, persist, powerOn, peak));
 }
예제 #2
0
 public LightState(PowerState powerState, LifxColor color, double?brightness = null, double?duration = null, double?infrared = null)
 {
     PowerState = powerState;
     Color      = color;
     Brightness = brightness;
     Duration   = duration;
     Infrared   = infrared;
 }
예제 #3
0
 public async Task <List <ApiResult> > SetColor(LifxColor color, float duration = LifxClient.DEFAULT_DURATION, bool powerOn = LifxClient.DEFAULT_POWER_ON)
 {
     if (client == null)
     {
         return(new List <ApiResult>());
     }
     return(await client.SetColor(this, color, duration, powerOn));
 }
예제 #4
0
        /// <summary>
        /// Triggers a breathing ("fade") effect on the light. During each cycle the light fades between two colors ("fromColor" and "color"). As documented here: https://api.developer.lifx.com/docs/breathe-effect.
        /// </summary>
        /// <param name="selector">Filter for which lights are targetted</param>
        /// <param name="color">Color which the light fades to. Light alternates between this and fromColor.</param>
        /// <param name="period">The time (in seconds) to complete one cycle of the effect.</param>
        /// <param name="cycles">The number of times to repeat the effect.</param>
        /// <param name="fromColor">Color which the light begins on and changes back to at the start of the next cycle. If omitted, this will be the current color of the light. Set to LifxColor.OffState to toggle between an off state and your chosen color (which must have a brightness level set above 0... default named colors will result in the light staying "off").</param>
        /// <param name="persist">If false, this sets the light back to its previous state when the effect ends. If true the light remains on the last color of the effect.</param>
        /// <param name="powerOn">If true, turn the bulb on if it is not already on.</param>
        /// <param name="peak">Defines where in a period the target color is at its maximum. Minimum 0.0, maximum 1.0.</param>
        /// <returns></returns>
        public async Task <ApiResults> BreatheEffect(Selector selector, LifxColor color, double period, double cycles, LifxColor fromColor = null, bool persist = false, bool powerOn = DEFAULT_POWER_ON, double peak = DEFAULT_PEAK)
        {
            if (selector == null)
            {
                selector = Selector.All;
            }
            string args = string.Format("color={0}&from_color={1}&period={2}&cycles={3}&persist={4}&power_on={5}&peak={6}", color, fromColor, period, cycles, persist, powerOn, peak);

            try
            {
                return(await lifxApi.BreatheEffect(auth, selector.ToString(), args));
            }
            catch (Refit.ApiException e)
            {
                return(e.GetContentAs <ApiResults>());
            }
        }
예제 #5
0
        /// <summary>
        /// Set the light to a specific color.
        /// </summary>
        /// <param name="selector">Filter for which lights are targetted</param>
        /// <param name="color">The color to set the light to.</param>
        /// <param name="duration">How long in seconds you want the power action to take. Range: 0.0 – 3155760000.0 (100 years).</param>
        /// <param name="powerOn">If true, turn the bulb on if it is not already on.</param>
        /// <returns></returns>
        public async Task <ApiResults> SetColor(Selector selector, LifxColor color, double duration = DEFAULT_DURATION, bool powerOn = DEFAULT_POWER_ON)
        {
            if (selector == null)
            {
                selector = Selector.All;
            }
            string args = string.Format("color={0}&duration={1}", color, duration);

            if (powerOn)
            {
                args = args + "&power=" + PowerState.On.ToString().ToLowerInvariant();
            }
            try
            {
                return(await lifxApi.SetState(auth, selector.ToString(), args));
            }
            catch (Refit.ApiException e)
            {
                return(e.GetContentAs <ApiResults>());
            }
        }
예제 #6
0
        public async Task <List <ApiResult> > SetColor(Selector selector, LifxColor color, float duration = DEFAULT_DURATION, bool powerOn = DEFAULT_POWER_ON)
        {
            if (selector == null)
            {
                selector = Selector.All;
            }
            string args = string.Format("color={0}&duration={1}&power_on={2}", color, duration, powerOn);

            if (selector.IsSingle)
            {
                ApiResult result;
                try
                {
                    result = await lifxApi.SetColorSingle(auth, selector.ToString(), args);
                }
                catch (Refit.ApiException e)
                {
                    result = e.GetContentAs <ApiResult>();
                }
                return(new List <ApiResult>()
                {
                    result
                });
            }
            else
            {
                try
                {
                    return(await lifxApi.SetColor(auth, selector.ToString(), args));
                }
                catch (Refit.ApiException e)
                {
                    return(e.GetContentAs <List <ApiResult> >());
                }
            }
        }
예제 #7
0
 /// <summary>
 /// Triggers a pulsing ("strobe") effect on the light. During each cycle the light switches between two colors ("fromColor" and "color"). As documented here: https://api.developer.lifx.com/docs/pulse-effect.
 /// </summary>
 /// <param name="color">Color which the light changes to. Light alternates between this and fromColor.</param>
 /// <param name="period">The time (in seconds) to complete one cycle of the effect.</param>
 /// <param name="cycles">The number of times to repeat the effect.</param>
 /// <param name="fromColor">Color which the light begins on and changes back to at the start of the next cycle. If omitted, this will be the current color of the light. Set to LifxColor.OffState to toggle between an off state and your chosen color (which must have a brightness level set above 0... default named colors will result in the light staying off).</param>
 /// <param name="persist">If false, this sets the light back to its previous state when the effect ends. If true the light remains on the last color of the effect.</param>
 /// <param name="powerOn">If true, turn the bulb on if it is not already on.</param>
 /// <returns></returns>
 public async Task <ApiResult> PulseEffect(LifxColor color, double period, double cycles, LifxColor fromColor = LifxClient.DEFAULT_FROM_COLOR, bool persist = LifxClient.DEFAULT_PERSIST, bool powerOn = LifxClient.DEFAULT_POWER_ON)
 {
     return((await Client.PulseEffect(this, color, period, cycles, fromColor, persist, powerOn)).Results.First());
 }
예제 #8
0
 /// <summary>
 /// Set an explicit state. As documented here: https://api.developer.lifx.com/docs/set-state.
 /// </summary>
 /// <param name="powerState">On or off.</param>
 /// <param name="color">The color to set the light to.</param>
 /// <param name="brightness">The brightness level from 0.0 to 1.0. Overrides any brightness set in color (if any).</param>
 /// <param name="duration">How long in seconds you want the power action to take. Range: 0.0 – 3155760000.0 (100 years).</param>
 /// <param name="infrared">The maximum brightness of the infrared channel.</param>
 /// <returns></returns>
 public async Task <ApiResult> SetState(PowerState powerState, LifxColor color, double brightness, double duration = LifxClient.DEFAULT_DURATION, double infrared = LifxClient.DEFAULT_INFRARED)
 {
     return((await Client.SetState(this, powerState, color, brightness, duration, infrared)).Results.First());
 }
예제 #9
0
 /// <summary>
 /// Set the light to a specific color.
 /// </summary>
 /// <param name="color">The color to set the light to.</param>
 /// <param name="duration">How long in seconds you want the power action to take. Range: 0.0 – 3155760000.0 (100 years).</param>
 /// <param name="powerOn">If true, turn the bulb on if it is not already on.</param>
 /// <returns></returns>
 public async Task <ApiResult> SetColor(LifxColor color, double duration = LifxClient.DEFAULT_DURATION, bool powerOn = LifxClient.DEFAULT_POWER_ON)
 {
     return((await Client.SetColor(this, color, duration, powerOn)).Results.First());
 }
예제 #10
0
        public override bool Equals(object obj)
        {
            LifxColor color = obj as LifxColor;

            return(color != null && color.ToString() == ToString());
        }
예제 #11
0
        /// <summary>
        /// Set an explicit state. As documented here: https://api.developer.lifx.com/docs/set-state.
        /// </summary>
        /// <param name="selector">Filter for which lights are targetted</param>
        /// <param name="powerState">On or off.</param>
        /// <param name="color">The color to set the light to.</param>
        /// <param name="brightness">The brightness level from 0.0 to 1.0. Overrides any brightness set in color (if any).</param>
        /// <param name="duration">How long in seconds you want the power action to take. Range: 0.0 – 3155760000.0 (100 years).</param>
        /// <param name="infrared">The maximum brightness of the infrared channel.</param>
        /// <returns></returns>
        public async Task <ApiResults> SetState(Selector selector, PowerState powerState, LifxColor color, double brightness, double duration = LifxClient.DEFAULT_DURATION, double infrared = LifxClient.DEFAULT_INFRARED)
        {
            if (selector == null)
            {
                selector = Selector.All;
            }
            string args = string.Format("power={0}&color={1}&brightness={2}&duration={3}&infrared={4}", powerState.ToString().ToLowerInvariant(), color, brightness, duration, infrared);

            try
            {
                return(await lifxApi.SetState(auth, selector.ToString(), args));
            }
            catch (Refit.ApiException e)
            {
                return(e.GetContentAs <ApiResults>());
            }
        }