I have NO idea what those “id: 1” is for. I think someone here in the forum managed to get tuya to work without it. Since my tuya works right now, I am not going to touch anything unless it’s absolutely necessary
That doesn’t seem to be it. I looked in the server files, and in home-assistant.log, I found the error referencing Tuya. It seems like it isn’t able to authenticate. Again, I’m using my normal Tuya account, not IoT.
tuyapy.tuyaapi.TuyaAPIException: get access token failed
Also, thank you for your help. It’s very much appreciated.
EDIT: I am using a multi-socket switch (Power strip).
it looks like your devID and/or localKey is not correct. you want to make absolutely sure that you got the right pair of information (see my post above)
Both are accurate. I decided to try to make an account with the Tuya IoT site, and then use that login information for the Tuya component, and it worked. I seem to be able to login to the Tuya app using that login information, and I can add devices from there.
I’d like to know if anyone is able to get the Tuya component working with an account created in the app instead of on the Tuya site. If not, that should be added to the documentation as a possible requirement.
@zhide.p -
Thanks for the code formatting, that helps. YAML is fussy about spacing - it looks like you need to add 2 spaces so you get indenting like this:
tuya:
username: '1234567890' // each line under platform name is indented 2 spaces
password: 'xxxx88788' // and there are NO dashes in phone no / user name
country_code: '1'
switch:
- platform: tuya // platform is indented 2 spaces under device type
host: 192.168.86.22 // device parameters align left under platform name
optimistic: true // is the IP correct for hassio server?
friendly_name: Tuya01 // NOTE: IP is NOT the IP for this switch
id: 1
FYI - I use Brackets to edit this code b/c it shows spaces. I use hass.io, + Samba Share component so that I can open configuration.yaml directly from finder on my Mac.
Lastly, have you checked your login credentials? Can you login to the Tuya site with the same username and password from above? What error messages are you getting? Next time, can you pls share the info your system displays (hassio > configuration tab > info [i with circle - last icon in dev tools)
@zhide.p - that’s just a warning - I get those too and it doesn’t affect performance. Can you share all info from your logs - as well as your system details (Mac/PC, Hassio version)?
I have a suspicion - you’re not authenticating. Are the username and password the same in the app as well? When you open the Tuya app on your phone, go to profile > Account, is your Account name your JFK… username or is it your phone number, or something else?
Lastly, do you see the switch or light in your Hassio dashboard? I assume it appears there, but doesn’t do anything, is that right?
@zhide.p - I think I know what’s wrong. In the code snippet above you have 3 different host addresses. Assuming you’re running a single instance of Hassio - this needs to be the IP address of THE device running Hassio - again, in my case a raspberry pi.
In order to get the IP address, I use Fing, an app on my iPhone, to view all the devices on my router. If you reboot your router (and don’t have fixed IP addresses) it may assign a different address to your pi in future - then you would have to change the hostname IP again. But that hasn’t happened to me yet.
In future, I plan to assign fixed IP addresses and setup DuckDNS - there are good tutorials out there too - thanks to this fab community.
@liz_myers, i am using a Raspberry Pi 3+ and it’s the only HA instance. I am sure the usrname and pw is correct. i have a 2 accounts set up by a phone nubmer and email, but no luck. When i put a wrong pw, it will give me the below message:
When i put the correct usrname and pw, there is no above error message and dashboard doesn’t show anything about tuya switch, either <> page on developer tools.
TP-link switches are working fine in my config, the IPs are correct and required for tp-link platform
hi liz, i also try to disable all tplink switches and leave only the tuya one, but it still not showing anything. dont really know what the issue is T_T. can you tell me what model of tuya switches you are using?
this is my model and it works in the Tuya Smart app.