rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.84k stars 546 forks source link

Not Connected to Device - Tuya Bulb #242

Open jcbagtas opened 3 years ago

jcbagtas commented 3 years ago

I was able to control the bulb before this happened. No particular change.

Setup the bulb via UI and not YAML

Happened while doing an automation, it just suddenly not connected.

Smart Life app can access the Bulb, home assistant cannot.

Log:

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:136
Integration: LocalTuya (documentation, issues)
First occurred: 11:33:35 PM (1 occurrences)
Last logged: 11:33:35 PM

[563...a24] Not connected to device Bathroom Bulb

Edit: Server: Raspberry Pi 4 Model B 8G RAM I just updated my HassOS and Supervisor to the latest: Home Assistant OS 5.8 Supervisor 2020.12.7

ultratoto14 commented 3 years ago

@jcbagtas on which version are you working ?

ranrinc commented 3 years ago

Hem, yesterday like almost 20 hours ago downloaded the latest master and upload it to the latest 2020.12.1 HA. Somehow all my tuya lightbulb is now missing from the list. Luckily since I still have the latest localtuya master, so I'm rolling back to it and the bulb appears back on HA. So there must be something wrong with it.

postlund commented 3 years ago

Make sure to check the log and not just only entity state as that tells us nothing about the actual problem.

ultratoto14 commented 3 years ago

@ranrinc are you blocking in some way udp requests ? Is your homeassistant running inside docker ?

Do you have the same kind of logs as jcbagtas ?

ranrinc commented 3 years ago

@ranrinc are you blocking in some way udp requests ? Is your homeassistant running inside docker ?

Do you have the same kind of logs as jcbagtas ?

Unsure about blocking a request since the older localtuya master working and yes I'm running home-assistant docker on my Synology. Will try to upload the latest localtuya master and hope it did not block my bulb again.

ultratoto14 commented 3 years ago

Is your docker instance in network mode host, or you defined only some port mapping ?

ranrinc commented 3 years ago

Is your docker instance in network mode host, or you defined only some port mapping ?

my docker running on host mode. Furthermore localtuya work just cant find the bulb. The rest Is working fine/

msslava commented 3 years ago

Same problem: Not connected to device ...

After reboot, it works fine, but soon time is again error

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:136
Integration: LocalTuya integration (documentation, issues)
First occurred: 17 декабря 2020 г., 21:13:25 (56 occurrences)
Last logged: 10:34:24

[001...af2] Not connected to device loungezone_powerstrip
[001...1a0] Not connected to device kitchen_powerstrip

Home Assistant 2020.12.1, Hass.io

jcbagtas commented 3 years ago

Apologies on my late reply. There was no blocking on my router.

I assume that tuya bulb still needs to ping their server (maybe for heartbeat?) to get a localkey to be used for local communications.

But I think it contradicts the "Local" in localtuya so I am still unsure if it is the actual reason.

As of now, I haven't monitored the light bulb due to festivity. I'll be setting up my sensors again and will update as soon as possible.

ultratoto14 commented 3 years ago

@jcbagtas local in localtuya means that HA will be connected directly to the device locally instead of going through the cloud to get device status or send turn on/off commands. It doesn't mean that it prevents your device to connect to the cloud.

We may have different issues there. Please to be sure try the latest master version, it may have a fix to the not connected issues or devices unavailable.

In the opposite, now master is using the ability for tuya devices to advertise themselves through UDP, so ports 6666 and 6667 should also be accessible. As a general advice, do not block UDP from your devices, if you have homeassistant running in docker instance, either use the network mode host or map the ports mentioned above.

In general, it good be a good idea to report the exact version of localtuya you are running and if you use master, you can mention the last commit id.

jcbagtas commented 3 years ago

@jcbagtas local in localtuya means that HA will be connected directly to the device locally instead of going through the cloud to get device status or send turn on/off commands. It doesn't mean that it prevents your device to connect to the cloud.

We may have different issues there. Please to be sure try the latest master version, it may have a fix to the not connected issues or devices unavailable.

In the opposite, now master is using the ability for tuya devices to advertise themselves through UDP, so ports 6666 and 6667 should also be accessible. As a general advice, do not block UDP from your devices, if you have homeassistant running in docker instance, either use the network mode host or map the ports mentioned above.

In general, it good be a good idea to report the exact version of localtuya you are running and if you use master, you can mention the last commit id.

Thanks for clarifying the cloud connection.

I am currently running the latest v3.1.0. I actually posted this issue before I updated HassOS, Supervisor, and Localtuya. Thank you for all your efforts.

I will continue to monitor the behaviour of the tuya bulb I have. As of now it is yet to disconnect, not like last week where in I have to reload the integration and resubmit the configuration every time I try to use the bulb.

I'll keep you posted. :)

PS, also remember the first time I tried to integrate localtuya, I had a connection error on ports 6666/6667 (not sure if it also stated 6668)

jcbagtas commented 3 years ago

After testing for some time now, I can say it is much stable than the previous versions.

Sometimes I turn off the power directly from the switch of the bulb and let it be disconnected from HA for a while. Then after I turn it on, it will eventually reconnect and the integration will still work.

But sometimes it does not. What I do to fix this is to either:

  1. RECONFIGURE the device
  2. RELOAD the integration

So far, I only need to do this when it gets disconnected because of the switch being Off or (sometimes) the router being restarted.

But it rarely happens now.

ranrinc commented 3 years ago

After testing for some time now, I can say it is much stable than the previous versions.

Sometimes I turn off the power directly from the switch of the bulb and let it be disconnected from HA for a while. Then after I turn it on, it will eventually reconnect and the integration will still work.

But sometimes it does not. What I do to fix this is to either:

1. RECONFIGURE the device

2. RELOAD the integration

So far, I only need to do this when it gets disconnected because of the switch being Off or (sometimes) the router being restarted.

But it rarely happens now.

Testing the current master. Hopefully, this will work 100% Thanks, bro.. for all the work. Really appreciated.

UPDATE: The latest master work and stable.. thanks again for the hard works...

msslava commented 3 years ago

Are you planning to upgrade your integration in HACS?

ultratoto14 commented 3 years ago

@msslava you can access to master in hacs.

ranrinc commented 3 years ago

@msslava you can access to master in hacs.

how to access master from hacs?

msslava commented 3 years ago

@ranrinc I did the following: