Tuya local

If you check the git hub https://github.com/rospogrigio/localtuya it has common configuration settings. Hope fully this will work for you, it did for me.

 - platform: light
        friendly_name: Device Light
        id: 4 # Usually 1 or 20
        color_mode: 21 # Optional, usually 2 or 21, default: "none"
        brightness: 22 # Optional, usually 3 or 22, default: "none"
        color_temp: 23 # Optional, usually 4 or 23, default: "none"
        color: 24 # Optional, usually 5 (RGB_HSV) or 24 (HSV), default: "none"
        brightness_lower: 29 # Optional, usually 0 or 29, default: 29
        brightness_upper: 1000 # Optional, usually 255 or 1000, default: 1000
        color_temp_min_kelvin: 2700 # Optional, default: 2700
        color_temp_max_kelvin: 6500 # Optional, default: 6500
        scene: 25 # Optional, usually 6 (RGB_HSV) or 25 (HSV), default: "none"
        music_mode: False # Optional, some use internal mic, others, phone mic. Only internal mic is supported, default: "False"
4 Likes

Thanks. I used the integration to set it up. The led strip has the numbers 20, 21, 24, but it doesn’t have the numbers 22,23. It is working now but not completely. If I try to change manually the brightness in color mode the integration stops.

I am with the same error. Do you have any updates about it?

try this

- host: xxxx.xxx.xxx.xxx
  device_id: xxxx
  local_key: xxxx
  friendly_name: Tuya tv
  protocol_version: "3.3"
  entities:
    - platform: cover
      friendly_name: NAME
      id: 1 # this is what open_close_stop use, not sure if you had this as 2 or something else
      commands_set: open_close_stop
      positioning_mode: position
      position_inverted: true
      current_position_dp: 2
      set_position_dp: 2 
1 Like

Gunnar I am still having problem. It is hard…
The arrows UP and Down are disabled. I´ve tried to change the actual position, and the problem still persists.

image

ohh… do you have anything in logs?

Can anyone tell me why, after adding the Local Tuya integration via HACS (and restarting HA), I still don’t have it in the drop-down under Integrations to add it?

Do you see the folder under /config/custom_components ?

It’s there now (didn’t do anything, just finally showed up). Now my issue is that all the tutorials on how/where to obtain the local key are outdated. I’ve been digging around on the Tuya site for hours and can’t figure out how to get this info. Does anyone have an accurate set of instructions?

Just follow the official Tuya integration guide @bkr1969, the process is no different. That has all that information - then you just pivot to local Tuya after you set up everything in the Dev Platform rather than using the official integration.

GUIDE LINK

I have 4 bulbs under localtuya integration working fine until today, one of them showing unavailable. Tried reboot HA, remove this bulb from localtuya and then add it back, reboot HA, but still showing unavailable. the bulb itself works fine since I can still turn on/off using smartlife app. Other 3 bulbs worked both on localtuya and smartlife. Anyone know what could be wrong and how to fix it?

PS: more info, when I turn it on/off from smartlife, it did sync the status to HA, however I can’t control the bulb from HA. Below are the error log(where 192.168.x.xxx is the IP of the trouble bulb):

2021-11-14 20:50:32 ERROR (MainThread) [custom_components.localtuya.common] [lig...n01] Connect to 192.168.x.xxx failed
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/common.py", line 149, in _make_connection
    status = await self._interface.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

Thanks.

Note that whenever a Tuya device gets re-paired through the Smart Life-app (you did not mention whether you did that) the device will get a new key which means you have to aquire the new key from your Tuya account and change it with localtuya accordingly.

Thanks Tamsy for the reply. I didn’t repair on smartlife so the key is same (double checked).
From the log it seems connection to the IP of the bulb is timeout.

Still don’t know how to fix this. When I removed this bulb again and retry to re-add it, got the error " Entity with this ID has already been configured". Did a search on google but didn’t find meaningful discussion/solution.

  1. Go to:
    Home Assistant → Settings → Integrations → LocalTuya Integration

  2. Choose/click the bulb in question.

  3. Click on the hamburger menu to the lower right (three vertical dots).

  4. Choose “Delete”.

  5. Restart Home Assistant.

  6. Home Assistant → Settings → Integrations → Add Integration

  7. Choose LocalTuya Integration.

  8. Configure the bulb from scratch.

That’s exactly what I did, and when configuring the bulb as entity id light.sn03, I got the error " Entity with this ID has already been configured". No error in the log.
Then I went to the entities page to search this entity and didn’t find it. It does show “10 hidden entity”,


when I click “clear”, it does show this entity still exists and status is unavailable.
Then I went back to integration page and noticed there are hidden integrations!
image
Sure enough there is another localtuya integration that was hidden and disabled! I deleted it and then repeat the steps to add it back, worked!

It seems that by default disabled entities and integrations are hidden, which I didn’t notice at the beginning, which took me long time to figure out :frowning:

So it does work now (that particular bulb)? :thinking:

Yes it is working now :slight_smile:

The issue was that after I removed bulb from the integration, it disappeared from the integration page, but actually it didn’t removed it, it was moved to another localtuya integration and was hidden by default, which I haven’t experienced in the past. I think I might clicked “disable” when I actually tried to “delete” it, these two options are together.

Thanks.

I have a question about local tuya. I have a bulb that is far away from my router and barely gets signal. Sometimes it connects and sometimes it disconnects.

I have a wifi extender in the same room with the bulb. With the official integration the bulb gets the wifi you set in the smart life app but with local tuya how do you know on which wifi it’s connected?

Thanks

Local tuya doesn’t fully replace the smart life app. You still need to configure and connect the tuya device to your network using the smartlife app first before you can control it with local tuya. When the device is “paired” to the smartlife app, it connects to your wifi network you specify in the app, then local security keys are created so the app can control the device when they’re on the same wifi network without routing every command through the Tuya server.

Local tuya uses these local keys created by the smartlife app pairing process for local control. If you remove the device from the smartlife app these keys will change and local tuya will stop working.

Some will attempt to firewall off the devices after pairing with the smartlife app, so they stop communicating with the tuya server. There are posts higher in the thread discussing that if you search. I personally don’t firewall them off since I still use the tuya skill for Alexa control.