subzero79 / node-red-contrib-tuya-local Goto Github PK
View Code? Open in Web Editor NEWNodeRED node to control tuya devices locally. Based on tuyapi module
NodeRED node to control tuya devices locally. Based on tuyapi module
no connect,
also, please add examples
This is weird, I have 4 smart plugs from the same vendor, Awow. All for work without issue via my phone, all 4 work via the TUYA API, i.e. from this node. But one keeps reporting error from socket messages over and over, even though it actually works. Any idea why this is the case?
Howdy!
I used this node some time ago with great results and I'm trying now a new node-red implementation on a raspberry pi. So I installed tuyapi, tuya-cli and the node-red-contrib-tuya-local.
When I ran the tuya-cli, I can get all the device IDs and local keys as expected.
Also, when I configured the node and deployed the flow, I could see that the connection was returning connected status as per the screenshot.
However, the debug is returning an awkward message from the node:
When I listed the npm installation, I found the following details for the node package:
Could this be any dependency compatibility issue? Is it possible to point to the 3.2.3 tuya library instead of the 5.1.2? How could this be achieved?
Dude you module is not even in NPM?
$ npm install node-red-contrib-tuya-local
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/node-red-contrib-tuya-local - Not found
npm ERR! 404
npm ERR! 404 'node-red-contrib-tuya-local@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2020-07-23T19_16_59_027Z-debug.log
WHAT THE HELL? Come on!
Hi,
I just added a thermostat using tuya-local, and it almost works. The only issue I can't seem to fix is, that the state of the entity always is "unknown", while the attributes all appear correctly, and I can also change target-temperature via homeassistant.
However, the unknown-state seems to mess with other things (e.g. influx-db/grafana).
I set the thermostat up as a climate-domain. I also tried to configure it, again, but I can't find a way to use any DPS for the state.
Hi,
when using protocol version 3.1 I get
payload: "parse data error"
and when using 3.3
payload: "json obj data unvalid"
Any idea what might be causing this?
Hi, thanks for this component it works flawlessly for fetching my plugs instant readings .
This is probably not a real issue (api limitation ?) but I noticed it's getting all the values in the app except total KW.h (accumulated energy consumption) .
18 is current (it lacks the .), 19 is Power(W) (also lacks a . before last digit) and 20 is Voltage (also lacks a . before last digit) . All these seem to get fetched correctly (except for the lack of the decimal separator) except for the last variable in the tuya app (total KW.h) .
Any chance for this to get updated or is it an API limitation ?
Thanks
I tried upgrading to Node Red 1.0 and this plugin breaks as a result (works fine on prior version). It goes into a connect/disconnect loop that never ends.
Not sure how to debug beyond this or if perhaps a tuyapi update would solve it but wanted to report it.
I noticed that this package is gone from https://www.npmjs.com/ and therefore you can no longer install it in node-red. Is the project abandoned?
Following error happens often and at times seems to be crashing Node and thus Node Red?
Jul 20 13:19:47 eccentric Node-RED[3719]: 20 Jul 13:19:47 - [info] [mqtt-broker:Broker] Connected to broker: mqtt://broker.dachshund-digital.org:1883
Jul 20 13:19:47 eccentric Node-RED[3719]: 20 Jul 13:19:47 - [info] [wifiscan:Scan] wifiscan - Input received
Jul 20 13:19:47 eccentric Node-RED[3719]: 20 Jul 13:19:47 - [red] Uncaught Exception:
Jul 20 13:19:47 eccentric Node-RED[3719]: 20 Jul 13:19:47 - [error] Error: No connection has been made to the device.
Jul 20 13:19:47 eccentric Node-RED[3719]: at TuyaDevice._send (/home/pi/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:235:13)
Jul 20 13:19:47 eccentric Node-RED[3719]: at /home/pi/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:117:14
Jul 20 13:19:47 eccentric Node-RED[3719]: at new Promise ()
Jul 20 13:19:47 eccentric Node-RED[3719]: at TuyaDevice.get (/home/pi/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:114:12)
Jul 20 13:19:47 eccentric Node-RED[3719]: at setDevice (/home/pi/.node-red/node_modules/node-red-contrib-tuya-local/tuya-local.js:42:12)
Jul 20 13:19:47 eccentric Node-RED[3719]: at TuyaNode._inputCallback (/home/pi/.node-red/node_modules/node-red-contrib-tuya-local/tuya-local.js:122:4)
Jul 20 13:19:47 eccentric Node-RED[3719]: at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
Jul 20 13:19:47 eccentric Node-RED[3719]: at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
Jul 20 13:19:47 eccentric Node-RED[3719]: at TuyaNode.Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
Jul 20 13:19:47 eccentric Node-RED[3719]: at TuyaNode.Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:186:25)
Jul 20 13:19:47 eccentric systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
I I copied your example flows here - https://github.com/subzero79/node-red-contrib-tuya-local - - and put in my MQTT info - and the IP of the ZemiSmart Smart plug I have on test right now... but as IDs for keys - I can only assume this has nothing to do with my official devloper ID and key for Tuya. Am I right in saying the device ID in Smart Life for my plug is irrelevant - in which case I don;t kno how to get the ID and key you refer to for the device. Two of us here are trying this node - neither uses Home Assistant - I use Node-Red (and Dashboard of course)... any pointers? I'd REALLY like to get (as an example) this device off the cloud...
Just a clarification? So these NR nodes don't leverage the node module tuya-local or thery do?
I am referring to the following...
https://github.com/rospogrigio/localtuya
Hi, I know you are not using this much anymore but i keep getting this error from the last function. From what I can tell it is saying that 'dps' is undefined but i'm not sure why.
Thanks
DC
At times devices go into a connecting state? For no apparent reason? I have good, strong WiFi, ip addresses are not changing under the hood (say from DHCP range changes), the network is stable. Nor do I see the devices disconnecting and connecting from the tuya app on my phone. So I suspect your implementation is doing something? Or the TUYA remote connect is doing something? How would you suggest I track down why this is happening, would like to get the NR connected devices consistent and stable similar to how they are in my phone configuration.
For example... I get this error on just some of my smart plugs...
"Error: Error from socket device: Smart YX-WS01"
Model is "Smart Plug YX-WS01"
TUYA product id is "cET7nrXx83igNwGF"
i get lots of
socket1 = teckin sp22 assumed with a realtek wifi
24 Feb 21:45:30 - [warn] [tuya-local:c55595b2.d344b8] Error: Error from socket device: socket1
24 Feb 21:45:30 - [info] [tuya-local:c55595b2.d344b8] error: Trying to clear a possible timeout timer for device socket1
Does this component connect to downlight devices? I'm having the following issue after deploying the node-red flow:
Error: Error from socket device: [device-name]
Here is the log extracted from node-red output:
Jun 17 21:58:29 raspberrypi Node-RED[4885]: 17 Jun 21:58:29 - [info] [tuya-local:493dabc7.d699b4] set timeout for re-connect
Jun 17 21:58:29 raspberrypi Node-RED[4885]: 17 Jun 21:58:29 - [warn] [tuya-local:493dabc7.d699b4] Error: Error from socket device: [device-name]
Jun 17 21:58:29 raspberrypi Node-RED[4885]: 17 Jun 21:58:29 - [info] [tuya-local:493dabc7.d699b4] error: Trying to clear a possible timeout timer for device [device-name]
I managed to configure this node in node-red for my PowerMonitoring Plug
It works fine.
I am able to Turn ON/OFF view the Voltage/ Current/Watts value.
But When I disconnect the internet access for the device (Plug). I am able to control (ON/OFF) the device locally thru lan, but not see the Voltage/ Current/Watts values.
These power values are always Nan when the Internet to the device is disconnected.
I tried to make the Nodred config simple as below:
HA Config as follows:
switch :
- platform: mqtt
name: "3D Printer Tuya Local"
state_topic: "hass/tlsw01"
command_topic: "hass/tlsw01/set"
payload_on: "true"
payload_off: "false"
state_on: "true"
state_off: "false"
optimistic: false
qos: 0
retain: true
sensor:
- platform: mqtt
name: "3D Printer Watts"
state_topic: "hass/tlsw01/watts"
unit_of_measurement: W
value_template: "{{ value | round(1) }}"
- platform: mqtt
name: "3D Printer Current"
state_topic: "hass/tlsw01/amps"
unit_of_measurement: A
value_template: "{{ value | round(1) }}"
- platform: mqtt
name: "3D Printer Voltage"
state_topic: "hass/tlsw01/volts"
unit_of_measurement: V
value_template: "{{ value | round(1) }}"
Please help
Hi,
this is more of a question than issue, but could you all, please, try to cut off the plug off the net and see if you can still control the plug and get volt, amps, watt readouts?
(all my plugs got new firmware)
TIA
I appreciate your doing this and it's working, but I'll occasionally get a number of errors like:
"TypeError: Packet too short. Length: 5. device: BR"
or
"TypeError: Prefix does not match: 580b29d10f998a05b9a93df453e1f3a33fd67e592cc978ca105d8f3958c20000aa55 device: LR"
or
"RangeError: Index out of range device: LR"
I'm not sure what those errors mean and they don't seem to impact whether or not the device works but I thought they were worth reporting.
(node:63079) UnhandledPromiseRejectionWarning: ReferenceError: timeout is not defined
at TuyaDevice. (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/tuya-local.js:74:17)
at TuyaDevice.emit (events.js:200:13)
at Socket. (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:367:16)
at Socket.emit (events.js:205:15)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1040:10)
(node:63079) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:63079) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hello,
I installed this node and I was able to connect to my device.
It is a window blind roller switch:
https://www.aliexpress.com/item/4000051743871.html?spm=a2g0s.9042311.0.0.2742b90ac0c8fL
I know probably this isn't covered by tuyapi but as I get a connection and replay back from the unit might be something I'm doing wrong.
Issue is that payload info I get is unreadble, see piucture below:
Ony hint possible?
Thanks
First time that I can switch on my tuya device thanks to your node! But it only lasts one second...
It works with {"set": true, "dps" : 1}
or just with a boolean true
.
Dps is then 1:true
and one second after, a second message is automatically sent with dps 1:false
No matter if I select Inject once after xx seconds, then none
or not at the bottom.
EDIT: I am sorry. I did not remember having played with the Smart Life app a year ago. I had a scenario for what I am describing Just wandering why this scenario is now playing? Without it, the commands in the node are just fine.
I installed this on my node-red (running on Windows 10, latest build, I don't think it matters).
I have a smart plug that reports its power consumption. That's the data I want to retrieve.
The problem: I can send "Request" and data is returned from the node, but not the correct data. Data is only updated correctly if I have the Smart Life app open on my phone and I go to "Electric" tab to see the data from the device on the app. I'll then see the same data on the app and coming out of this node. If I terminate the app on the phone, data stops being correct. "Request" just retrieves the last thing it saw before the app was terminated.
Anything I should try doing? Thank you.
Edit: Seems to be a problem related directly to Tuyapi and not to this node.
Sending a connect message while the device is connected causes the device to be stuck on "Connecting" status
Hi,
I'm trying to connect the MiLight WL-Box1 Gateway with local Tuya. Unfortunately, it doesn't work as expected. The connection establishment is not possible.
Debug output:
Error: Error from socket device: light bath room
ip: "192.168.40.105"
id: "####"
available: false
Tuya IOT API explorer device details:
"result": {
"active_time": 1660378330,
"biz_type": 0,
"category": "dj",
"create_time": 1660324661,
"icon": "smart/icon/ay1544595242978Akat0/a3c2e985445c0cbbd890208b927fb4aa.png",
"id": "####",
"ip": "####",
"lat": "0.0000",
"local_key": "####",
"lon": "0.0000",
"model": "",
"name": "MiLight Gateway",
"online": true,
"owner_id": "####",
"product_id": "####",
"product_name": "2.4GHz Gateway",
"status": [
{
"code": "switch_led",
"value": true
},
{
"code": "work_mode",
"value": "white"
},
{
"code": "bright_value_v2",
"value": 1000
},
{
"code": "temp_value_v2",
"value": 0
},
{
"code": "colour_data_v2",
"value": "{"h":112,"s":0,"v":1000}"
},
{
"code": "countdown_1",
"value": 0
},
{
"code": "control_data",
"value": ""
}
],
"sub": false,
"time_zone": "+02:00",
"uid": "eu1655664454272WMJ04",
"update_time": 1660378409,
"uuid": "acd2ffa82c5cbeb0"
},
"success": true,
"t": 1660378685232,
"tid": "####"
}
Any suggestions?
The below is taken from the API guide but doesn't seem to do anything. Not even an error.
{
"multiple": true,
"data": "{'20': true,'2': 'red' }"
}
Hi,
when I try to add a Tellur Power Strip I receive this error:
"Error: Error from socket device: Tellur"
I checked IP, Device ID e Key and already is ok.
Where I wrong?
How to command a subdevice?
I've a smart IR device ( with ID and Key) with one subdevice (ID and CID).
I'm trying to use node-red-contrib-tuya-local to turn on an RGBIC striplight and set some of it's values.
I have an inject with a payload message of on. The output of this inject goes to the input of a function, and the code for this function reads:-
if (msg.payload === "on")
msg.payload =
{
"set": true,
"dps": 20
}
return msg;
The output of this function then goes to the input of the tuya-local device.
The above does work to turn on the striplight.
How do I set more DPS values at the same time in the same payload, e.g. 20=true, 25="03e832020", 104=10 ?
I tried the following, but even formatting like this, the light doesn't even turn on:-
if (msg.payload === "on")
msg.payload =
{
dps:
{
"20": true,
"104": 11
}
};
return msg;
Hi,
I would really like to know how on Earth I can Request the Current Values (Voltage, Current, etc.) from my SmartPlug. In node Red the Plug is configured and working but I'm only getting real time Values if I have the App open. With {"set":true, "dps": 1} and {"set":false, "dps": 1} I can switch the Plug On an Off.
So my question is what the JSON Request for Requesting all or just a particular set of Data looks like.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.