rospogrigio / localtuya

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

Devices become unavailable #1117

Open fotis3d opened 1 year ago

fotis3d commented 1 year ago

Suddenly devices become unavailable forever. Tuya bulbs and plugs. In Tuya they work just fine. Reloading Local Tuya does not help.

To fix it I have to : 1) edit one of my devices (doesn't matter which one) without changing anything and then all the unavailable devices become available again. 2) Restart Home Assistant

BUT these work only for a short time. After a while the same thing happens.

Environment

cataseven commented 1 year ago

When I need I re install, add device and delete. You can also go settings stop woriking background and force stop options. But I prefer uninstall bcz I do not nuy new devices often

rlause commented 1 year ago

As mentioned before stopping access to DNS (blocking port 53) additionally to forbidding internet access works for weeks now. Meanwhile I updated and always stay with the most current Local Tuya version.

I have to admit that I have not used the SmartLife app since then. To do so, I would grant full internet (and DNS) access before opening the app. Having used the app I would disable internet and dns access again. As I said I haven't tried this out but I am quite sure this would work.

stephens12 commented 1 year ago

Just chiming in case it helps anyone. I fixed my issue by restarting my wireless then reloading Local Tuya. All the unavailable items came right back online.

ilkanaev commented 1 year ago

i have the same issue with one of my Tuya WiFi Smart Switch 3 gang. I have three of them but only one is problematic. Latest versions on all HW and SW components. After every reboot of homeassistant the device become unavailable.

My tricks to get it back is: Simple (mostly working) - go to tuya integration, click on edit device, select the unavailable one and "next, next, next..." without changing anything. More complicated (worst case) powering off/on the unavailable device via main electricity switch at my home.

{ "home_assistant": { "installation_type": "Home Assistant Supervised", "version": "2023.4.6", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.10", "docker": true, "arch": "aarch64", "timezone": "Asia/Jerusalem", "os_name": "Linux", "os_version": "6.1.21-v8+", "supervisor": "2023.04.0", "host_os": "Debian GNU/Linux 11 (bullseye)", "docker_version": "23.0.3", "chassis": "", "run_as_root": true }, "custom_components": { "sonoff": { "version": "3.5.1", "requirements": [ "pycryptodome>=3.6.6" ] }, "localtuya": { "version": "5.0.0", "requirements": [] }, "hacs": { "version": "1.32.1", "requirements": [ "aiogithubapi>=22.10.1" ] }, "xiaomi_gateway3": { "version": "3.2.1", "requirements": [ "zigpy>=0.44.1" ] } }, "integration_manifest": { "domain": "localtuya", "name": "LocalTuya integration", "version": "5.0.0", "documentation": "https://github.com/rospogrigio/localtuya/", "dependencies": [], "codeowners": [ "@rospogrigio", "@postlund" ], "issue_tracker": "https://github.com/rospogrigio/localtuya/issues", "requirements": [], "config_flow": true, "iot_class": "local_push", "is_built_in": false }, "data": { "region": "eu", "client_id": "...", "client_secret": "...", "user_id": "...", "username": "localtuya", "no_cloud": true, "devices": { ... ... "XXXXXXXXXXXXXXXXX": { "friendly_name": "Kitchen Main", "host": "XXX.XXX.XXX.XXX", "local_key": "XXX...XXX", "protocol_version": "3.3", "enable_debug": false, "entities": [ { "friendly_name": "kitchen_main_1", "current": 1, "current_consumption": 9, "voltage": 9, "restore_on_reconnect": false, "is_passive_entity": false, "id": 1, "platform": "switch" }, { "friendly_name": "kitchen_main_2", "current": 2, "current_consumption": 10, "voltage": 10, "restore_on_reconnect": false, "is_passive_entity": false, "id": 2, "platform": "switch" }, { "friendly_name": "kitchen_main_3", "current": 3, "current_consumption": 11, "voltage": 11, "restore_on_reconnect": false, "is_passive_entity": false, "id": 3, "platform": "switch" } ], "device_id": "eb6c5a629553039c6bpl2d", "dps_strings": [ "1 (value: False)", "2 (value: False)", "3 (value: False)", "9 (value: 0)", "10 (value: 0)", "11 (value: 0)" ], "product_key": "XXXXXXXXXXX" } }, "updated_at": "1682140526462", "cloud_devices": {} } }

keo85 commented 1 year ago

The issue here… just waiting someone could attend it.

gupaa commented 1 year ago

image every minute,,,

keo85 commented 1 year ago

I also have the same problem, all devices become disconnected, it is very frustrating…

cataseven commented 1 year ago

cataseven commented on Mar 12 When I need I re install, add device and delete. You can also go settings stop woriking background and force stop options. But I prefer uninstall bcz I do not nuy new devices often

Also disable devices of official tuya integration

lawrencelnm commented 1 year ago

I have a similar issue to this for many months now. All my LocalTuya devices will go into 'unavailable' state, all at the exact same time. This happens roughly once a day, at random time of the day.

I have been using LocalTuya from 2 years now. I never had this issue before. I suspect this started manifesting when LocalTuya implemented the Tuya account integration - the one that allow LocalTuya to obtain the device key from Tuya.

I hope this gets priority to be fixed soon because all my automations and scripts aren't executing properly when the devices go into unavailable state. I would even asked that we go back to the old non integrated way with Tuya (if it is the integration) to give this stability.

pratahsinnetamby commented 1 year ago

I had the same issue and (finally) I was able to fix it: I used tinytuya to scan my local network for Tuya devices and I noticed that the local keys for the unavailable ones have been changed!. Here are the steps for the solution:

  1. Install the tinytuya on your PC or a VM in the same network as your Tuya devices. Ideally, install it inside a virtual environment
  2. Run python-m tinytuya scan to see the list of the available devices.
  3. In the command output, find your device (based on device ID or IP address) and copy the value of Local Key.
  4. Go to HA -> Settings -> Integrations -> Localtuya -> Configure
  5. Select: Edit a device
  6. Finally change the Local key and save.

Your device is now alive!

1116

Nope. To me is not the local key. After restart it works for a little while. Local key was the first that came to my mind and checked that, it hadn't changed. Nevertheless I setup the cloud api just for testing cause I hadn't done that yet.

Hi Lawrence,

I don't seem to have the "Edit a device option"! Where exactly do you find it. In my case one of my devices was reset by Tuya (this switch seems to get reset every now and then) and each time it resets the local key. When I was using yaml, I was able to fix it quite easily, but now, I'm not sure where I can change it.

Any assistance would be much appreciated.

heligan commented 1 year ago

+1 on the issue. here are a few things I have done so far but hard to tell what's going on.

My devices are mostly feit bulbs and I only have localtuya in HA. I am using the cloud account (it keeps local keys updated) and I verified the local keys are the same as what tinytuya returns.

I tried homeassistant.reload_config_entry service call, this will get the entity from unavailable status back to normal. But if I turn the light on (clicking the toggle button in HA), it becomes unavailable again.

Sometimes, the device will become available but there is no way to turn it on until it becomes unavailable. Rarely the light will turn on actually, but perhaps randomly?

I tried to use the tinytuya's code, it seems working

import tinytuya
>>> d = tinytuya.OutletDevice(dev_id='<dev id>', address='ip address', local_key='<local key>', version=3.3)
>>> d.turn_on()
{'dps': {'1': True}, 't': 1688520972}
>>> d.turn_off()
{'dps': {'1': False}, 't': 1688521000}

Not sure how localtuya is implemented but looks like based on pytuya? https://github.com/rospogrigio/localtuya/blob/master/custom_components/localtuya/pytuya/__init__.py

My best guess about the issue would be there might be a loop in the code that goes through all devices. If one of the devices has something wrong, it is supposed to skip (continue in python) but somehow it breaks. So if some devices are ordered before the problematic device, it would still work but other devices after the problematic device will not because of this bug.

I saw quite some warnings in the logs

2023-07-03 23:04:33.531 WARNING (MainThread) [custom_components.localtuya.common] [.........] Failed to connect to 192.168.1.154: [Errno 113] Connect call failed ('192.168.1.154', 6668)

let's call it bulb A and I have another device at 192.168.1.174 (bulb B). I was able to control bulb B with tinytuya but localtuya won't work. I checked bulb A and it seems to be offline somehow and I had to power it off and turn it back on. Then HA can turn bulb A and B on/off now. So the failure to connect to bulb A also affect the control of bulb B.

lawrencelnm commented 1 year ago

I had the same issue and (finally) I was able to fix it: I used tinytuya to scan my local network for Tuya devices and I noticed that the local keys for the unavailable ones have been changed!. Here are the steps for the solution:

  1. Install the tinytuya on your PC or a VM in the same network as your Tuya devices. Ideally, install it inside a virtual environment
  2. Run python-m tinytuya scan to see the list of the available devices.
  3. In the command output, find your device (based on device ID or IP address) and copy the value of Local Key.
  4. Go to HA -> Settings -> Integrations -> Localtuya -> Configure
  5. Select: Edit a device
  6. Finally change the Local key and save.

Your device is now alive!

1116

Nope. To me is not the local key. After restart it works for a little while. Local key was the first that came to my mind and checked that, it hadn't changed. Nevertheless I setup the cloud api just for testing cause I hadn't done that yet.

Hi Lawrence,

I don't seem to have the "Edit a device option"! Where exactly do you find it. In my case one of my devices was reset by Tuya (this switch seems to get reset every now and then) and each time it resets the local key. When I was using yaml, I was able to fix it quite easily, but now, I'm not sure where I can change it.

Any assistance would be much appreciated.

@pratahsinnetamby,Here are self explainable pictures to guide you. IMG_3203 IMG_3204

pratahsinnetamby commented 1 year ago

Many thanks for the images Lawrence - much appreciated.

We seem to be on different versions of LocalTuya - I am on 5.1.0. There appear to be a few later versions. I might consider upgrading over the week-end.

The setup I get is as follows:

image

image

joemaya03 commented 1 year ago

I was facing a similar issue. Both my devices were frequently getting disconnected every 5 mins or so. Tried creating and deleting tuya iot projects, even kept a separate wifi router for the tuya devices, still getting the frequent disconnection issue. This was on home assistant 2023.8.1 using local Tuya v 5.2.1. finally found a perfect fix for this issue. I downgraded to local Tuya 4.1.1 and while configuring the devices I set the scan interval to 1 second and manually the dps points separated by commas and bam. Everything is working fine and not a single disconnection. It's been 36 hours and the connection is very very stable without a single disconnection.

I hope this helps other users put there. I wasted nearly 4 days behind resolving this issue on my Home Assistant setup

ntzb commented 1 year ago

@joemaya03 can you please explain what steps one should take? I have my smart switch going unavailable many times in the day, for anywhere between 1 to 4 minutes at a time! image my scan interval is configured to 3 seconds, on localtuya 5.2.1 and this is the dps settings:

              "dps_strings": [
                "1 (value: True)",
                "9 (value: 0)",
                "17 (value: 86)",
                "18 (value: 0)",
                "19 (value: 0)",
                "20 (value: 2230)",
                "21 (value: 1)",
                "22 (value: 588)",
                "23 (value: 29200)",
                "24 (value: 15818)",
                "25 (value: 2630)",
                "26 (value: 0)",
                "38 (value: memory)",
                "39 (value: False)",
                "40 (value: relay)",
                "41 (value: False)",
                "42 (value: )",
                "43 (value: )",
                "44 (value: )"
              ],

(I only care about 1,18,19,20 - switch, current, voltage, power)

ldimitroff commented 1 year ago

I'm having the same issue. One thing I noticed that I'm not able to ping the device locally. I assigned a static IP just to be sure that my router was not the issue 2023-09-15 10:30:22.187 WARNING (MainThread) [custom_components.localtuya.common] [eb3...h9o] Failed to connect to 192.168.1.66: [Errno 113] Connect call failed ('192.168.1.66', 6668) Any suggestion?

ntzb commented 1 year ago

@ldimitroff I was having the same problem exactly, the device did not respond to ping. eventually I flashed libretiny/kickstart, which is esphome based. (note - you can also flash open beken but it requires mqtt which I didn't use). since then not a single disconnection. something is seriously messed up in Tuya's firmware. granted, I was not on the latest firmware (which incidentally allowed me to flash 3rd party firmware) so I might've missed an update. it seems intimidating at first, but the whole process is very straightforward with the help of tuya-cloudcutter, and there's a chance you might need to recalibrate the voltage/current/power.

kvvoff commented 1 year ago

+1 After every reboot of homeassistant the device become unavailable. Local Tuya v5.2.1 Home Assistant 2023.9.3

meshaabi commented 1 year ago

I have an automation that switches on a Tuya-based floodlight based on a sensor event. Today, I noticed that it stopped working.

Upon further investigation, I saw that in the automation, there were no options available in the device action dropdown. When the integration is working, the dropdown is populated with actions such as "Turn on light," etc.

I managed to fix this temporarily in two ways:

Both these actions also revived the automation too. Unfortunately, the fix is not permanent, and the problem reappears.

Since I didn't need to restart Home Assistant and manipulating the device via the LocalTuya created entity fixed it, i think this points to a problem under the hood. I'll continue trying to debug once the problem reappears 🕵️

Tumist76 commented 1 year ago

I have the same problem and it happens only with tuya devices. They are from different manufacturers so I could have maybe blame a HA server or a router, but other smart devices connected to the same wi-fi work perfectly fine. Don't know what can be the reason.

Screenshot_20231001-112402.png

Screenshot_20231001-112345~2.png

cataseven commented 1 year ago

I have the same problem and it happens only with tuya devices. They are from different manufacturers so I could have maybe blame a HA server or a router, but other smart devices connected to the same wi-fi work perfectly fine. Don't know what can be the reason.

Screenshot_20231001-112402.png

Screenshot_20231001-112345~2.png

just delete official smart life app from all of your devices. this app is working on the background and query your devices. Or restrict app to not to run in background

KiimaRo commented 1 year ago

Plxfyjn Keeps going unavailable. Was working fine earlier and was really snappy and fast but now it's just unavailable the moment I try and do something with it and if I do try something it is very slow.

Anj-0110 commented 12 months ago

FYI...since I have disabled the background data in the SmartLife app on my phone I have not had any of the tuya devices cycle through unavailable then on or off randomly. It have only been 2 days but the logs have been clear since doing so. Something worth trying for those that are having the same issues. If this is the fix, hallelujah! It is so nice not to log in and NOT see random lights on!!

cloudbr34k84 commented 12 months ago

How do you do this?

On Thu, Nov 9, 2023, 12:11 AM Anj-0110 @.***> wrote:

FYI...since I have disabled the background data in the SmartLife app on my phone I have not had any of the tuya devices cycle through unavailable then on or off randomly. It have only been 2 days but the logs have been clear since doing so. Something worth trying for those that are having the same issues. If this is the fix, hallelujah! It is so nice not to log in and NOT see random lights on!!

— Reply to this email directly, view it on GitHub https://github.com/rospogrigio/localtuya/issues/1117#issuecomment-1801968786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOB2WBAKDK6KVK5UOSMO3UTYDOHKFAVCNFSM6AAAAAARZ6H4BCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRHE3DQNZYGY . You are receiving this because you were mentioned.Message ID: @.***>

Anj-0110 commented 12 months ago

How do you do this? On Thu, Nov 9, 2023, 12:11 AM Anj-0110 @.> wrote: FYI...since I have disabled the background data in the SmartLife app on my phone I have not had any of the tuya devices cycle through unavailable then on or off randomly. It have only been 2 days but the logs have been clear since doing so. Something worth trying for those that are having the same issues. If this is the fix, hallelujah! It is so nice not to log in and NOT see random lights on!! — Reply to this email directly, view it on GitHub <#1117 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOB2WBAKDK6KVK5UOSMO3UTYDOHKFAVCNFSM6AAAAAARZ6H4BCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRHE3DQNZYGY . You are receiving this because you were mentioned.Message ID: @.>

I went into my app setting in my andriod phone, opened SMARTLIFE settings, went into mobile data and turned off "allow background data usage"

I have to admit, I have still had some issues with lights becoming unavailable and then turning on or off but it has not been as frequent as before.

yjamal01 commented 11 months ago

I have the same problem and it happens only with tuya devices. They are from different manufacturers so I could have maybe blame a HA server or a router, but other smart devices connected to the same wi-fi work perfectly fine. Don't know what can be the reason. Screenshot_20231001-112402.png Screenshot_20231001-112345~2.png

just delete official smart life app from all of your devices. this app is working on the background and query your devices. Or restrict app to not to run in background

Had the same issue, switched to tuya local instead and its been good. 2 of my USB smart switches weren't supported, but I took that over the constant available/unavailable issue

yeowan commented 11 months ago

So I went through the entire thread and fixed the issue after some hours of experimenting. Funny that this was mentioned before by someone, but seemingly most people ignored the comment(s).

FIX FOR LOCALTUYA DEVICES BECOMING UNAVAILABLE follows:

You need to be sure that nothing else tries to connect to your registered device but LocalTuya. Otherwise it (either immediately or after a few occasions) corrupts LocalTuya's connection to the device until the whole HA is restarted. Close and disable Tuya app in your phone, in your wife's and children's phone. Disable Tuya built-in integration in HA. Close and do not use "Tuya IOT platform". You can even disable localtuya's own cloud integration if you completed the configuration (and restarted HA).

I am pretty sure if LocalTuya device becoming unavailable or starts to "act funny" like providing the sensor data , but your commands are not recognized, then something tried to connect to it through Tuya Cloud or locally.

fotis3d commented 11 months ago

What if we also use Official Tuya along with Local Tuya ? I cannot stop official Tuya since I also use infrared devices that require internet.

Why is this happening ? I use quite some time Local Tuya and I did not have disconnections before. Now they are constant.

yjamal01 commented 11 months ago

What if we also use Official Tuya along with Local Tuya ? I cannot stop official Tuya since I also use infrared devices that require internet.

Why is this happening ? I use quite some time Local Tuya and I did not have disconnections before. Now they are constant.

switch to tuya local instead. I am using that and no offline issue so far. I use the tuya integration and tuya app too, no problem

kdober commented 11 months ago

Honestly I don't know what else to do here. My roller shade (zemismart ZM25RW01) lose connection, some times after a minute, sometimes after a few hours. Some times it comes back when I edit the settings, sometimes I have to delete it (and even after re-adding it is shows up as unavailable). A few times I was able to bring it back by chaging the "Show as" of the device, for example to Shade or Blind.

Other smart plugs I have, same issue. After few hours they become unavailable. Reload of localtuya might bring one back to life, but not all. I need to take out the plug from the wall, wait a few hours and restart HA and the work again for some minutes or hours.

When this happens, it was still possible to control those devices from the Tuya/Smart life apps. As suggested above in the thread, I removed those apps from the phone, also Tuya cloud integration in HA, close session on Tuya dev. Nothing seems to work :(

I'm not blocking any connections on my router (tp link deco) and I neither have any other software for DNS, routing, etc.

Getting out of ideas here :(

Cheers Cristian

Pouackito commented 11 months ago

So I went through the entire thread and fixed the issue after some hours of experimenting. Funny that this was mentioned before by someone, but seemingly most people ignored the comment(s).

FIX FOR LOCALTUYA DEVICES BECOMING UNAVAILABLE follows:

You need to be sure that nothing else tries to connect to your registered device but LocalTuya. Otherwise it (either immediately or after a few occasions) corrupts LocalTuya's connection to the device until the whole HA is restarted. Close and disable Tuya app in your phone, in your wife's and children's phone. Disable Tuya built-in integration in HA. Close and do not use "Tuya IOT platform". You can even disable localtuya's own cloud integration if you completed the configuration (and restarted HA).

I am pretty sure if LocalTuya device becoming unavailable or starts to "act funny" like providing the sensor data , but your commands are not recognized, then something tried to connect to it through Tuya Cloud or locally.

This solved my problem, tks !

Loeffelmaster commented 11 months ago

My devices even have no access to the internet or DNS and with all these changes, they still get unavailable and a restart of HA and making the device powerless doesn't solve the problem. In an old version (not available anymore this problem never came up on my system and nothing changed except an update of LocalTuya. By now I have also 4 devices via bluetooth I couldn't get connected to LocalTuya so even if it would work, what isn't the case for me, I couldn't use it anymore.

kdober commented 11 months ago

Is there any way to get back to version 4.0.2? The list of previous versions only shows last 5 of them and I have no clue how to get back to an older one.

yeowan commented 11 months ago

Honestly I don't know what else to do here. My roller shade (zemismart ZM25RW01) lose connection, some times after a minute, sometimes after a few hours. Some times it comes back when I edit the settings, sometimes I have to delete it (and even after re-adding it is shows up as unavailable). A few times I was able to bring it back by chaging the "Show as" of the device, for example to Shade or Blind.

Other smart plugs I have, same issue. After few hours they become unavailable. Reload of localtuya might bring one back to life, but not all. I need to take out the plug from the wall, wait a few hours and restart HA and the work again for some minutes or hours.

When this happens, it was still possible to control those devices from the Tuya/Smart life apps. As suggested above in the thread, I removed those apps from the phone, also Tuya cloud integration in HA, close session on Tuya dev. Nothing seems to work :(

I'm not blocking any connections on my router (tp link deco) and I neither have any other software for DNS, routing, etc.

Getting out of ideas here :(

Cheers Cristian

I am sure that there is still something trying to connect. Think what apps / solutions did you use in the past to connect. Do you have other family members who might use Tuya/Smart life? Do you have any polling set up anywhere by anything? Do you have schedules set up in Tuya cloud or anywhere? Try re-set up one of your plugs in localtuya, then remove it from Tuya and Smartlife Apps entirely. Restart HA, and let's see if the issue persist.

tefracky commented 11 months ago

I am using this fork and all my devices work without any error: https://github.com/xZetsubou/hass-localtuya

kdober commented 11 months ago

Honestly I don't know what else to do here. My roller shade (zemismart ZM25RW01) lose connection, some times after a minute, sometimes after a few hours. Some times it comes back when I edit the settings, sometimes I have to delete it (and even after re-adding it is shows up as unavailable). A few times I was able to bring it back by chaging the "Show as" of the device, for example to Shade or Blind. Other smart plugs I have, same issue. After few hours they become unavailable. Reload of localtuya might bring one back to life, but not all. I need to take out the plug from the wall, wait a few hours and restart HA and the work again for some minutes or hours. When this happens, it was still possible to control those devices from the Tuya/Smart life apps. As suggested above in the thread, I removed those apps from the phone, also Tuya cloud integration in HA, close session on Tuya dev. Nothing seems to work :( I'm not blocking any connections on my router (tp link deco) and I neither have any other software for DNS, routing, etc. Getting out of ideas here :( Cheers Cristian

I am sure that there is still something trying to connect. Think what apps / solutions did you use in the past to connect. Do you have other family members who might use Tuya/Smart life? Do you have any polling set up anywhere by anything? Do you have schedules set up in Tuya cloud or anywhere? Try re-set up one of your plugs in localtuya, then remove it from Tuya and Smartlife Apps entirely. Restart HA, and let's see if the issue persist.

Two devices came back to life for 1, almost 2 days but then they went back to unavailable. I'm quite sure nothing is open. The Smartlife and Tuya apps, when open on the phone are asking for my credentials (since I deleted all data for the apps). API pages are closed. No familly members or invited emails. Will try next weekend with other versions or the fork suggested on previous post and comment how it goes. Cheers

JohnMcLear commented 10 months ago

@yeowan

So I went through the entire thread and fixed the issue after some hours of experimenting. Funny that this was mentioned before by someone, but seemingly most people ignored the comment(s).

FIX FOR LOCALTUYA DEVICES BECOMING UNAVAILABLE follows:

You need to be sure that nothing else tries to connect to your registered device but LocalTuya. Otherwise it (either immediately or after a few occasions) corrupts LocalTuya's connection to the device until the whole HA is restarted. Close and disable Tuya app in your phone, in your wife's and children's phone. Disable Tuya built-in integration in HA. Close and do not use "Tuya IOT platform". You can even disable localtuya's own cloud integration if you completed the configuration (and restarted HA).

I am pretty sure if LocalTuya device becoming unavailable or starts to "act funny" like providing the sensor data , but your commands are not recognized, then something tried to connect to it through Tuya Cloud or locally.

  1. Is it possible to add new devices without the app?
  2. Is disabling the cloud integration required to achieve stability?
  3. What about if I need both online and offline access? Is that no longer viable if I want stability?

The README docs state in bold "NOTE: The Cloud API account configuration is not mandatory (LocalTuya can work also without it) but is strongly suggested" - is this erroneous?

yeowan commented 10 months ago

1, the easiest way is to do a "config round": add devices to the cloud/TuyaApp, then configure in localtuya/HA , then close TuyaApp, restart HA, and all will be ok. If I recall correctly someone posted the procedure how to add devices without app, search for it if you really want. 2, No. However in some cases (for some devices?) it actually breaks the connection. Test it first leaving it on and if you experience strange behavior then disable it. 3, If you mean the TuyaApp under "online access" then you can't do that. However you can reach your HA "online", which controls all your devices locally via localtuya. (btw this should be the generic design concept for everything you use in your smarthome ;) ) Note that if you are persistent enough you can implement all the functions in localtuya for almost every device via the info extracted from "tuya iot platform"

Regarding README - see answer 1, (not required, but makes your life significantly easier)

Note: if anything "wakes up" Tuya Cloud (like opening the TuyaApp or triggering a schedule or anything. literally anything), then it will break localtuya for sure. best is not letting the devices communicate outside once configured completely.

JohnMcLear commented 10 months ago

@yeowan I think we can all agree that is an awful user experience and detrimental to the uptake of HA/LocalTuya to expect users to go through this journey. LocalTuya is fundamentally broken if we think this is an acceptable UX. I appreciate your effort though, you clarified a lot and presented an option for people who are okay with a shoddy UX.

kernowkoi commented 10 months ago

Been stumbling over this issue for last couple of weeks. Gave up and used official Tuya HA integration. Which as a Newbie to HA is good enough for now. But will look at this again sometime

guyoliver commented 10 months ago

Hi, I'm new to the HA and the localTuya. I thought that the HA would resolve the issues with the Tuya App (cloud), but I saw that after the device got "reset" (long press or such), the localTuya not recognize it. I've played with the python and I think I managed to fix a workaround (I think the solution shall come from the state machine). You can find the changes here (link). please try it and share your feedback. if it works I will suggest it to the maintainer after I do some "code cleanup". thanks

jdukat commented 7 months ago

I've found this thread and went through all the hints on checking keys etc, but ultimately what worked was shutting down the Tuya smartphone app + disabling the background data usage + closing the Tuya cloud website + restart HA. Unavailable devices suddenly all worked. I had no need to downgrade the LocalTuya integration in HACS.

JohnMcLear commented 6 months ago

My solution was to flash all of my Tuya devices using tuya-cloudcutter and move everything over to ESPHome.

https://github.com/tuya-cloudcutter/tuya-cloudcutter

jdukat commented 6 months ago

Yep, looks like the right direction. After my above post last week, I already lost connection to my Tuya wifi device from HA and the only solution that helped was a full reboot of HA + manual refresh of LocalTuya settings. Completely unreliable.

guyoliver commented 6 months ago

You can see my changes in this link (I will update a few more changes I've made for stability). Those are working for me: https://github.com/rospogrigio/localtuya/issues/1117#issuecomment-1873457274

jdukat commented 6 months ago

How to download the LocalTuya extension with your changes into HA?

guyoliver commented 6 months ago

I need to check, no idea, maybe someone knows.

codyrally commented 2 months ago

Thank you! I closed the Tuya smart app on my phone (swiped back twice to exit) and all my Tuya devices came back to life within a minute on homeassistant! Otherwise I would have been chasing my tail reinstalling cr@p all over the place, saved me hours!

nzrutman commented 2 months ago

I just tried the 5.2.1 update after sticking with 4.0.2 for almost 2 years, and it seems to be working fine. Time to close this ticket?

RayLation commented 1 month ago

Everything has been very stable for a long while here. I used to have lots of problems of devices going unavailable intermittengly, but I can't remember the last time it happened now. Thanks !