/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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; }
/// <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; }
/// <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; }
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" }; }
/// <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) { }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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) { }
} // All lights need a parent Controller #endregion #region Constructor protected BaseLights(MiLightGateway miLightGateway) { this.MiLightGateway = miLightGateway; }
/// <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); }
/// <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); }
protected GroupLights(MiLightGateway miLightGateway) : base(miLightGateway) { }
private static void _InitializeMiLight() { _miLightGateway = new MiLightGateway("192.168.10.36"); }