Closed palsbo closed 3 years ago
The error noted is from TuyAPI (the underlying API that this script uses) and indicates that there's no active connection to the device. Debug output would be helpful, and I should probably trap the error scenario, but since you mention that you are already running tuya-mqtt on a different device, my first guess might be that you didn't stop it there before starting it on the new device. Most Tuya devices only support a single concurrent local connection and will reject all other attempts to connect to the device locallt, so, if another instance of the script (or the Tuya app for example) is already connected to the device, then running a second instance will not be able to connect.
This should be clearly visible when running with debug output as reconnect attempts will happen every 30 seconds or so.
Thank you very much for a Quick responsse. I tried to switch off all other Equipment using the connecton to tuya, but still no Lock. Running en debug mode, it looks like the port is not available, but running tuya-cli wizard shows the list of devices.:
ash-4.3# tuya-cli wizard
DEBUG=tuya-mqtt:* node tuya-mqtt.js tuya-mqtt:info Connection established to MQTT server +0ms tuya-mqtt:tuyapi Search for device id 73000250c44f339338aa +0ms tuya-mqtt:tuyapi Search for device id bf5959607ad139b09cqivc +17ms tuya-mqtt:tuyapi Search for device id 80378704500291704621 +1ms tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +2ms tuya-mqtt:tuyapi Search for device id 38341275c82b9648acb0 +1ms tuya-mqtt:error bind EADDRINUSE 0.0.0.0:6667 +0ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms tuya-mqtt:error bind EADDRINUSE 0.0.0.0:6667 +1ms tuya-mqtt:error Will attempt to find device again in 60 seconds +1ms tuya-mqtt:error bind EADDRINUSE 0.0.0.0:6667 +0ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms tuya-mqtt:error bind EADDRINUSE 0.0.0.0:6667 +1ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms tuya-mqtt:error bind EADDRINUSE 0.0.0.0:6667 +1ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms
I am a bit confused😊 RegardsErik
The "tuyacli wizard" command just pulls the device list via the Tuya Cloud service REST API and has nothing to do with connecting to the local device, it's just getting the data needed to connect to those devices.
Based on the message it appears that UDP port 6667 is already used by something on the Synology and thus can't be bound by TuyAPI. You will either need to stop whatever is using that port, or you could try manually specifying the IP, key and protocol version in the config file, which should allow the device to be discovered without requiring UDP.
It looks like this IRC service is part of Synology Chat Server feature. I'm not sure if there is a way to uninstall or disable it, but at least it's now clear that this is the problem. I'm going to close this now since this issue is not related to tuya-mqtt but feel free to come back and post a solution if you determine how to fix it.
It's not possible for tuya-mqtt to use a port other than UDP 6667 for discovery because that's the port that the Tuya devices use to broadcast their discovery packets for protocol 3.3 devices (protocol 3.1 device use UDP port 6666). Attempting to listen on another port would just mean those discovery packets would never be received.
However, as I noted above, you can manually specify the IP, key, and protocol version for the device in the config file and then discovery should not matter. When you only specify the key of the device, tuya-mqtt (really TuyAPI) has to listen on port 6667 for the UDP packet from the device to discover the IP and protocol version, but, if you manually specify this data, then UDP based discovery is not required, it will just try to connect directly to those devices using the information provided.
I have no idea why OpenHAB would be using port 6667 though as that's not typical, IMO.
That's right, OpenHAB typically uses Port 8080 / 8443 TCP! Can you verify that OH is really using port 6667? What URL you use in the browser to access the OH GUI?
I use 8080. It must be something internaly in OH. Erik
tir. 5. jan. 2021 kl. 17.52 skrev Flip notifications@github.com:
That's right, OpenHAB typically uses Port 8080 / 8443 TCP! Can you verify that OH is really using port 6667? What URL you use in the browser to access the OH GUI?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TheAgentK/tuya-mqtt/issues/62#issuecomment-754758428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYJU4YSAIOVDPAAVEGZXJTSYM7ULANCNFSM4VUQNM3A .
--
http://www.e-julemaerket.dk/?b43be142-3678-476b-ba11-dded21173369
I found one other person that reported the same issue with the old tuya-mqtt script conflicting with OpenHAB on UDP port 6667 in the OpenHAB forum, but I never saw a resolution as to why. I don't know enough about OpenHAB to know what would be listening on that port but the summary version is that tuya-mqtt requires the ability to use this port for discovery as I can't change what port Tuya devices are hard coded to send the UDP discovery packets to so, if something else is using it, the only option is to manually specify the ID, IP address and protocol version in the config and not use discovery.
IMHO you need to specify IP and version manually - for example:
{
name: 'Plug',
id: '363062476001********',
key: '0354913f********',
ip: '192.168.1.200',
version: '3.1',
type: 'SimpleSwitch'
},
Also the apostrophe seems to be in a strange character (after ip: )
Correct, as I noted above and is clearly stated in the documentation, if you don't use discovery there is no way for TuyAPI to automatically detect the protocol version so you must supply id, key, ip, and version, the latter being the protocol version of your device (typically 3.3 these days).
I'm considering making 3.3 the default guessed protocol version in the future since those seem to be by far the most common devices, but it's a breaking change for any existing user that does happen to have 3.1 protocol devices, so I've been hesitant to do it.
Erik, could you please change your mail-format to plain text (instead of html) or send your update directly within Github. It's very hard to read your updates ( see here: https://github.com/TheAgentK/tuya-mqtt/issues/62 )
Which version have you set for device id 8037870450029170f251 - can you try 3.1 and 3.3 and see if the problem still exists?
Sorry - I will change the format. I have tried both 3.1 and 3.3
Hope this one is more readable:
`[16:06:39] root@openHABianDevice:/opt/tuya-mqtt# ./test.sh
tuya-mqtt:info Connection established to MQTT server +0ms
tuya-mqtt:tuyapi Search for device id 487668362cf432362176 +0ms
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +1ms
tuya-mqtt:tuyapi Search for device id 80378704500291704621 +1ms
tuya-mqtt:tuyapi Search for device id 73000250c44f339338aa +1ms
tuya-mqtt:tuyapi Found device id 487668362cf432362176 +2ms
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +2ms
tuya-mqtt:tuyapi Found device id 80378704500291704621 +0ms
tuya-mqtt:tuyapi Found device id 73000250c44f339338aa +1ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +0ms
tuya-mqtt:tuyapi Disconnected from device Switch1 (192.168.1.228, 487668362cf432362176, c503e1067353de66) +28ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +4ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +1ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +1ms
tuya-mqtt:tuyapi Disconnected from device Spisebord (192.168.1.231, 80378704500291704621, 576ed7ce67b2f203) +6ms
tuya-mqtt:tuyapi Disconnected from device Paere (192.168.1.235, 73000250c44f339338aa, c5b322f007e1823c) +1ms
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +0ms
tuya-mqtt:error Error connecting to device id 487668362cf432362176...retry in 10 seconds. +996ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +3ms
tuya-mqtt:error Error connecting to device id 73000250c44f339338aa...retry in 10 seconds. +1ms
tuya-mqtt:error Error connecting to device id 80378704500291704621...retry in 10 seconds. +2ms
tuya-mqtt:tuyapi Search for device id 487668362cf432362176 +11s
tuya-mqtt:tuyapi Found device id 487668362cf432362176 +1ms
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +3ms
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:tuyapi Search for device id 73000250c44f339338aa +1ms
tuya-mqtt:tuyapi Found device id 73000250c44f339338aa +1ms
tuya-mqtt:tuyapi Search for device id 80378704500291704621 +1ms
tuya-mqtt:tuyapi Found device id 80378704500291704621 +1ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +19ms
tuya-mqtt:tuyapi Received JSON data from device 487668362cf432362176 -> {"1":false,"2":0} +33ms
tuya-mqtt:tuyapi Received JSON data from device 80378704500291704621 -> {"1":true,"2":106} +3ms
tuya-mqtt:tuyapi Received JSON data from device 73000250c44f339338aa -> {"1":false,"3":92} +299ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Connected to device Switch1 (192.168.1.228, 487668362cf432362176, c503e1067353de66) +666ms
tuya-mqtt:discovery Home Assistant config topic: homeassistant/switch/487668362cf432362176/config +0ms
tuya-mqtt:discovery {
tuya-mqtt:discovery name: 'Switch1',
tuya-mqtt:discovery state_topic: 'tuya/switch1/state',
tuya-mqtt:discovery command_topic: 'tuya/switch1/command',
tuya-mqtt:discovery availability_topic: 'tuya/switch1/status',
tuya-mqtt:discovery payload_available: 'online',
tuya-mqtt:discovery payload_not_available: 'offline',
tuya-mqtt:discovery unique_id: '487668362cf432362176',
tuya-mqtt:discovery device: {
tuya-mqtt:discovery ids: [ '487668362cf432362176' ],
tuya-mqtt:discovery name: 'Switch1',
tuya-mqtt:discovery mf: 'Tuya',
tuya-mqtt:discovery mdl: 'Switch/Socket'
tuya-mqtt:discovery }
tuya-mqtt:discovery } +0ms
tuya-mqtt:tuyapi Connected to device Spisebord (192.168.1.231, 80378704500291704621, 576ed7ce67b2f203) +17ms
tuya-mqtt:discovery Home Assistant config topic: homeassistant/light/80378704500291704621/config +0ms
tuya-mqtt:discovery {
tuya-mqtt:discovery name: 'Spisebord',
tuya-mqtt:discovery state_topic: 'tuya/spisebord/state',
tuya-mqtt:discovery command_topic: 'tuya/spisebord/command',
tuya-mqtt:discovery brightness_state_topic: 'tuya/spisebord/brightness_state',
tuya-mqtt:discovery brightness_command_topic: 'tuya/spisebord/brightness_command',
tuya-mqtt:discovery brightness_scale: 100,
tuya-mqtt:discovery availability_topic: 'tuya/spisebord/status',
tuya-mqtt:discovery payload_available: 'online',
tuya-mqtt:discovery payload_not_available: 'offline',
tuya-mqtt:discovery unique_id: '80378704500291704621',
tuya-mqtt:discovery device: {
tuya-mqtt:discovery ids: [ '80378704500291704621' ],
tuya-mqtt:discovery name: 'Spisebord',
tuya-mqtt:discovery mf: 'Tuya',
tuya-mqtt:discovery mdl: 'Dimmer Switch'
tuya-mqtt:discovery }
tuya-mqtt:discovery } +1ms
tuya-mqtt:tuyapi Connected to device Paere (192.168.1.235, 73000250c44f339338aa, c5b322f007e1823c) +7ms
tuya-mqtt:discovery Home Assistant config topic: homeassistant/light/73000250c44f339338aa/config +5ms
tuya-mqtt:discovery {
tuya-mqtt:discovery name: 'Paere',
tuya-mqtt:discovery state_topic: 'tuya/paere/state',
tuya-mqtt:discovery command_topic: 'tuya/paere/command',
tuya-mqtt:discovery brightness_state_topic: 'tuya/paere/brightness_state',
tuya-mqtt:discovery brightness_command_topic: 'tuya/paere/brightness_command',
tuya-mqtt:discovery brightness_scale: 100,
tuya-mqtt:discovery availability_topic: 'tuya/paere/status',
tuya-mqtt:discovery payload_available: 'online',
tuya-mqtt:discovery payload_not_available: 'offline',
tuya-mqtt:discovery unique_id: '73000250c44f339338aa',
tuya-mqtt:discovery device: {
tuya-mqtt:discovery ids: [ '73000250c44f339338aa' ],
tuya-mqtt:discovery name: 'Paere',
tuya-mqtt:discovery mf: 'Tuya',
tuya-mqtt:discovery mdl: 'Dimmer Switch'
tuya-mqtt:discovery }
tuya-mqtt:discovery } +0ms
tuya-mqtt:tuyapi Received JSON data from device 487668362cf432362176 -> {"1":false,"2":0} +1s
tuya-mqtt:state tuya/switch1/state OFF +0ms
tuya-mqtt:state MQTT DPS JSON: tuya/switch1/dps/state -> {"1":false,"2":0} +2ms
tuya-mqtt:state MQTT DPS1: tuya/switch1/dps/1/state -> false +1ms
tuya-mqtt:state MQTT DPS2: tuya/switch1/dps/2/state -> 0 +1ms
tuya-mqtt:tuyapi Received JSON data from device 80378704500291704621 -> {"1":true,"2":106} +7ms
tuya-mqtt:tuyapi Received JSON data from device 73000250c44f339338aa -> {"1":false,"3":92} +3ms
tuya-mqtt:tuyapi Received JSON data from device 80378704500291704621 -> {"1":true,"2":106} +23ms
tuya-mqtt:state tuya/spisebord/state ON +31ms
tuya-mqtt:state tuya/spisebord/brightness_state 35 +20ms
tuya-mqtt:state MQTT DPS JSON: tuya/spisebord/dps/state -> {"1":true,"2":106} +1ms
tuya-mqtt:state MQTT DPS1: tuya/spisebord/dps/1/state -> true +0ms
tuya-mqtt:state MQTT DPS2: tuya/spisebord/dps/2/state -> 106 +1ms
tuya-mqtt:tuyapi Received JSON data from device 73000250c44f339338aa -> {"1":false,"3":92} +27ms
tuya-mqtt:error Could not get value for device DPS key 2 +1s
tuya-mqtt:state tuya/paere/state OFF +47ms
tuya-mqtt:state MQTT DPS JSON: tuya/paere/dps/state -> {"1":false,"3":92} +1ms
tuya-mqtt:state MQTT DPS1: tuya/paere/dps/1/state -> false +0ms
tuya-mqtt:state MQTT DPS3: tuya/paere/dps/3/state -> 92 +1ms
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +9s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +9s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +23ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +1ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +29ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +25ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +28ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +28ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +26ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +1ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +28ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +27ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +29ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +30ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +32ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +28ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +1ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +27ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c7323052c78) +29ms
tuya-mqtt:error Error connecting to device id 8037870450029170f251...retry in 10 seconds. +1s
tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +11s
tuya-mqtt:tuyapi Found device id 8037870450029170f251 +0ms
tuya-mqtt:error Error: Error from socket
tuya-mqtt:error at Socket.<anonymous> (/opt/tuya-mqtt/node_modules/tuyapi/index.js:387:30)
tuya-mqtt:error at Socket.emit (events.js:314:20)
tuya-mqtt:error at emitErrorNT (internal/streams/destroy.js:92:8)
tuya-mqtt:error at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
tuya-mqtt:error at processTicksAndRejections (internal/process/task_queues.js:84:21) +10s
tuya-mqtt:tuyapi Disconnected from device Bordlampe (192.168.1.200, 8037870450029170f251, b1971c732`
Thanks, much better now! 👍
In one of your last updates, I saw you used type: 'TuyaDevice' - as to my knowledge this is not a valid type. What kind of device is it? Can you try GenericDevice instead of TuyaDevice?
TuyaDevice is defined in the device folder (tuya-device.js) . It was just for testing.
Current devices.conf looks like this: `[ { name: 'Switch1', id: '487668362cf432362176', key: 'c503e1067353de66', ip: '192.168.1.228', version: '3.3', type: 'SimpleSwitch' }, { name: 'Bordlampe', id: '8037870450029170f251', key: 'b1971c7323052c78', ip: '192.168.1.200', version: '3.3', type: 'SimpleDimmer' }, { name: 'Spisebord', id: '80378704500291704621', key: '576ed7ce67b2f203', ip: '192.168.1.231', version: '3.3', type: 'SimpleDimmer' }, { name: 'Paere', id: '73000250c44f339338aa', key: 'c5b322f007e1823c', ip: '192.168.1.235', version: '3.3', type: 'SimpleDimmer' } ]
`
The config looks ok - I guess "Bordlampe" and "Spiseboard" are the same type of devices? Did you connect via the Tuya-App after you started tuya-mqtt?
Did you try to reboot the device (physically disconnect/reconnect from power)?
Looking at the above it seems like only a single device is actually failing, the other three show no issues. The device that is failing is rejecting the socket connection which implies that something about that device configuration is incorrect (wrong id, key, ip, protocol version) or that something is already connected to it. Also, does that device work if you use auto-discovery?
Sometimes I've had a device get in this state where it stops accepting local connections and even the Tuya app won't connect locally although control via Tuya cloud would still work, however, this usually seems to clear up after a few minutes. I had one light bulb get in this state for hours at one point, I thought I had killed it by sending an invalid value to one of the DPS keys, but, when I woke up the next morning, it had recovered in the middle of the night after hundreds of retries.
You could also try stopping tuya-mqtt and attempt to control that device via tuya-cli, but the error above is pretty basic, a standard socket error, and is coming from TuyAPI, which is used by both tuya-mqtt and tuya-cli.
Yes - 'Bordlampe' and 'Spisebord' is the same type/brand. I have tuya-app connected on my iPhone. I also tried to switch off the tuya-app - no change. the device "Bordlampe" continues to refuce to connect
I double checkt the parameters with tuya-cli. I have been able to use that device until yesterday (in the old configuration) I added another device - a dual dimmer (defined as type SimpleDimmer) - at this one is also connected. (I do not know if I can use this type without creating a new device object for DualDimmer??, but this is not important right now)
I see in logs you had previously posted that it worked at least once with auto discovery so you might want to try changing that one back to auto-discovery. You should see if it still works if you revert that device to auto-discovery. Also, please post the working tuya-cli command.
This is the printout from tuya-cli and copied directly into devices.conf
[ { name: 'Bordlampe', id: '8037870450029170f251', key: 'b1971c7323052c78' }, { name: 'Switch1', id: '487668362cf432362176', key: 'c503e1067353de66' }, { name: '2wDimmer', id: '38341275c82b9648acb0', key: 'a823482508e90875' }, { name: 'Spisebord', id: '80378704500291704621', key: '576ed7ce67b2f203' }, { name: 'Paere', id: '73000250c44f339338aa', key: 'c5b322f007e1823c' }, { name: 'Hoveddør', id: 'bf5959607ad139b09cqivc', key: '698139bd9dbc9f7b' } ]
This is the resulting dump:
`[17:06:51] root@openHABianDevice:/opt/tuya-mqtt# ./test.sh tuya-mqtt:info Connection established to MQTT server +0ms tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +0ms tuya-mqtt:tuyapi Search for device id 487668362cf432362176 +7ms tuya-mqtt:tuyapi Search for device id 38341275c82b9648acb0 +1ms tuya-mqtt:tuyapi Search for device id 80378704500291704621 +1ms tuya-mqtt:tuyapi Search for device id 73000250c44f339338aa +0ms tuya-mqtt:tuyapi Search for device id bf5959607ad139b09cqivc +1ms tuya-mqtt:tuyapi Found device id 80378704500291704621 +1s tuya-mqtt:tuyapi Received JSON data from device 80378704500291704621 -> {"1":true,"2":106} +55ms tuya-mqtt:tuyapi Found device id 73000250c44f339338aa +239ms tuya-mqtt:tuyapi Received JSON data from device 73000250c44f339338aa -> {"1":false,"3":92} +51ms tuya-mqtt:tuyapi Found device id 38341275c82b9648acb0 +546ms tuya-mqtt:tuyapi Found device id 487668362cf432362176 +3ms tuya-mqtt:tuyapi Received JSON data from device 487668362cf432362176 -> {"1":false,"2":0} +34ms tuya-mqtt:tuyapi Received JSON data from device 38341275c82b9648acb0 -> {"1":true,"2":1000,"6":0,"7":true,"8":300,"12":0} +2ms tuya-mqtt:tuyapi Connected to device Spisebord (80378704500291704621, 576ed7ce67b2f203) +89ms tuya-mqtt:tuyapi Received JSON data from device 80378704500291704621 -> {"1":true,"2":106} +27ms tuya-mqtt:state MQTT DPS JSON: tuya/spisebord/dps/state -> {"1":true,"2":106} +0ms tuya-mqtt:state MQTT DPS1: tuya/spisebord/dps/1/state -> true +1ms tuya-mqtt:state MQTT DPS2: tuya/spisebord/dps/2/state -> 106 +28ms tuya-mqtt:tuyapi Connected to device Paere (73000250c44f339338aa, c5b322f007e1823c) +261ms tuya-mqtt:tuyapi Received JSON data from device 73000250c44f339338aa -> {"1":false,"3":92} +36ms tuya-mqtt:state MQTT DPS JSON: tuya/paere/dps/state -> {"1":false,"3":92} +268ms tuya-mqtt:state MQTT DPS1: tuya/paere/dps/1/state -> false +1ms tuya-mqtt:state MQTT DPS3: tuya/paere/dps/3/state -> 92 +1ms tuya-mqtt:tuyapi Connected to device Switch1 (487668362cf432362176, c503e1067353de66) +561ms tuya-mqtt:tuyapi Connected to device 2wDimmer (38341275c82b9648acb0, a823482508e90875) +3ms tuya-mqtt:tuyapi Received JSON data from device 487668362cf432362176 -> {"1":false,"2":0} +26ms tuya-mqtt:state MQTT DPS JSON: tuya/switch1/dps/state -> {"1":false,"2":0} +588ms tuya-mqtt:state MQTT DPS1: tuya/switch1/dps/1/state -> false +1ms tuya-mqtt:state MQTT DPS2: tuya/switch1/dps/2/state -> 0 +1ms tuya-mqtt:tuyapi Received JSON data from device 38341275c82b9648acb0 -> {"1":true,"2":1000,"6":0,"7":true,"8":300,"12":0} +5ms tuya-mqtt:state MQTT DPS JSON: tuya/2wdimmer/dps/state -> {"1":true,"2":1000,"6":0,"7":true,"8":300,"12":0} +3ms tuya-mqtt:state MQTT DPS1: tuya/2wdimmer/dps/1/state -> true +0ms tuya-mqtt:state MQTT DPS2: tuya/2wdimmer/dps/2/state -> 1000 +1ms tuya-mqtt:state MQTT DPS6: tuya/2wdimmer/dps/6/state -> 0 +1ms tuya-mqtt:state MQTT DPS7: tuya/2wdimmer/dps/7/state -> true +0ms tuya-mqtt:state MQTT DPS8: tuya/2wdimmer/dps/8/state -> 300 +1ms tuya-mqtt:state MQTT DPS12: tuya/2wdimmer/dps/12/state -> 0 +0ms tuya-mqtt:error find() timed out. Is the device powered on and the ID or IP correct? +0ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms tuya-mqtt:error find() timed out. Is the device powered on and the ID or IP correct? +3ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms tuya-mqtt:tuyapi Search for device id 8037870450029170f251 +1m tuya-mqtt:tuyapi Search for device id bf5959607ad139b09cqivc +1ms tuya-mqtt:error find() timed out. Is the device powered on and the ID or IP correct? +1m tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms tuya-mqtt:error find() timed out. Is the device powered on and the ID or IP correct? +1ms tuya-mqtt:error Will attempt to find device again in 60 seconds +0ms
`
Everything but "Bordlampe" works. "Bordlampe" does work from tuya-app (and google home)
Just a thought: Could it be that the ip-address of "Bordlampe" has been changed? Do you use DHCP?
no - it is still the same :)
Personally I would just delete and reinitialize that device and try again with the new key since all of the other devices seem to be working fine. There's obviously no issue with tuya-mqtt. As I said above, I would suggest you attempt to control the device with tuya-cli get/set (this has nothing to do with tuya-cli wizard output) and see if that works.
Unfortunately I don't have time to troubleshoot your device/environment specific issues and I think we can safely say that the issue is not with tuya-mqtt at this point, so I will be bowing out of this thread for now. I do hope you get it working.
When trying to install on RS914 (npm install) I get the following:
`ash-4.3# npm install audited 322 packages in 17.975s
45 packages are looking for funding run
npm fund
for detailsfound 2 vulnerabilities (1 low, 1 high) run
npm audit fix
to fix them, ornpm audit
for detailsash-4.3#`
running npm audit, I get the following: `ash-4.3# npm audit
┌──────────────────────────────────────────────────────────────────────────────┐ │ Manual Review │ │ Some vulnerabilities require your attention to resolve │ │ │ │ Visit https://go.npm.me/audit-guide for additional guidance │ └──────────────────────────────────────────────────────────────────────────────┘ ┌───────────────┬──────────────────────────────────────────────────────────────┐ │ Low │ Prototype Pollution │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Package │ minimist │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Patched in │ >=0.2.1 <1.0.0 || >=1.2.3 │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Dependency of │ @tuyapi/cli │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Path │ @tuyapi/cli > http-mitm-proxy > optimist > minimist │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ More info │ https://npmjs.com/advisories/1179 │ └───────────────┴──────────────────────────────────────────────────────────────┘ ┌───────────────┬──────────────────────────────────────────────────────────────┐ │ High │ Prototype Pollution in node-forge │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Package │ node-forge │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Patched in │ >= 0.10.0 │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Dependency of │ @tuyapi/cli │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Path │ @tuyapi/cli > http-mitm-proxy > node-forge │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ More info │ https://npmjs.com/advisories/1561 │ └───────────────┴──────────────────────────────────────────────────────────────┘ found 2 vulnerabilities (1 low, 1 high) in 322 scanned packages 2 vulnerabilities require manual review. See the full report for details. ash-4.3#`
Running npm audit fix, I get the following: `ash-4.3# npm audit fix up to date in 15.732s
45 packages are looking for funding run
npm fund
for detailsfixed 0 of 2 vulnerabilities in 322 scanned packages 2 vulnerabilities required manual review and could not be updated ash-4.3#`
Sending command from MQTT prints the following:
(node:7616) UnhandledPromiseRejectionWarning: Error: No connection has been made to the device. at TuyaDevice._send (/volume1/homes/admin/tuya-mqtt-master/node_modules/tuyapi/index.js:269:13) at pTimeout._setResolver (/volume1/homes/admin/tuya-mqtt-master/node_modules/tuyapi/index.js:242:14) at new Promise (<anonymous>) at /volume1/homes/admin/tuya-mqtt-master/node_modules/tuyapi/index.js:238:46 at run (/volume1/homes/admin/tuya-mqtt-master/node_modules/p-queue/dist/index.js:153:104) at PQueue._tryToStartAnother (/volume1/homes/admin/tuya-mqtt-master/node_modules/p-queue/dist/index.js:101:38) at /volume1/homes/admin/tuya-mqtt-master/node_modules/p-queue/dist/index.js:167:18 at new Promise (<anonymous>) at PQueue.add (/volume1/homes/admin/tuya-mqtt-master/node_modules/p-queue/dist/index.js:148:16) at TuyaDevice.set (/volume1/homes/admin/tuya-mqtt-master/node_modules/tuyapi/index.js:238:27) (node:7616) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:7616) [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.
Any idea? Thanks for the greate work - it works fine on my Raspberry pi but not on Synology. I have checked the configurations files and the cli.