rospogrigio / localtuya

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

Can't setup LocalTuya #570

Open colindawson opened 2 years ago

colindawson commented 2 years ago

New install of local tuya. I select the dropdown with to find the device ID, and nothing is listed, even though I have three Tuya devices.

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:240 Integration: LocalTuya integration (documentation, issues) First occurred: 10:22:34 (4 occurrences) Last logged: 10:22:56

[582...872] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 510, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 472, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

Environment

Steps to reproduce

  1. Add localTuya in hacs
  2. Restart Home Assistant
  3. Add localTuya integration.

Configuration configuration.yaml or config_flow

I don't have a configuration, it's not installed yet.

DP dump

Provide Home Assistant taceback/logs

Additional information

rick044 commented 2 years ago

Exact same issue as above.

theoneandonlyzako commented 2 years ago

I keep getting an error when trying to submit a new device... first time.

kansson commented 2 years ago

Same thing with my installation.

derekoharrow commented 2 years ago

Ditto (want to use Local Tuya as the new official Tuya integration doesn't work properly with my thermostat)

cwquek commented 2 years ago

I have the same issue.

com-xuonghuynh commented 2 years ago

Same issue

Krojack commented 2 years ago

So I was getting this then out of the blue it started to work but only with power plugs. I have an LED light strip that I can't get working.

Error from the log:

2021-10-09 17:25:06 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...bd9] Heartbeat failed due to timeout, disconnecting
2021-10-09 17:25:06 ERROR (MainThread) [custom_components.localtuya.pytuya] [300...bd9] Failed to get status: 

Lights are working fine with the Smart Life app. They are even detected when I go to add the LocalTuya integration.

Full error message here: https://pastebin.com/apFSwkmH

atjshop commented 2 years ago

I had lot of timeout last night too. And I tried again later they worked well no issue.

back5907 commented 2 years ago

same how to fix

lockyt commented 2 years ago

Same issue - worked the first time I tried (before realising I need the local key) but now it just shows an empty list. If I hit submit with it empty (and after hitting the three dots) it lets me try enter it manually, but then I get 'An unknown error occurred, see log for details'. In the log I get Failed to get statusand unknown exception errors.

crferreira commented 2 years ago

I was having the same issue. In my case, I've had a Tuya v2 integration configured previously. Then, I disabled it and now Local Tuya is working.

cwquek commented 2 years ago

I was having the same issue. In my case, I've had a Tuya v2 integration configured previously. Then, I disabled it and now Local Tuya is working.

Thank you! That solve my problem.

colindawson commented 2 years ago

Further update from me. I rebuilt my Home Assistant install from scratch, and have more Tuya devices. (6 sockets, and 2 lights) When setting up my LocalTuya. Note I do not have the Tuya or V2 integrations and as this is a new build they've never been installed.

What I have found is that some devices install and work just fine, (4 sockets and 1 light). Whilst others do not, they get a "An unknown error occurred. See log for details." in the dialog.

When I check the logs there's two entries....

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:240 Integration: LocalTuya integration (documentation, issues) First occurred: 13:21:12 (1 occurrences) Last logged: 13:21:12

[582...872] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 510, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 472, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

And

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:240 Integration: LocalTuya integration (documentation, issues) First occurred: 13:21:12 (1 occurrences) Last logged: 13:21:12

Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 279, in async_step_basic_info self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 192, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 510, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 472, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

This will happen consistently for some devices, whilst others appear to work just fine.

purplephoenix76 commented 2 years ago

i had one switch which i had added successfully. After a few days, it starts showing unavailable. I've tried reload, restart and ultimate delete the integration. When i try to add it again, i've encountered the same as the rest. Using local tuya 3.2.3. I had no issues using the smart life app to access the switch and turn it on.

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:240 Integration: LocalTuya integration (documentation, issues) First occurred: 17:49:25 (11 occurrences) Last logged: 18:00:20

[bf0...kq4] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 510, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 472, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

DaKar00 commented 2 years ago

I have figured out cause for this problem, you are probably getting the device ID from the smart life app at the same time you are finnishing the integration of the device, just get the device ID of you device then close the smart life app before finnishing the integration in local tuya and it work every time =D

duncan485 commented 2 years ago

I have figured out cause for this problem, you are probably getting the device ID from the smart life app at the same time you are finnishing the integration of the device, just get the device ID of you device then close the smart life app before finnishing the integration in local tuya and it work every time =D

@DaKar00 Thanks, closing the app (Tuya in my case) on my phone actually worked =).

movanet commented 2 years ago

I have figured out cause for this problem, you are probably getting the device ID from the smart life app at the same time you are finnishing the integration of the device, just get the device ID of you device then close the smart life app before finnishing the integration in local tuya and it work every time =D

