Tuya Device Help

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?

1 Like

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.

1 Like

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:

  1. Add the old tuya.py custom component to your custom_components/switch folder

  2. Find the device Id and localkey, important here is that localkey changes each time you add the plug to an app

  3. 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

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 :slight_smile:

1 Like

not necessarily with the indirect cloud integration.

I can’t yet comment on the direct integration.

I have another problem with tuya,

current temperature isn’t true, seem be real temperature +21° or multiplied for 2!
and… why no hystory?
Cattura|368x388

another problem! you can only turn on\off or change temp. but not switch from program to manual

Hi,

I wanted to try the custom local component. But unfortunately GitHub gives a 404 on the repo.

Someone willing to share the code of tuya.py?

1 Like

Hi,
Sorry to hijack this subject. I have my tuya plugs showing in HA and I can control them through google home mini and also through automations, however, I am not able to switch them on/off from the frontend (the overview screen), which I used to do but not any more (they always revert to their previous state within a second). I removed the plugs and added them again, and also downgrade the HA version to 80.0, with no luck. Any suggestions?

No worries mate, have you checked the logs for any clues?

Yes, this is the error I have in the log file:

ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall switch.turn_on (c:xxxxxxxxxxxxxxxxx): entity_id=[‘switch.xxxxxxxxxxxxxxxxx’]>
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/core.py”, line 1177, in _event_to_service_call
await service_handler.func(service_call)
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py”, line 177, in handle_service
self._platforms.values(), func, call
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py”, line 250, in entity_service_call
permission=POLICY_CONTROL
homeassistant.exceptions.Unauthorized: Unauthorized