MagicHomeAPI 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MagicHomeAPI --version 1.2.0                
NuGet\Install-Package MagicHomeAPI -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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                
#r "nuget: MagicHomeAPI, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MagicHomeAPI as a Cake Addin
#addin nuget:?package=MagicHomeAPI&version=1.2.0

// Install MagicHomeAPI as a Cake Tool
#tool nuget:?package=MagicHomeAPI&version=1.2.0                

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

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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 Downloads Last updated
1.4.0 1,031 6/23/2020
1.2.0 1,008 3/5/2019

Now RGBWW works as well.