Tuya devices in automations

Hi!

I’ve been searching forums and google for days without a proper solution, though i think the answer is possibly quite simple.

I’ve used the Tuya Integration to add my Tuya (in my case, smartlife) devices, and they all appear nicely on my Entities list. I can add them to my Frontend and turn on / off the lights from there.

But i cannot use the lights in automations. If i choose a simple automation like ‘Turn on the light when the sun sets’, only the HA Devices turn up on the list of lights, never my Tuya lights, because they are ‘only’ entities.

What am i missing?

Thanks :slight_smile:

Hi ianfrank,

Can you share on how you integrate your tuya devices? I tried the method below and I could see the tuya.pull_devices and tuya.force_update but it does not show all my devices.

tuya:
username: YOUR_TUYA_USERNAME
password: YOUR_TUYA_PASSWORD
country_code: YOUR_ACCOUNT_COUNTRYCODE

Thank you in advance.

Hi swooshnoypi,

Sure… I basically did the same as you, i just added one line since my platform was Smartlife. So this is my config:

tuya:
  username: (my username for the smartlife/tuya app)
  password: (my password for the smartlife/tuya app)
  country_code: 41
  platform: smart_life

You can find your country code here : https://countrycode.org/

I’ve read somewhere that not all devices are supported yet, so perhaps that is why you don’t see all your devices.

Hope this helps. :slight_smile:

If you try to create an automation, in the first screen click skip. In the following screen you will be able to choose your tuya light.

I thought so too, but unfortunately only the things that are added as ‘Devices’ show up on the list. I can choose all of my Hue, Ikea Tradfri, Sonoff and Google devices, just not the Tuya ones.

I think in the action section, you want to select Call Service rather than device. This then gives you a list of entities related to that service.

What is the Entity ID of the entity? Often that points you to the right service to use.

using Smartlife in the config is shotty at best.

You need to delete all the devices in smartlife app, and add them all in tuya app. and use Tuya in the config, make a seperate account for tuya too, dont use the smartlife one.

sounds weird i know, but it will work,

@baz123 You are absolutely right, that actually worked :smiley: Thank you very much.

My enitities are called light.xxxxxx so i could call the service Light.On and use the entities there. Brilliant.

@fiftys ok, if smart_life is unstable, i will try to add the devices using the Tuya app instead. Perhaps they will show up as proper devices then. I will post the results here.

1 Like

I tried both tuya and smartlife. None of my lights show up as devices. Smartlife works best for me.
Although in automations I primary use scenes defined in the smartlife app.

@francisp ok cool, thanks for the info. I guess i’ll stick to Smartlife for now, and switch to Tuya if it proves to be unstable.

I actually plan to flash the bulbs using Tuya-Convert OTA, but i think i’ll have to wait since i upgraded them to the latest firmware when i got them a month ago.

Anyway, my problem is solved for now. Thank you all for the help. :sunglasses:

1 Like

its not just unstable, it simply doesnt work.

search it on here. lot of posts about it,

yes, I noticed that as well when i was troubleshooting my automation issue. The Smartlife integration does work for me though, and for some other people as well. My devices turned up in HA and I could interact with them.

I think we might have problems with the integration if the Tuya API is updated. It’s something to keep in mind for sure.

yeah i know they show up in ha, thats all i own is tuya stuff;. some flashed, some not. flashed stuff shows up as devices because its intagrated with mqtt. for the rest its all entitys.

for somereason using smartlife as the platform in ha has issues though. i wasnt able to see anything with the smartlife platform. soon as i switched over to:

tuya:
  platform: tuya

everything worked as expected. that was 9 months ago though. maybe its changed.

however the smartlife api must differ from the tuya. if you have used ifttt you will notice you have a choice between both logins as well.

Cool, i’ll look into it and switch to Tuya if Smartlife becomes rocky. Not sure if they fixed anything, i just read there was issues in november '19 because of changes in the API. Also read somewhere that you could use the same user/pass for both Smartlife and Tuya, but i never tested that, and maybe that changed too.

Anyway, thanks again for your input. :+1:

Hi,

1- I integrated TP-Link and Tuya to Smart home. Under configuration/Entities, I can see devices from both TP-Link and Tuya
2- Under devices, I only see TP-Link devices, not Tuya
3- That means that when I want to do automation, I can’t create triggers or take actions with devices I have with Tuya.

Below is the config for configuration.yaml:

# smart_life config
tuya:
  username: "xxxxx"
  password: "xxxxx!!"
  country_code: "1"
  platform: tuya

I tried doing tuya.pull_devices with no luck either
Any idea what I have missing?
Thanks

If you see them under entities, tuya.pull_devices won’t help because they are already pulled in. You don’t need them under devices to create automations. Simple use state triggers instead of device triggers.
image

That light is a tuya device.

Thanks @francisp - That’s a solution for the trigger, but what about actions?
Any ways to add Tuya devices as devices?

1 Like

action:

action:
 service: light.turn_on
 data:
   entity_id: light.tuya_entity

1 Like