MagicHome.NET 1.3.0

Library that imports functionality from the Magic Home app, allowing control of smart lights. Forked from nathanielxd/magic-home with improvements and refactoring.

There is a newer version of this package available.
See the version list below for details.
Install-Package MagicHome.NET -Version 1.3.0
dotnet add package MagicHome.NET --version 1.3.0
<PackageReference Include="MagicHome.NET" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MagicHome.NET --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Magic Home for .NET NuGet Build Status

⚠ This repository was forked from nathanielxd/magic-home and includes improvements and refactored code.

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

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();

Magic Home for .NET NuGet Build Status

⚠ This repository was forked from nathanielxd/magic-home and includes improvements and refactored code.

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

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();

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.0.0 123 2/3/2020
1.3.0 234 2/1/2020