9 Commits

Author SHA1 Message Date
dependabot[bot]
735ca1ffad Bump async from 2.6.3 to 2.6.4
Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-29 15:10:59 +00:00
tsightler
36f3854ca9 Update README.md 2021-06-01 13:12:35 -04:00
tsightler
b7fc73de3c Update bug_report.md 2021-02-09 12:13:08 -05:00
tsightler
2b92e2b27c Update feature_request.md 2021-02-09 12:12:36 -05:00
tsightler
35dde4bd11 Update feature_request.md 2021-02-09 12:11:57 -05:00
tsightler
d833151beb Update feature_request.md 2021-02-09 12:10:06 -05:00
tsightler
c179282393 Update README.md 2021-02-09 12:07:19 -05:00
tsightler
8b532d9df1 v3.0.4
* Fix reconnect failure for some error cases
* Bump tuyapi version to latest
2021-01-27 13:46:55 -05:00
tsightler
02d5124b62 v3.03
* Fix reconnect failure in some disconnect cases
* Remove duplicate republish function
2021-01-12 20:19:42 -05:00
6 changed files with 45 additions and 59 deletions

View File

@@ -6,35 +6,35 @@ labels: ''
assignees: '' assignees: ''
--- ---
**!!! Please Read This First !!!**\ **!!! Please Read This First !!!**
If you are having difficulty controlling a specific device, please verify that the device works with tuya-cli prior to opening an issue here. If you are unable to control the device via tuya-cli it will not be possible to control it with tuya-mqtt. If the device is working with tuya-cli, please post your working commands and the equivalent commands for tuya-mqtt. If you are having difficulty controlling a specific device, please verify that the device works with tuya-cli prior to opening an issue here. If you are unable to control the device via tuya-cli it will not be possible to control it with tuya-mqtt. If the device is working with tuya-cli, please post your working commands and the equivalent commands for tuya-mqtt.
**Describe the bug**\ **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce**\ **To Reproduce**
Steps to reproduce the behavior: Steps to reproduce the behavior:
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. Scroll down to '....' 3. Scroll down to '....'
4. See error 4. See error
**Expected behavior**\ **Expected behavior**
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
**Screenshots**\ **Screenshots**
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**\ **Desktop (please complete the following information):**
- OS: [e.g. iOS] - OS: [e.g. iOS]
- Browser [e.g. chrome, safari] - Browser [e.g. chrome, safari]
- Version [e.g. 22] - Version [e.g. 22]
**Smartphone (please complete the following information):**\ **Smartphone (please complete the following information):**
- Device: [e.g. iPhone6] - Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1] - OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari] - Browser [e.g. stock browser, safari]
- Version [e.g. 22] - Version [e.g. 22]
**Additional context**\ **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

View File

@@ -7,17 +7,5 @@ assignees: ''
--- ---
**!!! Please Read This First !!!**\ **!!! Please Read This First !!!**
If this feature request is to support a device that currently doesn't work, please verify that the device works with tuya-cli first. If the device cannot be used with tuya-cli, then it won't be possible to add support to tuya-mqtt. If you can query and control your device with tuya-cli, please post the commands and the functions they perform as part of the feature request. Feature requiest for this project are not being accepted at this time as this project is in maintainance mode only.
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -1,5 +1,12 @@
# tuya-mqtt # tuya-mqtt
This project provides a method for locally controlling IOT devices manufactured by Tuya Inc., and sold under many different brands, via MQTT.
# !!!! Important Note !!!!
This project is currently in maintainance mode. No further enhancements to this project are planned and will not be planned for the future unless someone out there is interested in becoming the new maintainer. Please do not open issues to request new features, new device support, etc, as they will likely be closed with no comment. I will try to support existing functionality, but even this will likely be on a very limited basis. If you are interested in maintaining this project, please post [here](https://github.com/rospogrigio/localtuya/issues/194).
I have decided to step away from this project as I've made the personal decision to rid myself of any Tuya Wifi based devices (I'm down to only 4 at this point, and they are all easy to replace or at least flash with Tasmota). This decision was made due to the fact that Tuya continues to make it more and more difficult to control their devices locally. While I don't blame them for this, these devices were only interesting to me because of this local control and thus I can no longer meet my personal goals with Tuya devices (at least the Wifi ones) so I will no longer be purchasing/using them going forward.
# About
This project is a bridge that allows locally controlling IOT devices manufactured by Tuya Inc., and sold under many different brands, via simple MQTT topics. It effectively translate the Tuya protocol to easy to use topics.
Using this script requires obtaining the device ID and local keys for each of your devices after they are configured via the Tuya/Smart Life or other Tuya compatible app (there are many). With this information it is possible to communicate locally with Tuya devices using Tuya protocol version 3.1 and 3.3 without using the Tuya Cloud service, however, getting the keys requires signing up for a Tuya IOT developer account or using one of several other alternative methods (such as dumping the memory of a Tuya based app running on Android). Using this script requires obtaining the device ID and local keys for each of your devices after they are configured via the Tuya/Smart Life or other Tuya compatible app (there are many). With this information it is possible to communicate locally with Tuya devices using Tuya protocol version 3.1 and 3.3 without using the Tuya Cloud service, however, getting the keys requires signing up for a Tuya IOT developer account or using one of several other alternative methods (such as dumping the memory of a Tuya based app running on Android).

