This is a simple node.js server, which allows managing TUYA devices via POST requests.
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
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
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
https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf