diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 7026ca7..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 60 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security -# Label to use when marking an issue as stale -staleLabel: wontfix -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: > - Auto closing the issue \ No newline at end of file diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index e1f7714..0000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,24 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Build and Publish package - -on: - push: - branches: [ master ] - -jobs: - publish: - #if: ${{ contains(github.event.head_commit.message, '#publish') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - run: npm install - - run: npm publish --dry-run - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c8db0e3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Release publish + +on: + push: + branches: + - master + +jobs: + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + always-auth: true + - name: Publish + run: | + npm ci + npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NODE_TKN}} + - name: Update Node-Red flow-library + uses: Zehir/update-package-node-red-flow-library-action@v1.0.5 + continue-on-error: true + with: + package-name: '@nrchkb/node-red-tuya-smart-device' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6704566..1c3d942 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ dist # TernJS port file .tern-port + +.idea +.vscode diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b0ffbb0..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "workbench.colorCustomizations": { - "activityBar.activeBackground": "#f4b24b", - "activityBar.activeBorder": "#09965f", - "activityBar.background": "#f4b24b", - "activityBar.foreground": "#15202b", - "activityBar.inactiveForeground": "#15202b99", - "activityBarBadge.background": "#09965f", - "activityBarBadge.foreground": "#e7e7e7", - "statusBar.background": "#f19e1b", - "statusBar.foreground": "#15202b", - "statusBarItem.hoverBackground": "#cc820d", - "titleBar.activeBackground": "#f19e1b", - "titleBar.activeForeground": "#15202b", - "titleBar.inactiveBackground": "#f19e1b99", - "titleBar.inactiveForeground": "#15202b99", - "sash.hoverBorder": "#f4b24b", - "statusBarItem.remoteBackground": "#f19e1b", - "statusBarItem.remoteForeground": "#15202b", - "commandCenter.border": "#15202b99" - }, - "peacock.color": "#f19e1b" -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 76cf8dd..9a27628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 0.1.0 - 2024-07-01 + +### Changed + +- Forked :) + +### Added + +- You can now provide Query Properties Map for Smart Device, it will make dps to be translated into human-readable format. You can generate the map on tuya IoT Platform > Device Control > Query Properties + +# Legacy Changelog + ## 5.3.0 - Added log level control to each node @@ -12,19 +24,19 @@ ## 5.1.0 -- Update tuya CLI to v7.5.1 (https://github.com/vinodsr/node-red-contrib-tuya-smart-device/pull/110) +- Update tuya CLI to v7.5.1 (https://github.com/NRCHKB/node-red-tuya-smart-device/pull/110) ## 5.0.1 -- Fix error validating the creds in the view mode. This is an known issue [node-red#3420](https://github.com/node-red/node-red/issues/3420) +- Fix error validating the credentials in the view mode. This is a known issue [node-red#3420](https://github.com/node-red/node-red/issues/3420) ## 5.0.0 - Updated TuyaAPI to `7.3.0` -- Added support to store device Id and device Key as credentials [#77](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/77) +- Added support to store device-id and device-key as credentials [#77](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/77) - Changed the default find timeout value to 10 seconds - Renamed `tuya smart device generic` node to `tuya smart device hub` - > Thanks to [foxylion](https://github.com/foxylion) for suggesting the crendentials feature + > Thanks to [foxylion](https://github.com/foxylion) for suggesting the credentials feature ## 4.1.1 @@ -37,13 +49,13 @@ ## 4.1.0 - Added CONTROL commands as input (CONNECT, DISCONNECT, RECONNECT) -- Seperate output node for device status and client status +- Separate output node for device status and client status - Dynamically set the find and retry timeout (Not saved permanently in the config) - Disable auto connect on start ## 4.0.2 -- Added support for both data and dp-refresh event [#54](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/54) +- Added support for both data and dp-refresh event [#54](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/54) ## 4.0.1 @@ -51,15 +63,15 @@ ## 4.0.0 -- Update to Tuya 7.1.0. Closes [#51](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/51) +- Update to Tuya 7.1.0. Closes [#51](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/51) ## 3.1.0 -- Added support for catch node. If there a catch node in the flow, the tuya smart device node will not throw any error to the debug window. Implementing [#47](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/47) +- Added support for catch node. If there is a catch node in the flow, the tuya smart device node will not throw any error to the debug window. Implementing [#47](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/47) ## 3.0.2 -- Fixes [#43](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/43) +- Fixes [#43](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/43) ## 3.0.1 @@ -67,21 +79,21 @@ ## 3.0.0 -Fixes [#35](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/35) -Fixes [#39](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/39) +Fixes [#35](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/35) +Fixes [#39](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/39) - Optimized code ## 2.0.0 -Fixes [#33](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/33) +Fixes [#33](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/33) - Tuya api library updated to 6.1.1 - No more null data payload on json undefined error. :) ## 1.2.1 -Fixes [#25](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/25) +Fixes [#25](https://github.com/NRCHKB/node-red-tuya-smart-device/issues/25) ## 1.2.0 diff --git a/README.md b/README.md index 53dc316..8f78f30 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # node-red-contrib-tuya-smart-device +This package is based and continues the work of https://github.com/vinodsr/node-red-contrib-tuya-smart-device + ![npm](https://img.shields.io/npm/v/node-red-contrib-tuya-smart-device) ![NPM](https://img.shields.io/npm/dm/node-red-contrib-tuya-smart-device) -![Build and Publish package](https://github.com/vinodsr/node-red-contrib-tuya-smart-device/workflows/Build%20and%20Publish%20package/badge.svg) +![Build and Publish package](https://github.com/NRCHKB/node-red-tuya-smart-device/workflows/Build%20and%20Publish%20package/badge.svg) ![License](https://img.shields.io/github/license/vinodsr/node-red-contrib-tuya-smart-device) -A node-red module which helps you to connect to any tuya device. +A node-red module which helps you to connect to any Tuya device. ![image](./img/sample.png) @@ -31,9 +33,9 @@ A node-red module which helps you to connect to any tuya device. - Controls multiple device using a single node using generic node (hub node) - Can use device IP for communication - Configure retry and find intervals -- Ability to setup Tuya Protocol Version +- Ability to set up Tuya Protocol Version - Ability to listen to both `Data` and `DP-Refresh` event -- Can store deviceId and deviceKey as crendentials +- Can store deviceId and deviceKey as credentials - Better error handling - Better log handling @@ -45,9 +47,9 @@ Instructions for getting the device id is available [here](https://github.com/co > > [https://github-wiki-see.page/m/iRayanKhan/homebridge-tuya/wiki/Get-Local-Keys-for-your-devices](https://github.com/iRayanKhan/homebridge-tuya/wiki/Get-Local-Keys-for-your-devices) -You will get the device id and the key once you run the wizard program as per the instructiions +You will get the device id and the key once you run the wizard program as per the instructions -Get more details about latest version changes in the [CHANGELOG.md](./changelog.md) +Get more details about latest version changes in the [CHANGELOG.md](CHANGELOG.md) # Setup @@ -55,7 +57,7 @@ Get more details about latest version changes in the [CHANGELOG.md](./changelog. The node takes one input and one output. Once you drop the node into the flow, you need to use the deviceid and devicekey that you got from the getting started step. -Once you setup the node, you can then use input to send any command to the device as per the tuya standards. +Once you set up the node, you can then use input to send any command to the device as per the tuya standards. # Input Format @@ -71,8 +73,8 @@ Once you setup the node, you can then use input to send any command to the devic > If you need the error thrown by the node use the catch node. -> The status output sends the state of the client (CONNECTING,CONNECTED,ERROR or DISCONNECTED). It will only send message if the state has been changed. . eg: even though multiple errors have been thrown, only once the ERROR state will be send. One possible scenario is -> `ERROR -> CONNECTING -> CONNECTED`. again if ERROR occurs , then the state is send out of the node. +> The status output sends the state of the client (CONNECTING,CONNECTED,ERROR or DISCONNECTED). It will only send message if the state has been changed. . eg: even though multiple errors have been thrown, only once the ERROR state will be sent. One possible scenario is +> `ERROR -> CONNECTING -> CONNECTED`. again if ERROR occurs , then the state is sent out of the node. # Examples @@ -82,15 +84,15 @@ You can refer the [example flow](./examples/latest.json) to get started - **I am getting "Can't find device error"** - The can't find device error can be due to many reasons + The `can't find device` error can be due to many reasons 1. Make sure the device is powered on - 1. Make sure the Device ID / IP / Key are correct - 1. Make sure that you haven't created multiple nodes for the same device. Multiple connections to the same device is not possible. This is a limitation of TuyAPI. + 2. Make sure the Device ID / IP / Key are correct + 3. Make sure that you haven't created multiple nodes for the same device. Multiple connections to the same device is not possible. This is a limitation of TuyAPI. - **What is the difference between FindTimeout and RetryTimeout?** - `FindTimeout` is the time in milliseconds that tuya api will check for a device. Once the timeout has breached, the can't find device error is shown. + `FindTimeout` is the time in milliseconds that tuya api will check for a device. Once the timeout has breached, the `can't find device` error is shown. `RetryTimeout` is the time in milliseconds to wait for the node to retry the connection once the device connection is disconnected due to some unexpected errors. @@ -108,4 +110,4 @@ MIT License - Copyright (c) 2020 Vinod S R [(Back to top)](#table-of-contents) -Your contributions are always welcome! Please have a look at the [contribution guidelines](CONTRIBUTING.md) first. :tada: +Your contributions are always welcome! Please have a look at the [contribution guidelines](CONTRIBUTING.md) first. diff --git a/package-lock.json b/package-lock.json index c5adace..5df70ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,18 @@ { - "name": "node-red-contrib-tuya-smart-device", - "version": "5.1.0", + "name": "@nrchkb/node-red-tuya-smart-device", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "node-red-contrib-tuya-smart-device", - "version": "5.1.0", + "name": "@nrchkb/node-red-tuya-smart-device", + "version": "0.1.0", "license": "MIT", "dependencies": { - "tuyapi": "7.5.1" + "tuyapi": "~7.5.2" + }, + "engines": { + "node": ">=16.0.0" } }, "node_modules/@types/retry": { @@ -98,9 +101,10 @@ } }, "node_modules/tuyapi": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/tuyapi/-/tuyapi-7.5.1.tgz", - "integrity": "sha512-woQEQAkXi2arodnWhn31yqa/u/XfpSe0l1Kr3qw0WH+HCGgtIOeoOrRLg3QS0M5IvrX71oNnQ7/uB8twwvD3Zw==", + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/tuyapi/-/tuyapi-7.5.2.tgz", + "integrity": "sha512-uB+cRE7Pkn0dUzb4qj60kCcLzSJjrPVludBsLAPKdaTohBNHVmKnWZjn6TKxPa1f30JNoid9RvgNch7SKJHbgQ==", + "license": "MIT", "dependencies": { "debug": "^4.3.4", "p-queue": "6.6.2", @@ -170,9 +174,9 @@ "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==" }, "tuyapi": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/tuyapi/-/tuyapi-7.5.1.tgz", - "integrity": "sha512-woQEQAkXi2arodnWhn31yqa/u/XfpSe0l1Kr3qw0WH+HCGgtIOeoOrRLg3QS0M5IvrX71oNnQ7/uB8twwvD3Zw==", + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/tuyapi/-/tuyapi-7.5.2.tgz", + "integrity": "sha512-uB+cRE7Pkn0dUzb4qj60kCcLzSJjrPVludBsLAPKdaTohBNHVmKnWZjn6TKxPa1f30JNoid9RvgNch7SKJHbgQ==", "requires": { "debug": "^4.3.4", "p-queue": "6.6.2", diff --git a/package.json b/package.json index 35f5389..ea355da 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,31 @@ { - "name": "node-red-contrib-tuya-smart-device", - "version": "5.3.0", + "name": "@nrchkb/node-red-tuya-smart-device", + "version": "0.1.0", "description": "A node-red module to interact with the tuya smart devices", - "repository": "https://github.com/vinodsr/node-red-contrib-tuya-smart-device", + "repository": "https://github.com/NRCHKB/node-red-tuya-smart-device", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "author": "Vinod S R", + "author": "Tadeusz Wyrzykowski (https://github.com/Shaquu)", "license": "MIT", - "homepage": "https://github.com/vinodsr/node-red-contrib-tuya-smart-device", + "homepage": "https://github.com/NRCHKB/node-red-tuya-smart-device", "keywords": [ - "node-red" + "node-red", + "tuya", + "nrchkb" ], "node-red": { - "version": ">=2.5.0", + "version": ">=3.0.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.2" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } } diff --git a/src/icons/device.png b/src/icons/device.png deleted file mode 100644 index f2f4128..0000000 Binary files a/src/icons/device.png and /dev/null differ diff --git a/src/icons/tuya.png b/src/icons/tuya.png new file mode 100644 index 0000000..7796446 Binary files /dev/null and b/src/icons/tuya.png differ diff --git a/src/tuya-smart-device-generic.html b/src/tuya-smart-device-generic.html index b0ab5f3..ad8ec58 100644 --- a/src/tuya-smart-device-generic.html +++ b/src/tuya-smart-device-generic.html @@ -1,7 +1,7 @@