예제 #1
0
        /// <summary>
        /// Sets a given group of RGBW bulbs to the specified hue.
        /// </summary>
        /// <remarks>
        /// MiLight bulbs do not support Saturation and Luminosity/Brightness.
        /// Use <see cref="SetTrueColor"/> for a beter representation of the color.
        /// </remarks>
        /// <param name="group">1-4 or 0 for all groups.</param>
        /// <param name="hue">The hue to set (0 - 360 degrees).</param>
        public void SetHue(int group, float hue)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new [] { HUE, HueToMiLight(hue), END };

            MiLightGateway.SendCommand(command);
        }
예제 #2
0
        /// <summary>
        /// Turns down the brightness for the specified group of
        /// white lightbulbs.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public void BrightnessDown(int group)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new [] { BRIGHTDOWN, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #3
0
        /// <summary>
        /// Sets the brightness for a group or all RGBW bulbs.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        /// <param name="percentage">The percentage (0-100) of brightness to set.</param>
        public void SetBrightness(int group, int percentage)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new byte[] { BRIGHTNESS, BrightnessToMiLight(percentage), END };

            MiLightGateway.SendCommand(command);
        }
예제 #4
0
        /// <summary>
        /// Sets a given group of RGBW bulbs to the specified color's hue. Does not
        /// support Saturation and Luminosity/Brightness of the color.
        /// For a better representation of the color use <see cref="SetTrueColor"/>.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        /// <param name="color">The <see cref="System.Drawing.Color"/> to set.</param>
        public void SetColor(int group, Color color)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new [] { HUE, HueToMiLight(color.GetHue()), END };

            MiLightGateway.SendCommand(command);
        }
예제 #5
0
        /// <summary>
        /// Switches the 'disco' mode of a group or all RGBW bulbs.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public void CycleMode(int group)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new [] { MODE, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #6
0
        /// <summary>
        /// Speeds down the current effect for a group or all RGBW bulbs.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public void SpeedDown(int group)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new [] { SPEEDDOWN, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #7
