Tuya local

@henry8866, As far as i know each brand an type has a different configuration. what worked for me was to use the tuya app itself to change a single value (only color from red to green) an then take a look at this list to see which entry changed. this way you can figure out all of the settings required.

but since you asked here is a screenshot of a color bulb:

2 Likes

Thanks. The dropdown values are different in my installation. These entries start with 20, 21 etc on my case. I’ll need to try it out.

I have just started using homeassistant after having used Domoticz for years.

My first project was to install LocalTuya and connect a first Led Filament lightbulb (A60GOLD) and it all worked fine BUT, for some reason I can’t find a way to change the white mode and brightness in Homeassistant while I can when using the Smartlife app.

Is this even possible and am I just looking in the wrong direction?

Thanks,
TechNoob

Hi All,

I’ve introduced Number and Select entity types to support Tuya devices that don’t fit neatly with the current entity types.

I primarily introduced as I’ve got an Arlec Smart Security Light (MAL315HA) that doesn’t have a traditional on/off mode. It’s DPS config represents the following:

101 - Mode: mode_auto/mode_on/mode_off <Select>
102 - Light State: true/false <Binary Sensor Only>
103 - Motion Sensitivity: [0-4] <Number>
104 - Light Timeout when in Auto mode (secs) <Number>
105 - Light Cutout Threshold [0-3900] <Number>
106 - Reset to Auto after 1 hr in Manual On: True/False <Switch>

The Number entity type is pretty self explanatory. Has configuration for maximum/minimum values.

The Select entity type allows configuring of values to send through to a DP. In addition, I’ve added a User friendly mapping, so (as an example) that you can have “On” as the setting for the Select, which maps to “mode_on” as the value being sent to the device.

So in the Smart Security Light Example, I have setup a Select against DPS: 101 with the following:

  • Name: Mode
  • Valid Entries: mode_off;mode_on;mode_auto
  • User Friendly Options: Off;On;Auto

If anyone is interested in giving it a try, the PR is #596. @Gabrie - This may assist with the light you were trying to setup

Hi all
I just installed a Tuya RGB Led Strip. I have added it to HA and I can turn it on-off but I can’t change the colors. Does anybody knows how I can make it work. The options are below

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.