View File

@@ -597,24 +597,15 @@ class TuyaDevice {
// Retry connection every 10 seconds if unable to connect // Retry connection every 10 seconds if unable to connect
async reconnect() { async reconnect() {
if (!this.device.isConnected() && !this.reconnecting) { if (!this.reconnecting) {
this.reconnecting = true this.reconnecting = true
debugError('Error connecting to device id '+this.options.id+'...retry in 10 seconds.') debugError('Error connecting to device id '+this.options.id+'...retry in 10 seconds.')
await utils.sleep(10) await utils.sleep(10)
if (this.connected) { return }
this.connectDevice() this.connectDevice()
this.reconnecting = false this.reconnecting = false
} }
} }
// Republish device discovery/state data (used for Home Assistant state topic)
async republish() {
const status = (this.device.isConnected()) ? 'online' : 'offline'
this.publishMqtt(this.baseTopic+'status', status)
await utils.sleep(1)
this.init()
}
// Republish device discovery/state data (used for Home Assistant state topic) // Republish device discovery/state data (used for Home Assistant state topic)
async republish() { async republish() {
const status = (this.device.isConnected()) ? 'online' : 'offline' const status = (this.device.isConnected()) ? 'online' : 'offline'
@@ -633,7 +624,7 @@ class TuyaDevice {
await utils.sleep(1) await utils.sleep(1)
this.connectDevice() this.connectDevice()
} else if (this.heartbeatsMissed > 0) { } else if (this.heartbeatsMissed > 0) {
const errMessage = this.heartbeatsMissed > 1 ? " consecutive heartbeats" : " heartbeat" const errMessage = this.heartbeatsMissed > 1 ? " heartbeats" : " heartbeat"
debugError('Device id '+this.options.id+' has missed '+this.heartbeatsMissed+errMessage) debugError('Device id '+this.options.id+' has missed '+this.heartbeatsMissed+errMessage)
} }
this.heartbeatsMissed++ this.heartbeatsMissed++
@@ -648,4 +639,4 @@ class TuyaDevice {
} }
} }
module.exports = TuyaDevice module.exports = TuyaDevice

