LocalTuya entity is showing as unavailable

Are there any LocalTuya guru’s able to help me with my LocalTuya integration. I have successfully added a switch to my Smart Life (Tuya) app, which I can turn on and off. I’ve followed all the instructions on the wiki on how to obtain the local_key and device_id for my switch. I’m using these values with the LocalTuya integration…

But the entity for the switch is “unavailable” in HA.

I have the debugging turned on which is outputting the following:

2021-01-30 22:03:17 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2021-01-30 22:03:47 DEBUG (MainThread) [custom_components.localtuya.switch] [bf9...auy] Adding switch.main_light with configuration: OrderedDict([('platform', 'switch'), ('friendly_name', 'Main Switch'), ('id', 1)])

I’m not entirely sure if during the setup, i might be choosing the wrong settings? For ID, I am choosing 1. For Friendly Name, I am typing Main Switch, and I’m leaving the other field blank as I understand these to be optional…

I hope that is enough info to warrant a response, whether that be suggestions, or what to try next.

Any guidance would be appreciated.

Thanks.

1 Like

I have the same issue. All my devices are configured in yaml

I got it working by uninstalling the integration, then uninstalling it from HACS, and then restarting HA. I then downloaded the localtuya 3.1.0 release and put it in my custom_components folder and restarted HA again. Then I went into the integration via the UI and configured it as normal, and it worked instantly!

I read in the issues section on their wiki that the integration fails to reload once booted up, and a fix was to call the service localtuya.reload from an automation at startup. But I’m happy to use 3.1.0 for now and hopefully they’ll fix 3.2.0 at some point.

1 Like

Hi,

I am running 3.2 and my devices are unavailable after HA restart.

My question is what is the correct usage of the LocalTuya integration: reload service

If I click on the call service nothing happens, do I have to enter any other parameter / service data in the yaml?

If I call the reload from the integration itself it works but i have to do each plug one by one.

image
Thanks,

1 Like

@MarkB1
Version 3.2.2 has been released - I’ve read the commit notes for v3.2.2 and the periodic connection retries that the latest version speaks of are explicitly there to fix and address the problems previously reported (that we were experiencing with the dropped devices, and calling the localtuya.reload service being the workaround), so it looks like this is a good version to move to. I’ll probably upgrade LocalTuya and test it out this week.

I’m getting the same problem here, device shows unavailable, check my wifi log and it has been online for over 6 days but suddenly 30 minutes ago it’s unavailable.

If I open the tuya smart app and toggle the devices they immediately return available on home assistant. It’s like they are going into a sleep mode but the timing is random.

I’ve resolved the issue by using automatization on homeassistant - start trigger with action homeassistant.reload_config_entry for a group of Tuya devices.
Or “unavailable” state trigger for Tuya devices can be also used.

1 Like

Could you share your automation with the community? I have the same issue. Randomly one of a group of devices fall offline.

As I was losing devices only when HA restart, it was the trigger.
It’s very simple:

alias: AUTO Local Tuya reconnect
description: ''
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: homeassistant.reload_config_entry
    target:
      entity_id: group.all_lights
mode: single

And in ‘groups.yaml’ something like that:

all_lights:
    name: All lights
    icon: mdi:lightbulb-group
    entities:
        - switch.AAA
        - light.xiaomi_gateway_light
        - light.BBB
        - switch.CCC
        - ...
4 Likes

This dont seem to fix it .

i even tried to execute the localtuya.reload directly from developer tools - services

Were you able to resolve this issue ?

Also receiving this issue now after attempting to set up. Thought I’d set the entity up incorrectly, but appears to be something with either Tuya or this integration.

Hello

I had to recheck the local key from the tuya API page, and edit this in the local HA config.

Saddly I have the same problem. PowerStrip and plug become unavailable every time after HA restart. I am quite sure that this is “localTuya” integration problem because powerStrip & plug are working via default app.

Just for info. It works for me now. I redownload master version of tuyaLocal via HACS (did not work). Than I have reinstall latest version 3.2.4 and create startup automation script as mention above.

I have no clue what happened and why it works now. Script didnt’t help before. I will not do anything now, because it works. :slight_smile: