Local Tuya Integration

Hello,
I have problem configuring local tuya.
I have cloud Tuya integration with 5 termostatic valves running, working OK.
They are connected to wireless Tuya mini-gateway, which connects to wifi, so tuya has its own address range.
I can set up a local-tuya integration (first screen) successfully, but when adding devices, it sees only gateway and I have no clue, how to add custom device.

Please any help
Jan

Tuya hub should be off if you want to connect it with HA. It’s a wifi or zigbee connection?

Hello nsacras,
now i’m on tuya integration and devices are hooked to the wifi zigbee hub.
I have no supported zigbee usb device localy on homeassistant running “Pi-C”.
If that is necessary, i will stick to the chinese cloud, hope they dont harm my valves"-)

thanks
SLMQ

Hi, I have entered my credential in local Tuya taken from my Cloaud API account

Then I am trying to add a device.
image

It is automatically discovered
image
But I still need to enter the local key !


I tried to follow the guide to recover the local key but that’s not working.
Neither looking into folders in my mobile phone nor trying to track the request using the sniffing tool.

Is there an easiest way to retrieve it ?

1 Like

I was able to pull a few of the local keys from the iot.tuya.com a few months back, but I wanted to add a new one today and it seems that Tuya is now charging for using the cloud service to pull the local keys. Haven’t found another way to do it yet :frowning_face:

I found my local key today on iot.tuya.com

Cloud → API Explorer → Smart Home Device System → Device Management → Get Device Details
see screenshot

If you run HA Supervised or Container (or any other Linux based rig) you can also do;

sudo npm i @tuyapi/cli -g

After tuyapi/cli is installed to optain your keys run from cli:

sudo tuya-cli wizard

a. You will be prompted to provide your your API key from tuya.com.
[Enter]
b. Now you have to provide your API secret from tuya.com.
[Enter]
c. Lastly provide a ‘virtual ID’ of a device currently registered in the app
[Enter]

Now you’ll get a list of all currently active tuya based devices including their names, IDs and keys displayed on the console.

i.e:

[
  {
    name: 'Lichtschalter Wohnzimmer OR',
    id: '[some-string]',
    key: '[some-string]'
  },
  {
    name: 'Lichtschalter Gästezimmer',
    id: '[some-string]',
    key: '[some-string]'
  },
  {
    name: 'Lichtschalter Diele 1',
    id: '[some-string]',
    key: '[some-string]'
  }
]

Using sudo tuya-cli wizard is much more comfortable and faster compared to having to login to your tuya account through your web browser and search through your devices for the valid keys.

1 Like

Thanks for these information.
I have now my local key and I configured local tuya with it. But the integration of my device (Konyks plug with power monitoring) is not providing me power measurements. It looks like the right DPs are not discovered by local tuya. I have only DPs 1, 2 and 7. And 2 and 7 are always 0!
But In Tuya IoT platform I can see power measurement values and also inside “Smart Life”.
So strange !

I have a problem adding devices to Local Tuya in Home Assistant. I am 99% certain that I have the correct ID’s and secret but I am getting an Unknown Error message.

Can any one tell me where I am going wrong from this ?

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/pytuya/init.py:704
Integration: LocalTuya integration (documentation, issues)
First occurred: 13:15:26 (3 occurrences)
Last logged: 13:20:50

Unexpected exception

