Giter Site home page Giter Site logo

liphis / ewelinknet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luisllamasbinaburo/ewelinknet

0.0 0.0 0.0 73 KB

eWeLink API for .NET Standad (Windows, Linux and Mac)

Home Page: https://www.luisllamas.es

License: Apache License 2.0

C# 100.00%

ewelinknet's Introduction

EwelinkNET

EwelinkNET is an API writen in .NET Standard to interact directly with eWeLink API using your regular credentials. Compatible with Windows, Linux and MAC.

Key features

  • Set on/off devices
  • Read data measurements (humidity, temperature...)
  • Listen for devices events (through websockets)
  • Work online mode or offline (a.k.a. LAN mode or Zeroconf)
  • Compatible with Windows, Linux and MAC.

Basic usage

var ewelink = new Ewelink(Email, Password, Region);
await ewelink.GetCredentials();
await ewelink.GetDevices();

var device = ewelink.Devices.First(x=> x.deviceid == deviceId) as SwitchDevice;
device.TurnOn();

Get Credentials

Use Email, Password and Region to get Ewelink credentials, that includes required information to perform actions.

var ewelink = new Ewelink(Email, Password, Region);
var credentials = await ewelink.GetCredentials();

Alternately, you can save credentials to avoid login.

ewelink.StoreCredenditalsFromFile();

And later restore with,

ewelink.RestoreCredenditalsFromFile();

Get Devices

Get Devices registered in you Ewelink account.

var ewelink = new Ewelink(Email, Password, Region);
await ewelink.GetCredentials();
await ewelink.GetDevices();

Devices are converted to one of the following classes.

  • SwitchDevice
  • MultiSwitchDevice
  • ThermostatDevice
  • RFBridgeDevice
  • CurtainDevice

All of them are derived classes of generic Device class.

Interact with devices

Each class provides there own methods to perform actions or retrieve measurement. For example, ThermostatDevice provides

  • TurnOn()
  • TurnOff()
  • Toggle()
  • GetTemperature()
  • GetHumidity()

And, MultiSwitchDevice provides

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

Listen to device changes

Changes in devices status are obtain through websocket connection, and provided events.

ewelink.OnDeviceChanged += (s, e) => Console.WriteLine(e.AsJson());
ewelink.OpenWebSocket();

Loaded devices states are updated accordly with new state.

Zeroconf (LAN mode)

It's possible to interact with eWelink devices throught LAN mode, without the need of internet connection or access to eWelink cloud.

  • TurnOnLAN()
  • TurnOffLAN()

For LAN mode to work, a ArpTable (and list or the Mac - Ip relationship) has to be provided, to allow find the device Ip.

ewelink.RestoreArpTableFromFile();

Todo

  • Get credentials
  • Get devices
  • Set on/off
  • Get measurements
  • Websockets listening
  • Zeroconf (LAN mode)
  • Add/test more devices
  • Async/sync version
  • Improve documentation/examples
  • Improve tests

ewelinknet's People

Contributors

luisllamasbinaburo avatar cristiant avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.