Skip to content

beshkin/automation-server-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Home automation server

This is a simple node.js server, which allows managing TUYA devices via POST requests.

Installation

Obtain the project

$ git clone https://github.com/beshkin/automation-server-nodejs.git

Install dependences

$ npm install

Start server

$ npm run start

Note: You need npm 14.x+

If you want to run the server as a service, I suggest using pm2 Install PM2

$ npm install pm2 -g

Start an application

$ pm2 start app.js

Listing all running processes:

$ pm2 list

It will list all process. You can then stop / restart your service by using ID or Name of the app with following command.

$ pm2 stop all
$ pm2 stop 0
$ pm2 restart all

Usage

TUYA

Switch on/off Tuya device.

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"deviceId":"DEVICE_ID","key":"DEVICE_KEY","ip":"DEVICE_IP", "action":"[off|on]"}' \
  http://localhost:8001/switch/tuya/power

Get Tuya device status

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"deviceId":"DEVICE_ID","key":"DEVICE_KEY","ip":"DEVICE_IP"' \
  http://localhost:8001/switch/tuya/power

Mi

Switch on/off Mi device

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"key":"DEVICE_KEY","ip":"DEVICE_IP", "action":"[off|on]"}' \
  http://localhost:8001/switch/mi/power

Get Mi device status

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"key":"DEVICE_KEY","ip":"DEVICE_IP"' \
  http://localhost:8001/switch/mi/power

Set brightness for Mi lamps

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"key":"DEVICE_KEY","ip":"DEVICE_IP","brightness":100}' \ 
  http://localhost:8001/switch/mi/brightness

Get brightness for Mi lamps

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"key":"DEVICE_KEY","ip":"DEVICE_IP"}' \ 
  http://localhost:8001/switch/mi/brightness

Documentation

Mi cloud light

https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published