Ejemplo n.º 1
0
        /// <summary>
        /// Set Dimmer for Light Device
        /// </summary>
        /// <param name="id">Id of the device</param>
        /// <param name="value">Dimmer intensity (0-255)</param>
        /// <returns></returns>
        public async Task SetDimmer(long id, int value)
        {
            SwitchStateRequest set = new SwitchStateRequest()
            {
                Options = new[]
                {
                    new SwitchStateRequestOption()
                    {
                        LightIntensity = value
                    }
                }
            };

            await HandleRequest($"/{(int)TradfriConstRoot.Devices}/{id}", Call.PUT, content : set, statusCode : System.Net.HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Turns a specific light on or off
        /// </summary>
        /// <param name="id">Id of the device</param>
        /// <param name="state">On (True) or Off(false)</param>
        /// <returns></returns>
        public async Task SetLight(long id, bool state)
        {
            SwitchStateRequest set = new SwitchStateRequest()
            {
                Options = new[]
                {
                    new SwitchStateRequestOption()
                    {
                        isOn = state ? 1 : 0
                    }
                }
            };

            await HandleRequest($"/{(int)TradfriConstRoot.Devices}/{id}", Call.PUT, content : set);
        }