-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Host is unreachable, report error #224
Comments
Correct me if I"m wrong, but I think the root of your confusion lies in thinking that TuyAPI exposes a native NodeJS socket. Although the interface is similar, TuyAPI does not expose the full underlying socket and the function signatures between the NodeJS Net class and TuyAPI are not the same. A few things:
|
thanks for the answer. Yes i know tuyapi doesn't expose any socket, is because there is a error listener i would expect it to report on host unreachable but since net docs are not clear that when host is down it would raise error, neither then tuyapi would do report it. Thanks again for your suggestion i'll test them, i did miss out reading the isConnected function |
Got it, let me know if you have any other questions. And if you discover anything inconsistent in your testing between real-world behavior and the TuyAPI docs, please let me know so I can update them. |
I took some time to read node-red docs to create an exclusive node for this. Very basic at the moment just by using the asynchronous example on the README, i simply couldn't figure it out from node-red-constrib-tuya-smart. So one thing i noticed, i have to disconnect the device on re-deploy otherwise it won't connect again due so the single connection limit. I do it like this, which works this.on('close', function() {
if (device.isConnected()) {
// node.warn("NR re-deploy, disconnecting")
device.disconnect();
}
}); now....when the device is taken off from mains while connected, i would expect a disconnect event or error but nothing comes through. This can be important as it can be used to mark the device as offline or unavailable (mqtt switch in homeassistant for example). The event gets fired when i re-deploy, which means device.disconnect() gets called and a new connection attempt is made timing out as it should. Back to the original post could this be a limitation on the net library or can it be handled by tuyapi? |
Just an update i left the example running on DEBUG=* and i can see the keep alive ping pong, so i when i plug off the device i get a disconnect event about 100 pings later, that's about 16 minutes
|
Heartbeat disconnect is being discussed for v6.0.0 #169 (comment) |
Thanks very much. I'll subscribe to the post for updates |
Hi there, just wanted to thank you for this library. There is a nodered plugin that uses this library but looks like the creator is not interested in updating to the latest tuyapi. I though it would just be to pass the version in the constructor and change the package version. But didn't work for me, so at the moment i am using the library by importing tuyapi into the global context which works good for me now.
Describe the bug
this is not like a bug but more like a question on the underlying net connect method. To use this tuya sockets i have them set up as mqtt switch in homeassistant, and all commanding and state report is done via nodered using mqtt in-out. To mark the devices as available or unavailable i use a 3 min interval ping to each device. To report the current state of the plugs i use a 10 sec interval query this time using the tuyapi module in a function node. I though to take out the ping out of the flow and just rely in tuyapi but seems like when host is unreachable there is no error report. I am correct to assume the net.connect method will not report any errors if the host is down? just will report on connections errors (sudden disconnect, refused, etc), the docs are not very specific on which errors
https://nodejs.org/api/net.html#net_event_connect
This is the code to check the status i use
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Debug Output
Post the output of your program/app/script when run with the
DEBUG
environment variable set to*
. Example:DEBUG=* node test.js
. Copy the output and paste it below (in between the code fences):Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: