Local Tuya - Control Tuya devices locally (Fork from localtuya)

Well the issue here is that not all your devices on cloud are within the same network so that doesn’t count as locally discovered devices.

Yes


If the devices are discovered then it will save you a ton of time on setup e.g. “configuring all discovered devices at once if possible” however your hub is empty of devices you will need to configure them manually ← at least filling device connection info.

1 Like

Got it, thank you. I thought the cloudAPI would bypass the VLAN requirement and that was the source of my trouble!

I started the manual configuration and eventually got all the devices entered.

There was an odd bug? with a couple of switches, where they initially refused to connect and be registered. After querying the device, it returned with an error, but the entry form “Device Name” had a different name than the one I had originally typed. I eventually figured out that if I submitted immediately without changing anything, the entry would be accepted.

If I tried changing anything on the entry form the first time it returned with the error, such as the name back to what I wanted, it would never be accepted and I would have to exit out to restart the process.

Regardless, thank you so much again for maintaining this fork!

This isn’t a bug, This is a feature I added before to automatically help/fix input mistakes for users with devices on different subnets or so. Basically, if you enter the device ID correctly, the rest of the fields will be filled automatically from the cloud list, except for IP and Protocol version

Example

1 Like

That’s very cool and a great demo. Wish I had known about it as it may have saved me some time! Is it in the tutorial documentation?

@umu_ugg
I’ve got an oddball device with a seemingly undocumented DPID of 101. From the Tuya API explorer:

      {
        "code": "m0",
        "custom_name": "",
        "dp_id": 101,
        "time": 1733103333231,
        "type": "string",
        "value": "00000301ff06ff0000ffff0000ff0000ffff0000ffff00ff"
      },

It’s a string of Christmas lights (specifically “Brizled/Brizlabs Smart RGB String Lights”). This particular endpoint encodes the lighting pattern of the lights, where when work_mode is scene, the pattern, color selections, speed, and direction (forward/reverse) are all encoded into the value. It’s all pretty straightforward, I’m just not sure how I would go about adding all that into integration. I could open an issue in Github and we could hash it out there?

Nope, If were in docs then it would goes under TIPS which it not an existed category atm.

You could add it as custom scenes, configure -> reconfigure an existing device -> choose your light on the Light entity configuration step in “custom scenes” box add your scenes e.g.

00000301ff06ff0000ffff0000ff0000ffff0000ffff00ff: Name of the scene
000e0d0000000000000000c80000: Night

and so on, this way it will replace the default scenes by the one you inserted.

Has anyone had any luck with RF Remote transmitters? I have a couple of IR+RF remote controllers added to my LocalTuya integration, and I have successfully learned and use IR commands - but RF commands don’t seem to get “learned” correctly. I can learn them in the Tuya app, but that doesn’t help me use them in LocalTuya.

Is there any way to see what commands (if any) are being received by the Home Assistant “Learn Command” action?

1 Like

I have had the same experience. I have two different Tuya branded IR/RF transmitters. IR learns and sends correctly, RF won’t learn. There was (or maybe still is) a branch with slightly different RF learn code, makes no difference tho. I sent my logs to the dev and he said he still couldn’t figure it out, and I guess he doesn’t have one of those devices to test himself. I’d love to make my RF devices local and no longer have to use the Tuya scenes hack. These are my only remaining Tuya devices where I still have to use the built-in Tuya integration.

Currently, RF isn’t supported. I tried to add it without having the actual RF remote, but I failed. I haven’t needed to buy the RF remote for testing yet

I tested it with a RF remote and no code is being learned.
I looked up the actual file where it’s supposed to save the learned code but it’s just an empty string.

Tried with a Tuya RF controller. Everything works fine using Tuya’s application though.

Anybody knows if there is any plans to get RF supported in LocalTuya too?

Thanks

Hi
lost some device out of 20. used to repair (like local code of the device changed) but that time nothing worked. any tips?,


Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.localtuya.coordinator
Source: custom_components/localtuya/core/pytuya/__init__.py:306
intégration: Local Tuya (documentation, problèmes)
S'est produit pour la première fois: 21:45:40 (5 occurrences)
Dernier enregistrement: 21:45:40

[166...7a2 - Volet salle de jeux droit] Connection failed: [Errno 113] Host is unreachable ('10.0.0.61', '6668')
[183...9a5 - Smart Socket] Connection failed: [Errno 113] Host is unreachable ('10.0.0.84', '6668')
[404...b8c - Volet gauche] Connection failed: [Errno 113] Host is unreachable ('10.0.0.68', '6668')
[404...174 - Volet SAM] Connection failed: [Errno 113] Host is unreachable ('10.0.0.64', '6668')
[404...f63 - Volet droit] Connection failed: [Errno 113] Host is unreachable ('10.0.0.69', '6668')

