Tuya local

Hi All,

I’m using Home assistant in a docker on a Openmediavault box and I’m perfectly happy with it. One thing however does not work well and that is Tuya.
Using the Tuya integration results in delays, group lights turn on one-by-one, you know the drill.
Before you say ‘Tasmota, Tasmota’, that is kind of difficult because I have 25+ Tuya bulbs and 12 of them are in a chandelier high up in the stairway. Not going to take them out to flash them.
Currently I installed Homebridge in a docker on the same machine and configured all the Tuya lights locally. Connected the Homebridge to Homeassistant and voila.
Everything works but…
I would like to have the Tuya locally integrated in homeassistant and would like to see some examples of an integration and yaml/json coding.
Can someone helps me to get on track?
Thanks in advance,

Nongsung

1 Like

You don’t have to with Tuya Convert. You can change the firmware OTA.

I have converted all my tuya bulbs/plugs to tasmota. However there are 3 plugs that aren’t ESP8266 based hence cannot be used with tasmota. For those I used local tuya custom component. It works quite well. The difficult part is to get the localKey for each of your devices. My setup is for switches but should be similar for lights.

There are multiple ways to get localKey. I used the method where we have to install an older version of smartlife app and then using some capture app to find localKey from JSON response. If you search you will find the process. You will also need deviceId which can be found in smartlife app itself.

My config looks the following

- platform: localtuya
  host: <IP_ADD>
  local_key: <localKey>
  device_id: <deviceId>
  name: bed_plug
  friendly_name: Bed Plug
  protocol_version: 3.3
  switches:
    sw01:
      name: bed_plug
      friendly_name: Bed Plug
      id: 1
- platform: localtuya
  host: <IP_ADD>
  local_key: <localKey>
  device_id: <deviceId>
  name: balcony_lamp
  friendly_name: Balcony Lamp
  protocol_version: 3.3
  switches:
    sw01:
      name: balcony_lamp
      friendly_name: Balcony Lamp
      id: 1

I suggest going with this fork instead as we have quite high pace when it comes to development now:

2 Likes

I have all the local keys and id’s, needed them to set them up in Homebridge.
Have not tried Fastcolors yet, gonna try that tomorrow.
And worst case, Tuya convert.

Keep you all posted, thanks for the quick answers; great forum!

Regards,
Nongsung

I didn’t know about rospogrigio/localtuya. Just tried it and that worked fine too. It has a UI so setup might be easier. You can give it a try

Yeah, tried that Rospogrigio already but found the various parameters to choose from a bit difficult. Could not get all my Tuya’s to work

Be aware, localtuya doesn’t support RGB/HSV bulbs yet, though it seems there is very active effort in getting it added at the moment. So, if these are color bulbs that you have, it may not be the route you want just yet.

Problem with Tasmota, aside from the fact that all the methods used to get the local keys seem to go away quickly and seem unreliable, is that also as far as I know without doing a two step through HA, tasmota will not link with Google Assistant. We use GA with Tuya natively a lot especially if HA goes down or I am messing with it for any reason.

Have you tried the newest HA build with the custom component version of Tuya? I’ve been using it for a couple of weeks now and it is FAST and RELIABLE. My switches work faster and better than they ever did.

If anyone ever links Tasmota to GA and finds a reliable way to get they keys I’m all in but also I love being able to pull a wifi outlet or bulb out of the box, link it in 3 minutes, update GA and restart HA, and I’m good to go.

Hi
I didn’t knew about this option. I have 7 tuya covers and the localtuya integration is ready to install. (it has discover the devices). My question is that right now I have the tuya integration running, so

  1. Do I have to unistall the tuya integration first?
  2. The entities of the above covers are used by several automations. Will they keep the same entity_id or I should change all my automations?
  1. You should remove the regular tuya integration, yes.
  2. They will get entity name based on the name you give them (“Living Room” -> “switch.living_room”), but you can change to whatever you like afterwards.

Thanks. before a while I tried to add one cover (without remove the tuya integration) and although the localtuya it “sees it” and the entity is created it is not working. Probably (I hope) because I haven’t uninstalled the original tuya integration. e?

Just to update you all, I have installed the Tuya integration; my color bulbs are not showing the actual color when selected, then removed the Tuya integration and installed localtuya; some bulbs are recognised but many aren’t. Tried another integration (true HACS) and the results were better not by no means perfect. I gave up and keep homebridge and that local tuya works perfect. Connected homebridge with homeassistant and all is well.
So all my Tuya lights are controlled by HA (and show the actual colors on my HA dashboard.

It all works as well as can be because homebridge goes haywire when we have a powercut; I live in Thailand and powercuts are very, very regularly; sometimes just a second of two, sometimes an hour or longer. When power returns ALL lights are on and homebridge is unaware…
Fixed that too; when my UPS switches from battery to power I let homeassistant restart the homebridge docker and then let HA close all the lights that should not be on.

SO I have a working solution but still I would prefer a total solution in HA without homebridge
but for the time it is what it is.

Thanks for the tips, tricks and support!

Regards,

Nongsung

I haven’t manage to make my covers work yet. But 1 dimmer light is working with localtuya.
But I have a basic question. For the beginning I added only 1 device (through integrations).
How can I add one more? I don’t see any options there. Should I add it through configuration.yaml?

You add new physical devices via the + button in the Configuration->Integrations page. If you want to add another entity (e.g. sensor) to an existing device, you will have to remove and re-add the entire device/integration as we currently don’t support adding new entities to existing devices (it will come at some point).

1 Like

We merged the last parts of color support (both HSV and RGB supported now) earlier today.

1 Like

I just loaded up some Tuya bulbs. Couldn’t change the colors and a little Googling led me here. Awesome to see this was just added. I have localTuya installed through HACS. How do I pull this capability in?
Thanks

You need to run from master to get color support. We are waiting for a PR to get merged to be included in HACS default repo list. Until then there won’t be any new releases.

Thanks. I want to capture this but then let HACS handle my updates in the future. Do you know if I manually update the files if that will cause a problem with HACS? Is it best to uninstall it from HACS first?

I think it’s best you uninstall from HACS and manually you install from master. Once it works in HACS, you remove the files manually and install from HACS. Remember to restart HA between each step (you will get some errors/warnings if you have devices added but the component not installed, just ignore until you have installed and restarted again).