Tuya Integration

No the issue is Tuya keep changing the API, thats whats happened recently. Bit hard for HA to keep up

I guess someone needs to make a good local docker image that works with mqtt discovery.

There was an custom component for the goldair heaters but it doesn’t work with latest version of home assistant.

What I have found so far:
Method 1-
Flash Tasmota with tuya-convert and use it like a sonoff switch. This is my preferred way and have a couple of switches done like that. With some new patch, tuya (or its rebranders) have broken the tuya-convert OTA method. There are some forks to work around this, but i havent been lucky so far.

These are the resources:

Original tuya-convert

Fork to work around upgraded hardware:

So for now, have to live with tuya HA component, but not a true solution for me as it sends data to the vendor server. The offline method is still very hacky and the newer versions of smartlife app are closing off a lot of info needed there, like the IDs and keys.

Method 2:

Add tuya to the config yaml and pulling the devices to refresh. It all works fine, and switch.junk&chars6&%with)5$nums appears. Now, how do we use it as a switch_ what is the way to use it in hadashboard, lovelace, etc? probably with lovelace, it could be easier, but what is the mechanism to switch on and off_ also, heard some issues with state not retaining and such. Could someone add some thoughts?

Thanks in advance.

I have tuya smart wifi socket, the one that have electricity meter.
I added the configuration for Tuya in HA, but I didn’t see the devices.
With the information from the tuya component source I made the requests to Tuya cloud with Postman, but I only receive empty device response.

Request

{
	"header": {
		"name": "Discovery",
		"namespace": "discovery",
		"payloadVersion": 1
	},
	"payload": {
		"accessToken": "..."
	}
}

Responce

{
    "payload": {
        "devices": [],
        "scenes": []
    },
    "header": {
        "code": "SUCCESS",
        "payloadVersion": 1
    }
}

I have also just installed some Tuya (Lumiman) lights and am not seeing them listed.
I can see that the component is logging in correctly via the EU node.
If I make changes to password or platform then it fails (as expected).
Perhaps something is going wrong between the skill installed on the Tuya site and Tuya itself - but that is outside of the area that we can debug I think.

Is the source of that piece available (hosted at px1.tuyaeu.com/homeassistant/skill ) or a way to see diagnostics from it?

I put the country code in quotes, like this “47”. The phone app is Tuya Smart, so I write platform: tuya
This works for me.

1 Like

I think I tried all possible ways to config the tuya platform. With and without quotes.Tried smart_life too
But still get this error: “Error during setup of component tuya”
Most important line is “tuyaha.tuyaapi.TuyaAPIException: Get accesstoken failed. Username or password error!”
Only thing I am not sure of is how to set username.
In the tuya app it is : countrycode-phonenumber without trailing zero so 31-12345678
But that does not work neither,

have the exact same issue! using LSC smart home products and app, which should be the same as tuya smart

@curious @dtx3k

If you use the default tuya integration make sure the “platform” is the same as the app - if you have used the “Smart Life” application on your phone you must use the “smart_life” platform. And if you used an app that isn’t listed in https://www.home-assistant.io/integrations/tuya I would remove the app, and pick the generic tuya app.

re username - this is my config:

tuya:
  username: 0414123456
  password: password
  country_code: 61

tried the generic tuya app (just to be shure) that didnt work even though the interface looks exactly the same (lol)
so it is a different platform then ? different then listed by the intergration maybe?
The app i’m using is called LSC Smart Home, interface identical to generic tuya, security key was mailed to me from: " [email protected]" that would suggest platform: smart_life

so changed config to:

tuya:
   username: [email protected]
   password: password
   country_code: 31
   platform: smart_life

so no luck sofar

I’ve been having similar issues when using the PlusMinus app for Lumiman bulbs.
Have opened a couple of tickets to try to find which “platform” it requires (I tried them all).
Am tempted to do a factory reset on the bulbs and register them with the Tuya app/service instead and then have a go at getting them working with HA.

I have the action ceiling lights, and did use the smart life app ( and not the LSC smart home ) to set them up. Since HA 0.101 I see them, before I could only see the scenes I had defined in the app.

Well I thought I tried all possibilities…i did not.
The correct settings are : username: mobile phone number without the first 0 and without countrycode.

1 Like

for those trying the generic tuya app, you need to reset the devices, and reregister them on the app. THEN try in HA.

Whilst all the apps appear similar, and likely to connect to the same physical Tuya end points, the host names are likely different, and not supported by the HA integration.

2 Likes

I could not get the smart_life working but I did switch all my devices over to the TuyaSmart app and then it worked. I also had to use quotes around the country_code.

Here is what worked for me…

tuya:
  username: [email protected]
  password: xxxxxxx
  country_code: “1”
  platform: tuya

shouldn’t there be quotes around anything that’s a string? so…like all of the variables?

Not in YAML.

From Stack Overflow (a random googled example, but applicable):

After a brief review of the YAML cookbook cited in the question and some testing, here’s my interpretation:

  • In general, you don’t need quotes.
  • Use quotes to force a string, e.g. if your key or value is 10 but you want it to return a String and not a Fixnum, write '10' or "10" .
  • Use quotes if your value includes special characters, (e.g. : , { , } , [ , ] , , , & , * , # , ? , | , - , < , > , = , ! , % , @ , \ ).
  • Single quotes let you put almost any character in your string, and won’t try to parse escape codes. '\n' would be returned as the string \n .
  • Double quotes parse escape codes. "\n" would be returned as a line feed character.
  • The exclamation mark introduces a method, e.g. !ruby/sym to return a Ruby symbol.

Seems to me that the best approach would be to not use quotes unless you have to, and then to use single quotes unless you specifically want to process escape codes.

Update

“Yes” and “No” should be enclosed in quotes (single or double) or else they will be interpreted as TrueClass and FalseClass values:

en:
  yesno:
    'yes': 'Yes'
    'no': 'No'

Smart_life never worked for me.
I had to remove everything from the smartlife app, then add it to the Tuya app.

It was then able to find everything using this.
I also couldnt use my phone number, I had to link my email in the tuya app.

tuya:
  username: ********email
  password: ******password
  country_code: 1

I removed my device (WakeUpLight) from the Smart Life app and created a new Tuya account. Then added the device to the Tuya.
But still it doesn’t find anything in HA. If a create a scene in the app, then this is immediately visible in HA. So the connection seems to be set up correctly. But why can’t I see the light?

the out of the box HA Tuya integration doesn’t support all devices that Tuya supports…