Hi everyone! I am struggling to use the “learn command” service with a IR remote. I’ve added the device and it seems fine, but when I try to learn the commands for my fan, there is an error:

Falha ao executar a ação remote.learn_command . Failed to learn: Toggle

The logs did not help me, unfortunately.

2024-12-25 20:31:59.516 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error for call_service at pos 1: Failed to learn: Toggle

My device is from Positivo and it works fine with the Smart Life app. Has anyone faced this issue? How did you fix it?
Thank you!

Switched to this fork and working fine without having to reconfigure everything! Tnx for keeping it working!

Thanks for this!

I was dreading making the switch and having to reconfigure everything - but it all worked out well!

+1 for the fork! I was having issues with the integration after the latest update to 2025.1.0, as none of my lamps would be online anymore. Moreover, I also had a couple new spotlights, which couldn’t be setup (probably due to protocol 3.5). With the fork, everything is working perfectly again and I could also setup my new spotlights. Awesome work! For info, I simply dirty updated the integration with the new repo, no reconfig needed.

1 Like

I have a Gratkit dryer V2. This integration recognises the following entities:

image

However the device supports many more, as seen in tuya-local/custom_components/tuya_local/devices/gratkit_filament_dryer.yaml at cc374f213ad2796296e556e950ddf30884620c33 · make-all/tuya-local · GitHub

How can I easily import all those devices without having to manually repeat the “add entity” procedure for each one?

It’s not clear to me how to set the mapping for DPS=103,105,106.

1 Like

I found this custom integration when HA 2025.1 broke the existing localtuya integration. All I can say is: wow! In addition to surviving the upgrade to HA 2025.1, the one-shot addition of all Tuya devices is a godsend (I did have to run it twice; first time picked up about half the devices) AND the automatic configuration of each device’s entities is a huge time-saver. (I was left only with the tasks of customizing names and icons of a few of these, and adding labels.) Great work!

1 Like

Hi,

I want to start using this integration and after install it I have to enter same authentication data.
I don’t know what to fill in and went to the documentation.
But the documentation pages have broken links how to set it up.
Can someone please tell me where I can find this information?

Thanks a lot!

I am struggling with integrating a button correctly so that each click does something and not only a state change. Example: the button is setup by local tuya as followed (copied from core.entity_registry) but this leads to a situation where e.g. a single click on button 1 sets the switch of button 1 to “single click”. If I now e.g. click on button 2 and want to single click on button 1 again, the log of the device doesn’t show any changes since the state is already on “single click”

      {"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Single click","Double click","Long Press"]},"config_entry_id":"01JHTEETVGSF8AX02Q2J1ZAXV6","created_at":"2025-01-17T15:27:51.756600+00:00","device_class":null,"device_id":"ABCDEF","disabled_by":null,"entity_category":"config","entity_id":"select.wohnzimmer_couch_switch_switch_1","hidden_by":null,"icon":null,"id":"ABCDEF","has_entity_name":true,"labels":[],"modified_at":"2025-01-17T15:35:32.731029+00:00","name":null,"options":{"cloud.alexa":{"should_expose":false},"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":"mdi:square-outline","original_name":"Switch 1","platform":"localtuya","supported_features":0,"translation_key":null,"unique_id":"local_ABCDEF","previous_unique_id":null,"unit_of_measurement":null},

Is there a way to configure this in a way that each click on a button triggers something and not only when a state change from e.g. single click to double click ist registred?

The standard status set from Tuya API is:

switch1_value	Enum	
{
  "range": [
    "single_click",
    "double_click",
    "long_press"
  ]
}
switch2_value	Enum	
{
  "range": [
    "single_click",
    "double_click",
    "long_press"
  ]
}
switch3_value	Enum	
{
  "range": [
    "single_click",
    "double_click",
    "long_press"
  ]
}
switch4_value	Enum	
{
  "range": [
    "single_click",
    "double_click",
    "long_press"
  ]
}
battery_percentage	Integer	
{
  "unit": "%",
  "min": 0,
  "max": 100,
  "scale": 0,
  "step": 1
}

You will find Client ID, Client secret and User ID in the Tuya Developer Portal.

Client ID and Client secret: in tab “Overview”
User ID: Click on Devices → Link App Account; you will then finde UID, which is the user id