thank you. you just saved DAYS of my life!
For those coming in late to this thread be aware:
there is more than one Tuya integration available in HA.
The ‘built in’ version doesn’t require a local key, works via the cloud, and requires you to know which tuya app you have been using (jinvoo, smartlife, tuya smart and others). Due to the API used it doens’t support everthing - dimmers, power readings from sockets, motion detectors and more, are not supported.
Hoping I can get some assistance. I purchased a few smart switches that are Tuya compatible, although not branded as such.
I’ve used the TuyaSmart app on the iPhone to set one up and it works fine through the app. I created an account using my mobile number and happen to be in Australia, country_code 61.
In my config yaml I have the credentials right. I know this because if I put them in intentionally wrong I get an error on startup saying the credentials are wrong in the log file.
I’m running HA 0.80.0 in a docker container on a Synology if that makes any difference.
The switch doesn’t appear in home-assistant anywhere. The Tuya component appears, and I’ve tried doing a pull_device and force_update but no luck.
I’ve also tried adding a switch manually into the config as indicated in this thread, but to me it doesn’t make sense to include the IP address of the device on which HA is running. If for example I have 2 of these switches how will it tell one from the other? Regardless adding the switch into the config manually doesn’t work either.
I’ve tried logging into the iot website for Tuya, but it doesn’t accept my credentials. I’m wondering if there’s something about being in country code 61? Oddly when I look at the reset password page it only shows country code 86 for a reset using mobile phone number.
Any help would be amazing - hope someone can help.
I also purchased an Aldi Medion plug and retrieved the local_key and device_id for it. Adding these into the switch details in the config didn’t help.
I tried both the Raspberry Pi IP address and the IP address of the switch too to no avail.
I am in the same position, I can see tuya.force_update and pull_devices in the services screen, no errors just no switch either.
OK - so you
can switch the switch via the TuyaSmart (not smart life) app
get HA to connect to Tuya Cloud using the same account details as in the TuyaSmart (not smart life) app using something like…
tuya:
username: 0414123456
password: MyPassword
country_code: 61
But you don’t see the switch appear as a device in HA?
(I’m going to assume your default HA page shows everything rather than having a set of custom pages which are limited.)
If you go into developer tools -> states and list all entities of type switch, so you see anything with a name like switch.00152310bcddc2ee846e ? (this is the virtual id of the device - the first number I think is your ‘home’ id, and the rest is the MAC of the device)
In the app, if you select it then menu, is the device support for third party control?
if you are using local_key and device_id, you are using the old (potentially better, direct) integration, not the smartlife cloud integration
I’ve tried both with and without the switch section and under switch the states I only see my 2 xiaomi zigbee switches, not the tuya/medion one. Also it is not showing in the default HA page.
This is my config:
tuya:
username: '[email protected]'
password: 'xxxxx'
country_code: '61'
switch:
- platform: tuya
host: 192.168.0.15
local_key: "62678b7f9398xxx"
device_id: "77180230840d8e4c5xxx"
id: 1
Supported third party control includes alexa, google assistant, ifttt and tmallgenie.
I have it working with google assistant and via the Tuya app.
Under Tuya, country code, I think you need to add something like
platform: smart_life
The platform should match whatever app you used to setup the device.
My plugs show up in the device list as switch.ReallyLongNumber
The really long number is the mac address or something like that, it matches what I see in router for my plugs.
BTW, in my router, the plugs showed up as esp’s, took me a little while to figure that out too.
EDIT: After you update the config.yaml and restart, you need to go to services and do a tuya.force.update then tuya.pull.devices
Randy
Could you please advise what version of HA you’re running and on what Hardware?
version 77.3 on a pi3b.
I remember when I first installed on an older version, maybe 74 or 75, I didn’t need to add the platform line and it showed up differently on the device list
I could be wrong here, but AFAIK, there are two ways to control Tuya like switches.
One is via the cloud and the tuya (or other) service. Here, you configure your device with the Tuya (or similar) app, and configure them to the cloud service. Home assistant will then use your login credentials to connect to the cloud service and control them via that cloud service. So, you communicate with the cloud service to turn on the switch, and it communicates with the switch.
Tuya seems to be a platform that other manufacturers can use to avoid developing their own firmware, phone app and back-end cloud service. For example, I bought my switches from CostCo in Canada from CESmartHome. They have their own app and service that looks like a clone of Tuya. However, I was able to get my switches talking to the Tuya app, so that is the integration I used. If you’re using a different app (eg Smart Life or Jinvoo Smart)m that is what you have to define with the platform parameter.
The other way, is by determining the IP, local_ley and device_id. If you can figure out the correct details, then you can communicate with the device directly, without going thru the cloud service.
The way I understand it, you can only use one way or the other.
Thanks @idbaker, your comment about using one or the other method was a help as I was mixing a bit of old and new methods together.
I finally succeeded in setting up the plug using the old tuya method.
Steps were:
-
Add the old tuya.py custom component to your custom_components/switch folder
-
Find the device Id and localkey, important here is that localkey changes each time you add the plug to an app
-
Add the switch using the below, host is IP address of the plug.
switch:
- platform: tuya
host: 192.168.0.15
local_key: “b32ab680603abxxxx”
device_id: “77180230840d8e4cxxxx”
switches:
switch1:
friendly_name: switch1
id: 1
- platform: tuya
It is a bit flaky, I’m getting errors sometimes but other times it works great.
I have an amazon tuya/smart life based smart multi socket plug. I am on Home assistant 0.80.2 and was able to discover the multi socket after adding the tuya user/pw and platform into the configuration.
My problem right now is it doesnt reflect my switch states in the UI. Did anyone get the tuya switch states to reflect accurately?
I ended up returning my switches as I couldn’t get then to work. I did read this though if it helps anyone.
Hi all,
Just getting started with Homeassistant on a Raspberry Pi. I’ve been able to link all my intelligent device except a Smart Heater branded “Thorben”, that use the Tuya Platform. The heather works perfectly with the Tuya App, Smart Life and even Goldair App, but I haven’t been able to add it in my Homessistant.
This is the code have been using and even though I don’t get any errors, the Heather is not visible the Home of mi Hassio. This is my configuration:
tuya:
username: '[email protected]'
password: 'yyyyyy'
country code: '56'
climate:
- platform: 'tuya'
host: '192.168.0.111'
device_id: '22222222dc4f221021b1'
local_key: 'aaaaa2a22a2222aa'
id: 1
I even tried to install other unit of the same heather using the Goldair component but with this option I get the following some errors. Here is the code and the error I am getting:
goldair_heater:
- name: Dormitorio Principal
host: '192.168.0.111'
device_id: 22222222dc4f221021b1
local_key: aaaaa2a22a2222aa
Any clues of what could be wrong?
Thank you very much in advance
Francisco
the heater probably isn’t supported - the Tuya integrations (there are two that I am aware of) don’t support all the devices that the app supports (motion sensors for example)
Well I have a Tuya based heater as well and I got it running via the cloud service from Tuya. I do want to add it locally so if I get a chance to I’ll report back if I get it going.
What guide did you use to get the local key?
Hi Walaj,
I was exploring tuya.py and there is line that request all devices I will try to figure out if I can make it work.
Best
Hi Nikoraus69, what do you mean with “running via the cloud service from Tuya”. Do you mean using the Tuya Smart App?
What is the brand of your heater?
To get the local key, I downloaded an App called “SSL Capture” from Google Play. Then I started it and enrolled the device (Heater) on the Tuya App. Then I opened once again “SSL Capture” and local for the data captured from the Tuya App. In one of these captured data packed you can find the local key.
There are other methods described on this forum and GitHub, please let me know if you can get the local kay and if you can linked your heater to homeassistant?
Best
Francisc
Hey!
It’s a Eurom heater which is a branded Tuya product.
If you can connect via the app you should be able to connect to it using the Tuya component in HA.
Thanks for the info about getting the local key. I will try it if my heater starts acting up again