Giter Club home page Giter Club logo

ewelink's Introduction

eWeLink API library

Ewelink SDK to control your eWelink smart devices.

Build Status Reviewdog Go Report Card GoDoc Codacy Badge

Check out the API Documentation http://godoc.org/github.com/NicklasWallgren/ewelink

Installation

The library can be installed through go get

go get github.com/NicklasWallgren/ewelink

Supported versions

We support the two major Go versions, which are 1.15 and 1.16 at the moment.

Features

  • Retrieve devices
  • Turn on/off devices
  • Get power consumption [TODO]

Examples

Initiate power state request

import (
    "context"
    "fmt"
    "github.com/NicklasWallgren/ewelink"
)

instance := ewelink.New()

// authenticate using email
session, err := instance.AuthenticateWithEmail(
	context.Background(), ewelink.NewConfiguration("REGION"), "EMAIL", "PASSWORD")

// retrieve the list of registered devices
devices, err := instance.GetDevices(context.Background(), session)

// turn on the outlet(s) of the first device
response, err := instance.SetDevicePowerState(context.Background(), session, &devices.Devicelist[0], true)

fmt.Println(response)
fmt.Println(err)

Custom AppId and AppSecret

You can provide your own AppId and AppSecret, which can be retrieved from https://dev.ewelink.cc.

ewelink.NewConfiguration("REGION", ewelink.WithAppID("APP_ID"), ewelink.WithAppSecret("APP_SECRET"))

Unit tests

go test -v -race ./...

Code Guide

We use GitHub Actions to make sure the codebase is consistent (golangci-lint run) and continuously tested (go test -v -race $(go list ./... | grep -v vendor)). We try to keep comments at a maximum of 120 characters of length and code at 120.

Contributing

If you find any problems or have suggestions about this library, please submit an issue. Moreover, any pull request, code review and feedback are welcome.

ewelink's People

Contributors

ant1eicher avatar jacostaperu avatar nicklaswallgren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ewelink's Issues

LAN MODE

This lib have implemented LAN mode integration?

Power reading not yet implemented

Any suggestions or documentation how I can add this (or a final date when you will have implemented this) ?
I only need the power reading features.
I am writing software that can identify the individual devices (airco, freezer, cooking, oven, circulation, ...) and the timing when they are ON/OFF (assuming these are not switched ON/OFF by ewelink)

AuthenticateWithEmail not working

I tried the initiate power request example but my login failed with this error:

failed to authenticate unable to authenticate using email. ewelink.apiError{Code:403, Message:"Sign:oauthClient enable invalid", Cause:""}

Is There Any PHP Version

Hello everyone.

I want a web page and switch on and off sonoff devices with php code.

Can anybody help me?

Please write here.

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.