Skip to content

Commit

Permalink
Merge pull request #121 from vinodsr/feature/improve-code-base
Browse files Browse the repository at this point in the history
Bump to version 5.2.0
  • Loading branch information
vinodsr authored Jun 11, 2023
2 parents bb90074 + 2a88442 commit 6621d7b
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 5.2.0

- Added new control action "SET_EVENT_MODE"
- Improve the code base
- Improved example

## 5.1.0

- Update tuya CLI to v7.5.1 (https://github.com/vinodsr/node-red-contrib-tuya-smart-device/pull/110)
Expand Down
137 changes: 129 additions & 8 deletions examples/latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": "b2e04683.825318",
"type": "tab",
"label": "Flow 1",
"label": "Example Flow",
"disabled": false,
"info": ""
},
Expand All @@ -14,11 +14,13 @@
"disableAutoStart": true,
"deviceId": "",
"deviceKey": "",
"storeAsCreds": false,
"deviceIp": "",
"retryTimeout": "1001",
"findTimeout": "2000",
"tuyaVersion": "3.1",
"eventMode": "event-both",
"credentials": { "secretConfig": "{}" },
"x": 680,
"y": 360,
"wires": [["ff4bd686.53ae18"], ["15d22ba6.824b84"]]
Expand Down Expand Up @@ -77,7 +79,7 @@
"z": "b2e04683.825318",
"name": "",
"x": 660,
"y": 540,
"y": 740,
"wires": [["1e77cd28.a8c303"]]
},
{
Expand All @@ -91,7 +93,7 @@
"initialize": "",
"finalize": "",
"x": 450,
"y": 540,
"y": 740,
"wires": [["e4cfcdc.9520a3"]]
},
{
Expand All @@ -108,7 +110,7 @@
"payload": "true",
"payloadType": "bool",
"x": 240,
"y": 580,
"y": 780,
"wires": [["81a451cc.919f9"]]
},
{
Expand All @@ -124,7 +126,7 @@
"statusVal": "",
"statusType": "auto",
"x": 940,
"y": 540,
"y": 740,
"wires": []
},
{
Expand All @@ -141,7 +143,7 @@
"payload": "false",
"payloadType": "bool",
"x": 240,
"y": 500,
"y": 700,
"wires": [["81a451cc.919f9"]]
},
{
Expand Down Expand Up @@ -219,8 +221,8 @@
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"RECONNECT\"}",
"payloadType": "json",
"x": 330,
"y": 220,
"x": 340,
"y": 260,
"wires": [["e63245d0.e6cdc8"]]
},
{
Expand All @@ -236,6 +238,125 @@
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"DISCONNECT\"}",
"payloadType": "json",
"x": 340,
"y": 200,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "c820897454429637",
"type": "inject",
"z": "b2e04683.825318",
"name": "Get Schema",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"GET\",\"schema\":true}",
"payloadType": "json",
"x": 310,
"y": 100,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "7b416b83a6edfd2b",
"type": "inject",
"z": "b2e04683.825318",
"name": "Get Status of dps 1",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"GET\" , \"dps\": 1}",
"payloadType": "json",
"x": 330,
"y": 40,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "8616fca1bda4ddbf",
"type": "inject",
"z": "b2e04683.825318",
"name": "SET EVENT MODE - DATA",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"SET_EVENT_MODE\",\"value\":\"event-data\"}",
"payloadType": "json",
"x": 260,
"y": 460,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "cbe30d8393fbb66a",
"type": "inject",
"z": "b2e04683.825318",
"name": "SET EVENT MODE - DP REFRESH",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"SET_EVENT_MODE\",\"value\":\"event-dp-refresh\"}",
"payloadType": "json",
"x": 280,
"y": 500,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "4df579385b195b55",
"type": "inject",
"z": "b2e04683.825318",
"name": "Update Find Timeout",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"SET_FIND_TIMEOUT\",\"value\":1234}",
"payloadType": "json",
"x": 230,
"y": 540,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "65ab15b279337d86",
"type": "inject",
"z": "b2e04683.825318",
"name": "Update Retry Timeout",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"SET_RETRY_TIMEOUT\",\"value\":1234}",
"payloadType": "json",
"x": 240,
"y": 580,
"wires": [["e63245d0.e6cdc8"]]
},
{
"id": "51d98c1b9e3ce54b",
"type": "inject",
"z": "b2e04683.825318",
"name": "CONNECT ACTION",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"operation\":\"CONTROL\",\"action\":\"CONNECT\"}",
"payloadType": "json",
"x": 330,
"y": 160,
"wires": [["e63245d0.e6cdc8"]]
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-tuya-smart-device",
"version": "5.1.0",
"version": "5.2.0",
"description": "A node-red module to interact with the tuya smart devices",
"repository": "https://github.com/vinodsr/node-red-contrib-tuya-smart-device",
"main": "index.js",
Expand All @@ -14,12 +14,16 @@
"node-red"
],
"node-red": {
"version": ">=2.5.0",
"nodes": {
"tuya-smart-device": "src/tuya-smart-device.js",
"tuya-smart-device-generic": "src/tuya-smart-device-generic.js"
}
},
"dependencies": {
"tuyapi": "7.5.1"
"tuyapi": "~7.5.1"
},
"engines": {
"node": ">=16.0.0"
}
}
31 changes: 29 additions & 2 deletions src/tuya-smart-device.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ <h4>payload</h4>
} }</code
>
</dd>
<dt class="">dps <span class="property-type">action</span></dt>
<dt class="">action <span class="property-type">string</span></dt>
<dd>
This property works only with operation is set as "CONTROL"

Expand All @@ -353,7 +353,7 @@ <h4>payload</h4>
<td>Disconnect from the device</td>
</tr>
<tr>
<td>RECONNECTS</td>
<td>RECONNECT</td>
<td>Reconnects to the device</td>
</tr>
<tr>
Expand All @@ -368,7 +368,34 @@ <h4>payload</h4>
Sets the retry timeout dynamically. This is not saved in the config
</td>
</tr>
<tr>
<td>SET_EVENT_MODE</td>
<td>
Sets the event mode dynamically. This is not saved in the config.
<br />
<br />
value = event-data //for subscribing to only data event
<br />
<br />
value = event-dp-refresh //for subscribing to only dp-refresh event
<br />
<br />
value = both //for subscribing to both events
</td>
</tr>
</table>
example :
<div>
action : CONNECT
<code> payload = { "operation": "CONTROL", "action": "CONNECT" } </code>
</div>
<div>
action : SET_EVENT_MODE
<code>
payload = { "operation": "CONTROL", "action": "SET_EVENT_MODE",
"value": "event-data" }
</code>
</div>
</dd>
</dl>

Expand Down
Loading

0 comments on commit 6621d7b

Please sign in to comment.