Code Monkey home page Code Monkey logo

home-automation's Introduction

home-automation REST api for tp-link devices

A Rest API with endpoints to perform operations on TP-Link smart home devices.

Supported devices

Plug - HS100, HS103, HS105, HS107, HS110, HS200, HS220, HS300

Bulb - LB100, LB110, LB120, LB130, LB200, LB230

Requires

Dependency

tplink-smarthome-api

Requires a MongoDB instance running on localhost:27017 or change the url at /config/default.js

Starting the app

$ npm install 
$ npm start

Endpoints

Devices

GET /devices/list

List all devices

Response body:

{
    "devices": [
        {
            "_id": "5df5ab687d3532e777ddb8db",
            "deviceId": "1234ZE34E60ABDAJH882364767E0B46691A225F67",
            "host": "192.168.0.100",
            "type": "bulb"
        }
    ]
}

GET /devices/ip/:host

Get a device using host address

Response body:

{
    "status": "success",
    "message": "device found",
    "data": {
        "host": "12.11.0.100",
        "model": "LB130(EU)",
        "description": "Smart Wi-Fi LED Bulb with Color Changing",
        "alias": "Living room light",
        "type": "bulb",
        "state": {
            "power": "on",
            "lightingState": {
                "mode": "normal",
                "hue": 0,
                "saturation": 0,
                "color_temp": 4000,
                "brightness": 100
            }
        }
    }
}

Bulbs

POST /bulb/ip/turnOn

Turn on bulb using the host address

Request body:

{
	"host": "12.11.0.100"
}

Response body:

{
	"message": "Living room light switched on",
	"status": "success"
}

POST /bulb/ip/turnOff

Turn off bulb using the host address

Request body:

{
	"host": "12.11.0.100"
}

Response body:

{
	"message": "Living room light switched off",
	"status": "success"
}

POST /bulb/ip/brightness

Set the brightness of a bulb using the host address

Request body:

{
    "host": "12.11.0.100",
    "brightness": "20"
}

Response body:

{
	"message": "Living room light brightness set to 20",
	"status": "success"
}

POST /bulb/ip/color

Set the color of a bulb by hex value using the host address

Request body:

{
    "host": "12.11.0.100",
    "color": "2BFF24"
}

Response body:

{
	"message": "Living room light colour set to HSV 118 86 100",
	"status": "success"
}

POST /bulb/ip/colorTemperature

Set the color temperature of a bulb using the host address

Request body:

{
    "host": "12.11.0.100",
    "temperature": "4000"
}

Response body:

{
	"message": "Living room light colour temperature set to 4000",
	"status": "success"
}

Plugs

POST /plug/ip/turnOn

Turn on bulb using the host address

Request body:

{
	"host": "12.11.0.111"
}

Response body:

{
	"message": "Computer switched on",
	"status": "success"
}

POST /plug/ip/turnOff

Turn off bulb using the host address

Request body:

{
	"host": "12.11.0.111"
}

Response body:

{
	"message": "Computer switched off",
	"status": "success"
}

home-automation's People

Contributors

dependabot[bot] avatar kooixh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.