This is a good solution, thank you! Been trying for a few weeks until now....

evenywchen commented 2 years ago

I have figured out cause for this problem, you are probably getting the device ID from the smart life app at the same time you are finnishing the integration of the device, just get the device ID of you device then close the smart life app before finnishing the integration in local tuya and it work every time =D

@DaKar00 Thanks, closing the "Tuya Smart" actually worked, too.

williamrosswhite commented 1 year ago

I was having the same issue. In my case, I've had a Tuya v2 integration configured previously. Then, I disabled it and now Local Tuya is working.

what is tuya v2? where is it? how do i disabele it?

besiktas97 commented 1 year ago

I was having the same issue. In my case, I've had a Tuya v2 integration configured previously. Then, I disabled it and now Local Tuya is working.

what is tuya v2? where is it? how do i disabele it?

Tuya v2 is a integration and you can delete it. V2 is the cloud version of all your tuya devices.

williamrosswhite commented 1 year ago

I was having the same issue. In my case, I've had a Tuya v2 integration configured previously. Then, I disabled it and now Local Tuya is working.

what is tuya v2? where is it? how do i disabele it?

Tuya v2 is a integration and you can delete it. V2 is the cloud version of all your tuya devices.

Do you mean the existing cloud based tuya integration in home assistant? I deleted that and tried again and got the same error. It says check logs but where are the logs to check?

webwolf3000 commented 1 year ago

This doesn't work; it's buggy as hell.

It was working great for 3 months, occasionally went offline but I just had to login to the app and send a command to the Blind motor to 'wake it up' then the tuya local button would work again. After hitting configure on the tuya local integration and changing one thing, it totally went offline (unavailable) - I've set it up 20 times and even restored a 3 month old HASS to a VM to test it and it's just unavailable.

Not sure what changed, but for some reason, this thing is totally not playing ball. It's very flaky and intermittent even when it's working so stability is an issue.

Can confirm if too many things are trying to connect to the Motor at the same time, it'll just balk and go offline. But I disabled and closed everything related to the motor and it just sat there, occasionally waking up just to go back to unavailable for no obvious reason. Actually think Tuya is the issue here, maybe flashing the device would be a better option...

DaKar00 commented 1 year ago

Have you tried the new "get devices from cloud" function in the new localtuya app?

Hämta Outlook for Androidhttps://aka.ms/AAb9ysg


From: webwolf3000 @.> Sent: Tuesday, December 6, 2022 9:16:59 PM To: rospogrigio/localtuya @.> Cc: DaKar00 @.>; Mention @.> Subject: Re: [rospogrigio/localtuya] Can't setup LocalTuya (#570)

This doesn't work; it's buggy as hell.

It was working great for 3 months, occasionally went offline but I just had to login to the app and send a command to the Blind motor to 'wake it up' then the tuya local button would work again. After hitting configure on the tuya local integration and changing one thing, it totally went offline (unavailable) - I've set it up 20 times and even restored a 3 month old HASS to a VM to test it and it's just unavailable.

Not sure what changed, but for some reason, this thing is totally not playing ball. It's very flaky and intermittent even when it's working so stability is an issue.

Can confirm if too many things are trying to connect to the Motor at the same time, it'll just balk and go offline. But I disabled and closed everything related to the motor and it just sat there, occasionally waking up just to go back to unavailable for no obvious reason. Actually think Tuya is the issue here, maybe flashing the device would be a better option...

— Reply to this email directly, view it on GitHubhttps://github.com/rospogrigio/localtuya/issues/570#issuecomment-1339953620, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AS2A4PNN3US7GNTFKMFQLCTWL6NLXANCNFSM5EN5WKXQ. You are receiving this because you were mentioned.Message ID: @.***>

webwolf3000 commented 1 year ago

Have you tried the new "get devices from cloud" function in the new localtuya app?

I have not. I logged into the cloud in the local tuya app (did and didn't, reset the device deleted in the cloud and reconfigured etc).

Is there a new option other than logging into the cloud through the local tuya app?

Ok, so essentially if for any reason you reconfigure the local tuya device, it will invalidate the integration. You have to perform the following:

Open the tuya mobile app Remove and reset the device (don't just remove) Add the device to the tuya app *Close the tuya app Configure local tuya

It's not possible to reconfigure the local tuya integration without completely reconfiguring it from scratch.

For now, I can get a positioning but not open, close, stop controls and since I have to delete and readd everything to keep trying to fix it... The standard tuya app works better for now.

NothingSethual commented 1 year ago

I have figured out cause for this problem, you are probably getting the device ID from the smart life app at the same time you are finnishing the integration of the device, just get the device ID of you device then close the smart life app before finnishing the integration in local tuya and it work every time =D

Bless you. This did the trick for me. Closed Tuya (and white-labelled versions) and it worked.