0
        /// <summary>
        /// Turns down the temperature of a group of white lights (cooler).
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public void Cooler(int group)
        {
            CheckGroup(group);             // Check and select
            SelectGroup(group);

            var command = new [] { COOLER, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #8
0
        /// <summary>
        /// Sets the 'Night' mode for the specified group or all RGBW bulbs.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public void SetNightMode(int group)
        {
            CheckGroup(group);             // Just check

            var command = new byte[] { OFF[group], NIGHT[group], END };

            MiLightGateway.SendCommand(command);

            ActiveGroup = group;
        }
예제 #9
0
        /// <summary>
        /// Switches the specified group or all RGBW bulbs to white.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public void SwitchWhite(int group)
        {
            CheckGroup(group);             // Just check

            var command = new [] { WHITE[group], ZERO, END };

            MiLightGateway.SendCommand(command);

            ActiveGroup = group;
        }
예제 #10
0
        /// <summary>
        /// Switches 'off' one or all white lightbulbs.
        /// </summary>
        /// <param name="group">1-4 or 0 for all groups.</param>
        public override void SwitchOff(int group)
        {
            CheckGroup(group);             // Just check

            var command = new [] { OFF[group], ZERO, END };

            MiLightGateway.SendCommand(command);

            ActiveGroup = group;
        }
예제 #11
0
        public static void Initialize(MiLightGateway miLightGateway)
        {
            //Sonoff Switches
            ChristmasLights = new SonoffSwitch("192.168.10.84");
            KitchenLights   = new SonoffSwitch("192.168.10.81");
            GlobusLight     = new SonoffSwitch("192.168.10.81"); //TODO IP
            BedLightBalls   = new SonoffSwitch("192.168.10.81"); //TODO IP

            //Yee Light Devices
            LightHallway = new YeelightDevice("192.168.10.77", "0x000000000361df8b", false, 0, "mono");
            StripeA      = new YeelightDevice("192.168.10.75", "0x000000000361afc3", false, 0, "stripe");
            StripeB      = new YeelightDevice("192.168.10.74", "0x0000000004555e6d", false, 0, "stripe");

            //Mi Light Devices
            BulbA = new MiBulb(miLightGateway, 1);
            BulbB = new MiBulb(miLightGateway, 2);
            BulbC = new MiBulb(miLightGateway, 3);

            //Mi Home Devices
            DoorBathroom = new DoorWindowSensor("158d0001e037e5")
            {
                CustomName = "Badezimmertür"
            };
            ApartmentDoor = new DoorWindowSensor("158d0001a5db48")
            {
                CustomName = "Wohnungstür"
            };
            SwitchA = new SimpleSwitch("158d00019dbac7")
            {
                CustomName = "Switch A"
            };
            SwitchB = new SimpleSwitch("158d00016da2ed")
            {
                CustomName = "Switch B"
            };
            MotionBathroom = new MotionSensor("158d0001d87940")
            {
                CustomName = "Motion Bathroom"
            };
            MotionHall = new MotionSensor("158d0001d47c2f")
            {
                CustomName = "Motion Hall"
            };
            MotionLivingRoom = new MotionSensor("158d00014dc328")
            {
                CustomName = "Motion Living Room"
            };
            SwitchC = new SensorSwitch("158d0001b86fed")
            {
                CustomName = "Switch C"
            };
            SwitchD = new SensorSwitch("158d0001b86f59")
            {
                CustomName = "SwitchD"
            };
            WaterLeakBathroom = new WaterLeakSensor("158d0001bb89e9")
            {
                CustomName = "Water Leak"
            };
            TempSensorLivingRoom = new TempSensor("158d0001b7edbb")
            {
                CustomName = "Temperatur Wohnzimmer"
            };
            SwitchE = new DoubleKeySwitch("158d0001718576")
            {
                CustomName = "Switch Wandregal"
            };
        }
예제 #12
0
 /// <summary>
 /// Creates an instance of the RGBWLights class to send commands
 /// to RGBW lightbulbs. Must be supplied with the (parent) controller.
 /// </summary>
 /// <param name="miLightGateway">The MiController class to use as parent.</param>
 public RGBWLights(MiLightGateway miLightGateway) : base(miLightGateway)
 {
 }
예제 #13
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Switches to the previous effect of the RGB bulb(s)/strip(s)
        /// </summary>
        public void PreviousEffect()
        {
            var command = new [] { PREVEFFECT, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #14
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Sets the give hue of the RGB bulb(s)/strip(s)
        /// </summary>
        /// <param name="hue">Hue in 0.0 - 360.0 degrees.</param>
        public void SetHue(float hue)
        {
            var command = new [] { HUE, HueToMiLight(hue), END };

            MiLightGateway.SendCommand(command);
        }
예제 #15
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Turns down the brightness of the RGB bulb(s)/strip(s)
        /// </summary>
        public void BrightnessDown()
        {
            var command = new [] { BRIGHTDOWN, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #16
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Turns up the brightness of the RGB bulb(s)/strip(s)
        /// </summary>
        public void BrightnessUp()
        {
            var command = new [] { BRIGHTUP, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #17
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Switches 'off' the RGB bulb(s)/strip(s). Groups are not used in the
        /// context of RGB bulb(s)/strip(s), so this is default set to 0 and does
        /// not have to be specified.
        /// </summary>
        public override void SwitchOff()
        {
            var command = new [] { OFF, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #18
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Speeds down the current effect of the RGB bulb(s)/strip(s)
        /// </summary>
        public void SpeedDown()
        {
            var command = new [] { SPEEDDOWN, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #19
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Speeds up the current effect of the RGB bulb(s)/strip(s)
        /// </summary>
        public void SpeedUp()
        {
            var command = new [] { SPEEDUP, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #20
0
 /// <summary>
 /// Creates an instance of the WhiteLights class to send commands
 /// to White lightbulbs. Must be supplied with the (parent) controller.
 /// </summary>
 /// <param name="miLightGateway">The MiController class to use as parent.</param>
 public WhiteLights(MiLightGateway miLightGateway) : base(miLightGateway)
 {
 }
예제 #21
0
        }                                                                    // All lights need a parent Controller

        #endregion


        #region Constructor

        protected BaseLights(MiLightGateway miLightGateway)
        {
            this.MiLightGateway = miLightGateway;
        }
예제 #22
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Sets the color of the RGB bulb(s)/strips(s). Translates
        /// to hue, no brightness or saturation taken in consideration.
        /// </summary>
        /// <param name="color">The 'System.Drawing.Color' to set.</param>
        public void SetColor(Color color)
        {
            var command = new [] { HUE, HueToMiLight(color.GetHue()), END };

            MiLightGateway.SendCommand(command);
        }
예제 #23
0
파일: RGBLights.cs 프로젝트: ermac0/mi-home
        /// <summary>
        /// Switches to the next effect of the RGB bulb(s)/strip(s)
        /// </summary>
        public void NextEffect()
        {
            var command = new [] { NEXTEFFECT, ZERO, END };

            MiLightGateway.SendCommand(command);
        }
예제 #24
0
 protected GroupLights(MiLightGateway miLightGateway) : base(miLightGateway)
 {
 }
예제 #25
0
파일: Program.cs 프로젝트: ermac0/mi-home
 private static void _InitializeMiLight()
 {
     _miLightGateway = new MiLightGateway("192.168.10.36");
 }