-
Notifications
You must be signed in to change notification settings - Fork 4
70. tuyaDAEMON REST
Marco Sillano edited this page Jul 22, 2023
·
2 revisions
To make tuyaDEAMON more useful an optional REST interface has been added, so it is even easier to develop WEB-enabled projects (see as an example the PHP application tuyaDAEMO toolkit). The tuyaDAEMOM REST is implemented using two interfaces, for different purposes:
- Syntax:
http://<your-node-red-url>/tuyaDAEMON[?device=<name>[&property=<name|dp>[&value=<a-value>]]]
- Fast asynchronous processing, immediate response.
- Return JSON: data or status.
- GET, SCHEMA: solved by global
tuyastatus
, always returns data, so any device accepts GET and SCHEMA requests (note: these requests are NOT saved in the log). - SET: sent to tuyaDEAMON CORE, immediately returns 'status:sent message' (note: these requests CAN be saved to the DB log).
- REDTRG: to activate a red trigger, send a SET to
_system
, property:_doTrigger
, value: the trigger number.
Examples:
-
SET:
http://localhost:1984/tuyaDAEMON?device=tuya_bridge&property=switch&value=OFF
- answer:
{"status":"sent"}
- answer:
-
GET:
http://localhost:1984/tuyaDAEMON?device=tuya_bridge&property=switch
- answer:
"device":"tuya_bridge","property":"switch","value":"OFF"}
- answer:
-
SCHEMA:
http://localhost:1984/tuyaDAEMON?device=tuya_bridge
- answer:
{"_connected":true,"_t":1611594148,"reserved (trigger)":0,"switch":"OFF"}
- answer:
-
REDTRG20020:
http://localhost:1984/tuyaDAEMON?device=HAL@home&property=_doTrigger&value=20020
- answer:
{"status":"sent"}
- answer:
- Syntax:
http://<your-node-red-url>/tuyaDAEMONdebug[?device=<name|id>[&property=<name|dp|MULTIPLE>[&value=<a-value>|<couples-dp:set>]]]
- Slow synchronous process, it waits always for device response or timeout (actual default 8s).
- All commands are sent to devices (beware of capability limits in
alldevices
for device or dp) using tuyaDEAMON CORE. - Return JSON: data or status.
- The 'MULTIPLE'
value
is low-level: it is not processed (if it is a JSON string it is parsed) but it is sent 'as is' to thetuya-smart-device
node. - All requests CAN be saved to the DB log
Examples:
-
SET:
http://localhost:1984/tuyaDEAMONdebug?device=tuya_bridge&property=switch&value=OFF
- answer:
{"device":"tuya_bridge","property":"switch","value":"OFF"}
(i.e. this dp accepts SET )
- answer:
-
GET:
http://localhost:1984/tuyaDEAMONdebug?device=tuya_bridge&property=switch
- answer:
{"device":"tuya_bridge","property":"switch","value":"OFF"}
(i.e. the dp accepts also GET: it is 'RW' )
- answer:
-
SCHEMA:
http://localhost:1984/tuyaDEAMONdebug?device=tuya_bridge
- answer:
{"status":"request aborted for timeout"}
(i.e. this device does not accept SCHEMA request - if ok values from globaltuyastatus
)
- answer:
-
MULTIPLE:
http://localhost:1984/tuyaDAEMONdebug?device=umidificatore&property=MULTIPLE&value={"5":true,"6":"colour","8":"0080800000FFFF"}
- answer:
{"device":"umidificatore","property":"led","value":"ON"}
(if ok returns the first property+value)
- answer:
-
REDTRG20020:
http://localhost:1984/tuyaDEAMONdebug?device=HAL@home&property=_doTrigger&value=20020
- answer:
{"device":"HAL@home","property":"_doTrigger","value":20020}
- answer:
a) All REST interfaces, called without parameters, return a JSON list with the names of all devices (real, virtual, mirror, fake). Example:
-
call:
http://localhost:1984/tuyaDAEMON
- answer:
["Zigbee Gateway","Smart IR 1","HAL@home","tuya_bridge", "USB siren","Sensore porta"]
- answer:
b) The base URL (for me: 'http://localhost:1984') is the node-red server URL.