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

Hello, So I have been using localtuya since 1 year or so, But I was struggling a little bit due to instability and loading, issues. I tried to make PRs adding features and fixes but it seems the upstream dev is busy IRL due to personal issues, I didn’t have an experiences in python but localtuya is an important integration in my setup. While I was updating the integration I actually started to understand how HA and python works so I decided to keep updating the fork at least for my use in no time I saw some people started using my fork so I decided to share it with you guys.
Before someone ask: The reason I stick with this integration is due to the approach of both integrations localtuya is way lighter on HA and faster.

What’s the main features does this fork have?

  1. Stability! no crashes or loading fails
  2. Auto configure Devices if Cloud API account is set up.
  3. Supports protocol 3.5 discoverable.
  4. Support sub-devices devices that works through gateways e.g. ZigBee and BLE.
    ^ Sub Devices automatically discoverable if Cloud API account is set up.
  5. Configure devices with templates ready-config yaml file shareable.
    ^ Configured devices are exportable through config-flow.
  6. Platforms humidifers, button and siren are supported.
  7. Supports Multi-Hubs aka multi accounts.
  8. Other features may not be important to mention like entity category, icons, devices classes and HA Events etc…

IR Remote:

CREDITS:
All thanks goes to the upstream dev rospogrigio, This fork wouldn’t be existed without him



Installation:

HACS

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Or add the repository manually to HACS

  1. Open HACS and navigate to Integrations Section.
  2. Open the Overflow Menu (⋮) in the top right corner and click on Custom repositories.
  3. Paste https://github.com/xZetsubou/localtuya into the input field and select Integration from the category dropdown then click ADD.
  4. Now the integration should be added search in for it and install it!.

Manual installation:

  1. Download the latest version from GitHub releases extract the file.
  2. Copy custom_components directory into your HA config directory.

NOTES:

  • It’s possible to install this fork integration above upstream integration. But reverting back may not works as it should, because devices config values type aren’t the same.

  • Reverting back to upstream and keeping the devices data isn’t possible after the 3.2.4 update.

12 Likes

thanks for sharing this, I hope one day, these can be merged into upstream

I have the existing Local Tuya, is there a way to run these side by side to compare?
I don’t want to break something that’s currently working

Running both integration at the same in the same HA environment is not possible.

I would say the only way to do that is by taking backup copy for .storage and custom_components directories or do HA Backup.

1 Like

I guess you actually gave me a good idea, I’ve been looking to use my raspberry pi 3 for something.

Btw, i installed this fork, restarted home assistant and everything is still working fine without interruption.

1 Like

Meaning you left the devices installed from the previous HACS integration? And the devices pulled from the new forked repo.

Yes, the fork posted on the first message is using the same data model from the previous one so after installing the new one, all is continue to work perfectly.

1 Like

My feature request goes here;
All looks great but can i just give my cloud account credentials and let the integration setup all existing devices automatically for me without any intervention? It can generate a report at the end such as: 5 devices found in cloud. 4 of them supported and their sensors are automatically created. 1 of them is not supported, try manual configuration

This kind of step would ease initial onboarding for beginner users.

The auto configure feature just added on last update I don’t know how effective it is since I haven’t tested it on other then my devices. Don’t know if it will work fine for others it needs to be tested more. Mass auto configure was a plan but since it require more steps to validate devices are usable locally, I thought it can be done later after making sure that it works as it should and integration is stable.

1 Like

It looks like GitHub - rospogrigio/localtuya: local handling for Tuya devices is active again - has commits as recent as September 22 2023 - and that’s what HACS references.

GitHub - xZetsubou/hass-localtuya: 🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya" says:

This branch is 110 commits ahead, 14 commits behind rospogrigio:master

But there are lots of open issues and pull requests on the rospogrigio repo.

It looks like a lot of work to maybe get some “smart” bulbs I purchased (for a good price) to work offline in HA.

Have any of you recently added any new Tuya devices using localtuya (via any repo)?

This branch is 110 commits ahead, 14 commits behind rospogrigio:master

The upstream repo isn’t literally dead, it gets updates from time to time…

It looks like a lot of work to maybe get some “smart” bulbs I purchased (for a good price) to work offline in HA
Have any of you recently added any new Tuya devices using localtuya (via any repo)?

I don’t understand what do you mean by new Tuya devices since even new tuya devices can come with old firmware, I think many bulbs are running on protocol 3.5 I’m currently using one.

Then I mean devices that might have newer firmware and that have not have been used with home-assistant before, and that need some sort of setup prior to use in HA.

I was also wondering if the method needed to get a Tuya account has changed.

But I’ve given up on these devices since I’d only use 2 or 3 and there’s no manufacturer supported method I can find to get them working in non-local mode.

Tuya account isn’t really needed to use localtuya.

If you can tell me the devices brands or purchase link I might have a clue of what you’re talking about.

Why do you say “isnt’ really needed”. Is a Tuya account needed for localtuya or not?

I have some DAYBETTER bulbs that are supposed to work the same as Tuya devices. They were $40 for 10, so thought I’d try them.

There are no clear steps on how to use them in local mode.

But I said, I’m returning them. I plan to try some bulbs that run Tasmota as there are a good number of vendors and users of Tasmota.

Localtuya uses your Tuya account only to pull device data like localkey ← is required to make connection with your devices locally. that why it’s not needed. you still able to use localtuya even if you used Tuya Cloudcutter.

So setting up Tuya account will make device set up step easier. You can still able to pull localkeys from you smart/tuya apps in case don’t want to set up Cloud API.

Have you used HA Tuya integration

Help! I had some device that suddenly became “unavailable” for reasons I cannot find out… So I thought I’d give this fork a go. I removed the upstream version and installed this one. Now I can not add the device anymore. It gives an empty error. When trying to add.
I guess the old entities were not removed with the removal of upstream version, and it cannot add a duplicate? How can I remove the old data? Where is data for this integration stored

I don’t know what happen to you, whether it’s merging issue or not. but showing an error when choosing Add Device might be different issue. installing the fork above upstream doesn’t remove or add any entitles your old devices should works normally after merging complete and should already added if you didn’t delete them. maybe checking the logs will give you an idea of what is happening.

All Data stored in: config/.storage/core.config_entries search inside for localtuya

You can delete the data from the file or delete the entry from HA integration page.

Note You need to refresh the page after installing the fork this might be the reason why error is empty.

thank you for your project. I installed it today and I can finally see my bluetooth curtain. the only thing is that the commands are very slow and are not always taken.

I’m using Tuya Local (GitHub - make-all/tuya-local: Local support for Tuya devices in Home Assistant), which seems pretty active. Could anyone explain how this one compares?