Traceback (most recent call last): File “/config/custom_components/localtuya/config_flow.py”, line 580, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File “/config/custom_components/localtuya/config_flow.py”, line 245, in validate_input interface = await pytuya.connect( File “/config/custom_components/localtuya/pytuya/init.py”, line 704, in connect _, protocol = await loop.create_connection( File “/usr/local/lib/python3.10/asyncio/base_events.py”, line 1064, in create_connection raise exceptions[0] File “/usr/local/lib/python3.10/asyncio/base_events.py”, line 1049, in create_connection sock = await self._connect_sock( File “/usr/local/lib/python3.10/asyncio/base_events.py”, line 960, in _connect_sock await self.sock_connect(sock, address) File “/usr/local/lib/python3.10/asyncio/selector_events.py”, line 500, in sock_connect return await fut File “/usr/local/lib/python3.10/asyncio/selector_events.py”, line 535, in _sock_connect_cb raise OSError(err, f’Connect call failed {address}’) OSError: [Errno 113] Connect call failed (‘192.168.1.159’, 6668)

Oh and the local key using the Tuya API Explorer to recover it.

Try to reload tuya integration or reinstall it.
It seems that some connection issue is the major reason for that error.

1 Like

Hey friends, this is one of my favorite integrations because I was dumb enough to buy 45 Tuya wifi overhead lights.

I’m getting a Failed to Set DP error. Everything worked fine for about 3-5 months until recently (maybe after an update?)

Now, some of my devices disconnect and become unavailable until I restart HASS or sometimes reload LocalTuya and then restart HASS. Here’s the error:

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:259 
Integration: LocalTuya (documentation, issues) 
First occurred: 2:35:47 AM (88 occurrences) 
Last logged: 3:08:11 AM

[eb0...8jz] Failed to set DPs {20: True, 22: 40, 21: 'white', 23: 230}
[eb4...m7m] Failed to set DPs {1: True, 3: 46, 2: 'white'}
[eb6...1yb] Failed to set DPs {1: True, 3: 46, 2: 'white'}
[ebd...v1m] Failed to set DPs {1: True, 3: 46, 2: 'white'}
[ebe...7ha] Failed to set DPs {20: True, 22: 46, 21: 'white'}
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, 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.10/asyncio/tasks.py", line 456, in wait_for
    return 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/common.py", line 332, in set_dps
    await self._interface.set_dps(states)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 557, in set_dps
    return await self.exchange(SET, dps)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 486, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 259, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

P.S. Watching closely, I noticed that sometimes the lights just go unavailable for a few seconds after I change a scene, then come back – until at some point they just won’t come back. (I.e. I change the scene, some of the lights go offline for about 5 seconds, but then can be controlled again.)

I don’t mind paying. But it’s $2500/mo USD

…which is a rip-off out of touch with reality :unamused:

I seem to still be getting these errors. It’s really frustrating since I had it all working fine about 3-4 weeks ago. Now my entire house lighting is broken unless I restart HA every few hours.

Any ideas at all?

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:259 
Integration: LocalTuya (documentation, issues) 
First occurred: 1:29:35 AM (183 occurrences) 
Last logged: 12:41:30 PM

[eb6...1yb] Failed to set DPs {3: 238, 5: '000e3a00e1ffee', 2: 'colour'}
[ebd...v1m] Failed to set DPs {5: '000e3a00e1ffee', 2: 'colour'}
[ebe...7ha] Failed to set DPs {24: '00e103e800ee', 21: 'colour'}
[eb8...xio] Failed to set DPs {5: '3a000e0159ffee', 2: 'colour'}
[ebc...2eh] Failed to set DPs {3: 238, 5: '3a000e0159ffee', 2: 'colour'}
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, 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.10/asyncio/tasks.py", line 456, in wait_for
    return 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/common.py", line 320, in set_dp
    await self._interface.set_dp(state, dp_index)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 553, in set_dp
    return await self.exchange(SET, {str(dp_index): value})
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 486, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 259, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

With 45 newly integrated wifi-lights, and most likely another huge amount of other wifi-devices, Zigbee device and “Disturbing” devices, i think i would start to look over my wifi-setting/setup, i doubt HA have problems handling the requests/communication, most likely you Router, or some interference on the 2.4ghz band
Lots of things could cause interference on 2.4ghz, also look into which Channels, the different integrations/device communicate over

December 2022 Updated steps:

Assuming device is added to Tuya Smart or SmartLife app already

  1. Go to https://iot.tuya.com/ and creat a project on cloud tab (on a computer). Make sure the data center you choose corresponds to the region you used to sign in to the app (for US, use West America Data Center).
  2. Go to Devices > Link Tuya App Account, click Add App Account, then from the Tuya Smart or SmartLife app (on mobile device) go to Me/Profile, click the scan QR code button in the top right, and scan the QR code, accept defaults
  3. Now under the Devices list, you should see your device(s). Copy the Device ID you want.
  4. Go to “Service API” tab at top, it will prompt you to authorize (or click “Go to Authorize”). Select IoT Core and authorize it.
  5. From sidebar menu go to Cloud > API Explorer Menu, and choose “Smart Home Device System” > “Device Management” > “Get Device Details”
  6. Insert the “Device ID” from step 3 and submit request
  7. At right you will see a list of details and you will find the requested local key
  8. Insert local key and device ID where needed in HA

After having used local tuya for a while, the sober reality is it is REALLY buggy. I have hit my head on the wall too many times troubleshooting these same issues. Until we get a lot of these resolved, I’ve switched back to the default tuya integration. There is a little more lag at times, but atleast I don’t have connection timeouts and resets every 2 weeks. Im hoping that eventually tuya devices will support homekit and/or matter and then we wont have to worry anymore.

Hello everybody and Happy New Year.

I am new in the home assistant and i would like your support.
I am using Local Tuya version 4.1.1 on a HA core

I’ve added a tuya device and i need to add additional entities. I cannot find the way to do it. It gives me the option to delete an entity but not to add one.

Also if i try to add another device and i make a mistake with an entity then i do not have the choise of deleting the new device. The only choise that i have is to delete the ntegration and rebuild the all devices.

Is there a simple way to resolve this issue or be able to edit the config file of the local tuya?
Thank you in advance

I have two outdoor BT lights that are connected to a Calex BT Mesh Gateway.

I can see and control the two lights via the Tuya app and can see them in the IoT platform website.

Local Tuya sees the BT Mesh and I’ve got the local key from the website, but I cannot add it to HA:

Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists.

Has anybody setup Local Tuya with a BT Mesh?