Local Tuya Integration

Hello all, first time posting on here so be gentle.

I’ve been using HA for a while now and love it dearly when it works, when it doesn’t, I want to launch it out of a high window!! anyway my issue is when I try to integrate local Tuya into HA which seems to be the common theme on this thread.

I can get the device ID’s and the Local keys no problem I’ve done this a few times now as I’ve messed around with it enough to work out if you just create a new email address it’ll give you the free option again, anyway the problem occurs when I try to integrate my devices into the local Tuya integration. I’ve installed it using HACS no problem and its sits there waiting to configuration but when I go to add my devices to it firstly it doesn’t seem to discover any of my devices at all (I have over 60 of them) and when I try to add them manually entering the devices host (I.P address), Device ID and Local key it just scans for them then comes back after ages with “An unknown error has occurred”

Logger: async_upnp_client.ssdp
Source: components/ssdp/init.py:383
First occurred: 10:36:58 AM (11 occurrences)
Last logged: 10:56:58 AM

Received error: [Errno 101] Network unreachable, transport: <_SelectorDatagramTransport fd=21 read=polling write=<idle, bufsize=0>>, socket: <asyncio.TransportSocket fd=21, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=(‘0.0.0.0’, 55038)>

This was the last log entry when I tried to add one device manually.
what am I doing wrong?

Do you have any solution for this problem ???
I have added some entities but missmatched the datapoint - where I can change it ? which file to edit ???
Thanks for a quick Answer.

Dlete the device, and add again

1 Like

Hi.

I have recently installed localtuya via HACS on my HA which is running in a Docker container.

I have then added the integration and entered the details from my Tuya IoT development platform and used the details from a previous project.

When completed, no devices are showing as added, but when I download the diagnostics I can see that there are devices there:

{
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2023.1.5",
    "dev": false,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/London",
    "os_name": "Linux",
    "os_version": "4.4.18-g8bcbd8a-dirty",
    "run_as_root": true
  },
 [...]
    },
    "localtuya": {
      "version": "5.0.0",
      "requirements": []
    }
  },
  "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",
    "username": "localtuya",
    "no_cloud": false,
    "client_id": "rf7...ae5",
    "client_secret": "4c6...c23",
    "user_id": "eu1...HDQ",
    "devices": {},
    "updated_at": "1677494455104",
    "cloud_devices": {
      "xxxxxxxxx": {
        "active_time": 1671196254,
        "biz_type": 18,
        "category": "cz",
        "create_time": 1671196254,
        "icon": "smart/icon/ay1544008322541hl9iQ/1a92cf5799e23daf5a149159fbb7bffb.jpg",
        "id": "bf002026ebcba1f78a14yn",
        "ip": "x.x.x.x",
        "lat": "x",
        "local_key": "8dc...b34",
        "lon": "x",
        "model": "U1R BL-13A -JX",
        "name": "Tree Lights",
[..]

In total there are 22 devices listed.

However, I am also running the Tuya official integration.

Could this be causing a naming conflict which prevents the tuyalocal devices from being added.

I was hoping I could migrate from Tuya to tuyalocal device by device so I didn’t muck up too many of my automations at once while migrating.

go to integrations, click localtuya, click ADD device … then you should get/se a list of device in/from your tuya-iot project … in best case you just have to add-configure, as the integration now should get the local-key ( as it also seems in your diagnostics
But yes you have to ADD them all manually, 1 by 1

Migration, i dont know, never heard of such “easy” feature :slight_smile: , and i also doubt that you can have same device in 2 different integrations

I tried that and there weren’t any devices in that list.

The problem was that the Docker installation wasn’t on the same subnet as the house devices so didn’t auto discover - After a bit of tinkering I’ve resolved that, but only my WiFi devices are visible in the dropdown list.

Do I need to do something special to get my Zigbee TRVs working via 2 Tuya Zigbee hubs?

Sorry never even heard about Tuya Zigbee hub :slight_smile: … i also only have WIFI devices in LocalTuya

For your Zigbee hubs try Homekit_controller, i have my Aqara_hub there ( and this integration even “auto-discovered” my IKEA-Hub ) thou i ignored that, as i have that in IKEA-Integration

My hubs now show as a devices - So I’ll see how far I can get.

I’ll look at the HK Controller stuff as a fallback if I can’t get it working.

if it shows as a device, you should be able to add it, AND if your lucky with all the zigbee devices still stored/configured in the hub, if you need to type in a code, it’s usually an 8 digits code ( sometimes placed on the device, and most likely needs to be typed in HA in the form XXX-XX-XXX

Is anyone using this with say a Zigbee or Z-wave motion sensor to trigger a Tuya based bulb to turn on?

In my experience - even with it being local, the delay makes it less than useful.

Also - is there a way to set the color by an automation? I can do it fine from the device card in Home Assistant, but when I create an automation (say a simple time based one), All I can do us on/off/toggle or brightness.

Your hub is a so called gateway as it transfers WLAN to ZigBee. Gateways are not supported by Local Tuya. You can add the Gateway, but you won’t see any device connected to it and you won’t be able to control them.

When you have ZigBee devices, you don’t need Local Tuya at all. When using ZigBee the best thing is to integrate those device via ZHA (ZigBee Home Automation) an integration of HA itself, ConBee or Z2M (ZigBee2MQTT). You need a controller (I use at the moment a Sonoff Zigbee 3.0 USB Dongle Plus the ZBDongle-E, it is still Beta for Z2M most people use the ZBDongle-P variant of that dongle or the Conbee II, I had one, but the new ones work better for me) it is a ZigBee USB Stick. Best use it with a USB cable to get better results.
You will remove the devices from Tuya and integrate them into the ZigBee integration of your choice. I used first ZHA, but I have now switched to Z2M. Z2M is a little bit harder to setup but in my opinion the better integration. You can name devices after integration and the will have that name. If a device fails, you can delete the device, integrate a new device for it with the name of the old device and everything works as before. As the device and all entities will have the exact old name. :wink:

You can either use scenes, in a scene a set of devices with given parameters will be turned on or off or you use the parameter section under data when you turn it on or off. There you can send your RGB values etc. with the command. Problem you need to find out which parameters are supported by that device and you need to set the values manually.
I’m still trying to succeed here, but the values I send to my bulbs aren’t the one they should be and I can’t find the problem.
Why I’m not using a scene. Very easy I don’t want to turn on a given set of bulbs. I want to define a color and brightness the several different bulb will be turned on depending on time when they are triggered. That is impossible with a scene unless you define a scene for every bulb, every setting for the time wanted. So 3 different time zones, 3 different scenes for every single bulb and so you also need 3 automation. One for every time zone.
I want to use an automation, where the needed values will be used via variable (I use Node-Red, but it is also possible in YAML). So I just set the variable for the time zone and every bulb will turn on as wished. I just need one automation to set the variable and use the normal automation to turn on and off the bulbs. Unfortunately I’m only partially successful. Yes I can set the variable, I can turn on the bulbs with different set of parameters as wanted, but they don’t reflect the values they should have. :frowning:

You can add zigbee device behind a tuya based gateway.

see here for more info

This has been supported for a longtime now, its just that it wasnt really introduced in the documentation nor any easy way to add a zigbee device without going to the yamlgotchi route, after all autodiscovery do not work on any zigbee device that is connected behind a tuya gateway.

its the same case with tuya bluetooth gaateway which what I used for those cheap tuya bluetooth fingerbot. though I still need to use the tuya app to calibrate the finger how long it can press down.

1 Like

This sounds fantastic, did you manage to integrate Zigbee devices in Tuya Local?

I tried a quicktest from it way back then and yes, all of them works just fine, zigbee bulbs that is paired to tuya multigateway works fine. smartplugs also works fine.

Hi, how did you add the tuya fingerbot (bluetooth) that is connected to the tuya gateway? I can only add gateway to the Home Assistant. Can you send the configuration file?

Hi guys -

love your work, but not sure where to post a possible suggestion ?

I’ve tried to dig through the source code, to see how the plugin communicates with the TUYA cloud API.

It seems that TUYA have closed down the access to their “API” and now you get a month to do it then, you are in limbo land… I have several devices I would love to add, but now impossible.

I have even managed to use a “Rooted” Android device to get the 'Local Key", but it seems your plugin still tries to access the cloud API (which would mean you will be getting the obligatory “your Cloud API access has expired”)

I was digging around in the IoT interface, and have found a that if you use another “API” call it still is accessible…

if you use this one instead it works still

hopefully this can help bring things back on line for alot of people that are now experiencing “expiry of account”

Has your IoT expired by any chances (older than a month) ?

This has been really difficult for me to get through but I am closer. This is a RainPoint hub/outlet and hose controlller. When configuring, I get to configure entity and it is an outlet but it is failing to add the entity with a generic “Unknown error occurred”. I tried individually adding them. You cannot really make many choices in this. I tried it with and without the power options but no dice. Any help would be greatly appreciated and thank you in advance.

Local Tuya apologies new to this after the recent outage, i seem to have managed to follow the instruction on how to get the local key and the id etc only bit i cant fathom is the host* field in the menu. i assume that this is the local IP however, as these devices dont show up by name on the router DHCP is there an easy way to get their IP by device ID or some other local search?

To be able to address those devices by name you need a local DNS-Server which is able to add own names you define.
In HA you can use for example AddGuard Home to do so. Your DHCP needs to be changed to give your devices the HA device as DNS.
In AddGuard Home you can add own devices with the name you like. Additionally AddGuard Home can block malicious traffic by not resolving those domain names.

You devices need to have fixed IP-addresses for that, but you should give them fixed IP addresses for Local Tuya anyway.