42
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "tuya-mqtt", "name": "tuya-mqtt",
"version": "3.0.2", "version": "3.0.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -18,13 +18,13 @@
} }
}, },
"@tuyapi/cli": { "@tuyapi/cli": {
"version": "1.13.6", "version": "1.15.0",
"resolved": "https://registry.npmjs.org/@tuyapi/cli/-/cli-1.13.6.tgz", "resolved": "https://registry.npmjs.org/@tuyapi/cli/-/cli-1.15.0.tgz",
"integrity": "sha512-xvQfhFkhc0issQClzHSCrRuFyq6exBloKW0ZCIfWqRaZ9bPuDLjNv3UDFD7ywFSsBWiWNX28kGSAIM5QX2glNQ==", "integrity": "sha512-V85STIKtkDM+t8G08PUdL4klnnGmJU1qcPQF6pYRUn//iSlm1AD0CkNZ9Qll+nK2rpPB/2X5wJCwe8dCp1MEnQ==",
"requires": { "requires": {
"@tuyapi/link": "^0.3.3", "@tuyapi/link": "^0.3.3",
"@tuyapi/openapi": "^1.2.0", "@tuyapi/openapi": "^1.2.0",
"@tuyapi/stub": "^0.1.4", "@tuyapi/stub": "^0.2.0",
"cli-table3": "^0.6.0", "cli-table3": "^0.6.0",
"colors": "^1.4.0", "colors": "^1.4.0",
"commander": "^5.1.0", "commander": "^5.1.0",
@@ -72,9 +72,9 @@
} }
}, },
"@tuyapi/stub": { "@tuyapi/stub": {
"version": "0.1.4", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/@tuyapi/stub/-/stub-0.1.4.tgz", "resolved": "https://registry.npmjs.org/@tuyapi/stub/-/stub-0.2.0.tgz",
"integrity": "sha512-uF2u1Z78Qif3hK92RYxMG4AbjedNRZYmM1jIvegf4KUfDVV/BhHFooz2y3Q28jPl5Q+H39QY/WBH2bMiXMAg/g==", "integrity": "sha512-QVwHf1KexAJw8mgmkyxXH4t5sToK0Ai3O8PFKNqgbgx6LOWciqOOcV99xw+6UwGa2iyvW/PnFoMqVRuYy1EgQQ==",
"requires": { "requires": {
"debug": "^4.1.1", "debug": "^4.1.1",
"tuyapi": "^5.0.0" "tuyapi": "^5.0.0"
@@ -228,9 +228,9 @@
} }
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }
@@ -346,12 +346,12 @@
} }
}, },
"call-bind": { "call-bind": {
"version": "1.0.0", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.0.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-AEXsYIyyDY3MCzbwdhzG3Jx1R0J2wetQyUynn6dYHAO+bg8l1k7jwZtRv4ryryFs7EP+NDlikJlVe59jr0cM2w==", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"requires": { "requires": {
"function-bind": "^1.1.1", "function-bind": "^1.1.1",
"get-intrinsic": "^1.0.0" "get-intrinsic": "^1.0.2"
} }
}, },
"callback-stream": { "callback-stream": {
@@ -1094,9 +1094,9 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
}, },
"ini": { "ini": {
"version": "1.3.8", "version": "1.3.7",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ=="
}, },
"inquirer": { "inquirer": {
"version": "7.3.3", "version": "7.3.3",
@@ -2302,9 +2302,9 @@
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}, },
"tuyapi": { "tuyapi": {
"version": "6.1.2", "version": "6.1.4",
"resolved": "https://registry.npmjs.org/tuyapi/-/tuyapi-6.1.2.tgz", "resolved": "https://registry.npmjs.org/tuyapi/-/tuyapi-6.1.4.tgz",
"integrity": "sha512-C8ewskhjWJHjUlgCRItEilkrZ3z2uH4rkSJMRTG73EQgMutr/9R3EfoyxAMUQIQxvsmODjMsXpKX07+tqIQ7tg==", "integrity": "sha512-aE1ctVaF1fXUbwMatQvr6GuE1kmVD0QdIIm/9AUJW+mOCOg5SSt2XyTmKc8qirJ6iQ3lZcTnHp9xK6gRAzrOLA==",
"requires": { "requires": {
"debug": "4.1.1", "debug": "4.1.1",
"p-queue": "6.6.1", "p-queue": "6.6.1",

View File

@@ -1,6 +1,6 @@
{ {
"name": "tuya-mqtt", "name": "tuya-mqtt",
"version": "3.0.2", "version": "3.0.4",
"description": "Control Tuya devices locally via MQTT", "description": "Control Tuya devices locally via MQTT",
"homepage": "https://github.com/TheAgentK/tuya-mqtt#readme", "homepage": "https://github.com/TheAgentK/tuya-mqtt#readme",
"main": "tuya-mqtt.js", "main": "tuya-mqtt.js",
@@ -13,13 +13,13 @@
}, },
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@tuyapi/cli": "^1.13.6", "@tuyapi/cli": "^1.15.0",
"color-convert": "^2.0.1", "color-convert": "^2.0.1",
"debug": "^4.3.1", "debug": "^4.3.1",
"json5": "^2.1.3", "json5": "^2.1.3",
"mqtt": "^4.2.6", "mqtt": "^4.2.6",
"supports-color": "^8.1.0", "supports-color": "^8.1.0",
"tuyapi": "^6.1.2", "tuyapi": "^6.1.4",
"mathjs": "8.1.1" "mathjs": "8.1.1"
}, },
"repository": { "repository": {