MagicHomeAPI 1.2.0

Library that imports functionality from the Magic Home app, allowing control of smart lights

Install-Package MagicHomeAPI -Version 1.2.0
dotnet add package MagicHomeAPI --version 1.2.0
<PackageReference Include="MagicHomeAPI" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MagicHomeAPI --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Magic Home NuGet DDL

A C# library that imports functionality from the Magic Home app, allowing control of smart lights.

With this, you can control your bulbs that work with the Magic Home App.

Remember to to be connected to the same network as the bulb and be able to send packets from the device.

Features

  • Discover bulbs on LAN
  • Turn On/Off
  • Turn Color and White
  • Turn Patterns
  • Use time
  • Groups for easy access to multiple bulbs
  • Logger

Missing Features:

  • Music / Microphone
  • Using in-built-timers
  • administration to set WiFi SSiD key

Installation

NuGet / [DDL]https://drive.google.com/file/d/1N8gVF5mD3ZfD7VJSwgafOgqnd-NJ1ncU/view?usp=sharing)

Documentation

Initialization

Light myLight = new Light(&quot;LANAdress&quot;);

This will create the light, connect it and extract all the data from it (color, protocol, etc).

Discovery

Light myLight = Light.Discover()[0];

This will discover all lights on the LAN, and assign the first one to myLight.

Usage

myLight.TurnOff();

Sets the light on and off.

myLight.SetColor(255, 0, 0); // color in bytes as R G B
myLight.SetColor("#ff0000"); // color in hex
myLight.SetColor(new RGB(255, 0, 0)); // color as RGB class

Different ways to change the color

myLight.SetPresetPattern(PresetPattern.PatternHere, 100)

Sets a preset pattern from the enum.
Speed (second param) goes from 1 to 100.

myLight.SetCustomPattern(RGBArray, TransitionType.Gradual, 100)

Sets a custom pattern from a RGB Array, a transition and speed.

myLight.SetBrightness(50);

Sets the brightness (UNSTABLE!)

Using RGB class

RGB myColor = new RGB(color bytes or hex);
RGB[] myColors = new RGB[3]; // create an array of colors so we can use SetCustomPattern();
myColors[0].Set(255, 0, 0);
myColors[1].Set(0, 255, 0);
myColors[2].Set(0, 0, 255);

SetCustomPattern(myColors, TransitionType.Strobe, 100);

Groups

LightGroup myGroup = new LightGroup(Light.Discovery());

Create a group of lights and assign all bulbs discovered on your LAN. You can control all your lights simultaneously by simply calling myGroup.MethodHere();

Set Time and Get Time

SetTime(DateTime dt); // sets the time of the device to dt
GetTime(); // gets the time of the device

Properties

Protocol, Color, Brightness, Time, IsOn, Mode, Logger, Socket. Use property Stats as a string containing all data. Use property DiscoveredAdresses to get all discovered IPs if you used Light.Discover();

LightLogger

All logs are automatically saved in the assembly folder. To change that, or disable the logger:

myLight.Logger.LogPath = "X:\\pathhere\\";
//OR
myLight.Logger = new LightLogger(myLight, "path");

myLight.Logger.Enabled = false; //or true to enable/disable

Contact me on github or at dragusinnathaniel@gmail.com

Thanks to my teacher and bevile

Magic Home NuGet DDL

A C# library that imports functionality from the Magic Home app, allowing control of smart lights.

With this, you can control your bulbs that work with the Magic Home App.

Remember to to be connected to the same network as the bulb and be able to send packets from the device.

Features

  • Discover bulbs on LAN
  • Turn On/Off
  • Turn Color and White
  • Turn Patterns
  • Use time
  • Groups for easy access to multiple bulbs
  • Logger

Missing Features:

  • Music / Microphone
  • Using in-built-timers
  • administration to set WiFi SSiD key

Installation

NuGet / [DDL]https://drive.google.com/file/d/1N8gVF5mD3ZfD7VJSwgafOgqnd-NJ1ncU/view?usp=sharing)

Documentation

Initialization

Light myLight = new Light(&quot;LANAdress&quot;);

This will create the light, connect it and extract all the data from it (color, protocol, etc).

Discovery

Light myLight = Light.Discover()[0];

This will discover all lights on the LAN, and assign the first one to myLight.

Usage

myLight.TurnOff();

Sets the light on and off.

myLight.SetColor(255, 0, 0); // color in bytes as R G B
myLight.SetColor("#ff0000"); // color in hex
myLight.SetColor(new RGB(255, 0, 0)); // color as RGB class

Different ways to change the color

myLight.SetPresetPattern(PresetPattern.PatternHere, 100)

Sets a preset pattern from the enum.
Speed (second param) goes from 1 to 100.

myLight.SetCustomPattern(RGBArray, TransitionType.Gradual, 100)

Sets a custom pattern from a RGB Array, a transition and speed.

myLight.SetBrightness(50);

Sets the brightness (UNSTABLE!)

Using RGB class

RGB myColor = new RGB(color bytes or hex);
RGB[] myColors = new RGB[3]; // create an array of colors so we can use SetCustomPattern();
myColors[0].Set(255, 0, 0);
myColors[1].Set(0, 255, 0);
myColors[2].Set(0, 0, 255);

SetCustomPattern(myColors, TransitionType.Strobe, 100);

Groups

LightGroup myGroup = new LightGroup(Light.Discovery());

Create a group of lights and assign all bulbs discovered on your LAN. You can control all your lights simultaneously by simply calling myGroup.MethodHere();

Set Time and Get Time

SetTime(DateTime dt); // sets the time of the device to dt
GetTime(); // gets the time of the device

Properties

Protocol, Color, Brightness, Time, IsOn, Mode, Logger, Socket. Use property Stats as a string containing all data. Use property DiscoveredAdresses to get all discovered IPs if you used Light.Discover();

LightLogger

All logs are automatically saved in the assembly folder. To change that, or disable the logger:

myLight.Logger.LogPath = "X:\\pathhere\\";
//OR
myLight.Logger = new LightLogger(myLight, "path");

myLight.Logger.Enabled = false; //or true to enable/disable

Contact me on github or at dragusinnathaniel@gmail.com

Thanks to my teacher and bevile

Release Notes

Now RGBWW works as well.

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 119 3/5/2019