Language: EN


Interact with the SmartLife API from .NET with SmartLifeNET

SmartLifeNET is an API written in .NET Standard that allows us to interact directly with the SmartLife API using the user credentials used by the official application.

With SmartLifeNET, it is compatible with Windows, Linux, and MAC, Android and iOS, and allows actions to be performed on devices or measurements to be obtained (temperature, humidity, power consumption, etc.) from those devices that have such functionality.

Some of the key features of SmartLifeNET are:

  • Turn devices on and off
  • Read measurements (humidity, temperature, etc.)
  • Multiplatform

For devices controlled by eWelink, visit the library eWelinkNET

Basic usage

Here is a basic example of how to use SmartLifeNET.

var smart = new SmartLife(email, password);
await smart.Connect();
await smart.InitDevices();

var device = smart.Devices.FirstOrDefault(x => x is SmartLifeNet.Classes.SwitchDevice) as SmartLifeNet.Classes.SwitchDevice;
await device?.SetState(1);

Get Credentials

We can obtain the credentials necessary to perform the necessary actions using our Email and Password.

var smart = new SmartLife(email, password);
var credentials = await smart.GetCredentials();

Alternatively, you can save the obtained credentials to avoid having to log in later.


Later, we can retrieve the credentials by doing.


Get Devices

We can get the devices registered in your SmartLife account.

var smart = new SmartLife(email, password);
await smart.Connect();
await smart.InitDevices();

The devices become the following classes.

  • SwitchDevice
  • MultiSwitchDevice

All of them derive from the base class ‘Device’.

Interact with the devices

Each class has its own methods to perform the actions allowed by the type of device.

So, for example, ‘SingleSwitchDevice’ provides,

  • TurnOn()
  • TurnOff()

While ‘MultiSwitchDevice’ provides,

  • TurnOn()
  • TurnOn(int channel)
  • TurnOff()
  • TurnOff(int channel)

Download the code

SmartLife is an OpenSource development. The code for this post is available for download on GitHub. github-full