Request for integration with Tuya

Description

I would like to be able to control these devices that manage the heating via Wi-Fi and the Tuya controller. These devices work with Home Assistant but are not yet supported by Gladys.

The air conditioners were installed by a professional. They are of the Thermor brand. The Thermor app is not compatible with Home Assistant. But the Tuya bridge detects the split units as the original Haier brand.

The eCosy controls the only radiator that is in use in my home. I bought it before I discovered Home Assistant and Zigbee.

Hi @Papashultz,

I actually need Tuya as well. I just installed 2 Airton air conditioners + 1 pilot-wire thermostat that uses Tuya. I was indeed able to install this fairly easily in HA, and locally (well, advertised as such, but you still have to connect via the cloud).

I plan to look into this soon to modify the current integration and manage to connect.

1 Like

Okay, I can now connect:
image

Known errors are showing up:
image
image

Devices are correctly reported directly with the local_key and id:
image

And for those implemented, the following are correctly added:
image

I’ll try in the next PR to add the air conditioners and pilot wires

1 Like

Hello,

I have a first draft for the TUYA integration to update the Tuya account configuration. I specifically modified the field names to match the names used on the website. I hid the « Client Secret » like passwords. And I added information about renewing trial periods (which are renewable for up to 3 months but completely free and are usually applied a few minutes after the request).
This update also includes the foundation for local communication (no more cloud). Switch management works locally.
The PR:

In a future PR I will add the devices as discussed previously.

PS:
@pierre-gilles, I do, however, have an issue with Tuya protocol version 3.5. I can’t find a Node.js project for this protocol. Apparently only TinyTuya implements it, and it’s in Python. I can’t find a maintained project in this regard (protocol 3.5 isn’t new, it’s over 3 years old).

ChatGPT gives me 2 possibilities:

  • Redevelop the protocol handling ourselves like « TinyTuya » in Node.js, but we would need to maintain it afterwards
  • Add Python support alongside Gladys to install TinyTuya… I don’t think that’s what you want…

Do you have a solution for that?

If any owners of Tuya devices happen to pass by, I’d be interested in feedback on a test image — for this cloud/local connection, as well as for future additions.

Hello,

I’d be happy to test, but I’ll set it up via Portainer. If you confirm that my stack is correct, I’ll test it as soon as I receive your reply.

services:
  tuya-test:
    image: terdious/gladys:tuya-test
    container_name: tuya-test
    restart: always
    privileged: true
    network_mode: host
    environment:
      NODE_ENV: production
      SQLITE_FILE_PATH: /var/lib/gladysassistant/gladys-tuya-test.db
      SERVER_PORT: 81 # The Gladys port is 83 on my side; do I need to change it?
      TZ: Europe/Paris
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/gladysassistant:/var/lib/gladysassistant
      - /dev:/dev
1 Like

Hello @Papashultz,

Your stack looks good and matches my setup.

No, on the contrary, the goal here is to test in a session alongside your production. No need to stop your production. Just check that port 81 is not in use, otherwise set it to a free and accessible one ^^
The main thing being this: `SQLITE_FILE_PATH: /var

Assume that I am a “basic” user, not a developer. As such, here are my thoughts as a tester:

  • I’m having a bit of trouble with the Tuya configuration help that is just above the fields to fill in, including in the currently production version. It took a real effort to find the solution thinking “oh yes, there’s documentation, where is it again?” : Is it possible to add a link to the Tuya documentation that opens in a new window?

Here between:

Vous pouvez connecter Gladys \[…\]

and

Vous avez besoin \[…\]

could you add a line like:

For easier use, you can open a new window to our tutorial by clicking here \[link to: Tuya | Gladys Assistant \].

or alternatively put a direct link that would open to: Tuya Smart Developer Center

in the sentence: « You must then create a ‹ Cloud Project › in your Tuya account. » at the « Cloud Project » part?

  • I am currently stuck here

I don’t know what to put in the App Username field. Is it the Project Code that I find on Tuya Smart Developer Center or is it a name that I find in my smartphone app?

  • The IP devices are, for the moment, on the same network as Gladys. I therefore expect discovery to happen automatically.

Another suggestion not related to the current exercise: on Home Assistant the Tuya integration is done directly via a direct link with the smartphone app using a link via the app’s user code and then a QR code callback. Wouldn’t it be simpler to proceed this way? Especially since this implies having a Tuya app on the smartphone for both the Gladys solution and the Home Assistant solution.

1 Like

Just a guess:

I put the « Project code » in the last field, and fired it up. It works!

image

If it’s not the right answer: tell me and tell me where I should go.

If it’s the right answer

The displayed IP address is that of my router, but not that of my local network (192.168.1.0/24)

Whether using Gladys production or Gladys-test, it is not possible to open the garage door with the switch.

The app also doesn’t work on Home Assistant.

This morning, only the Tuya app on my smartphone is making the Tuya devices work. :face_with_steam_from_nose:

@Papashultz,

Sorry, I

I’ve been checking my router for a while to find the IP addresses of the connected devices so I can set them to static IPs.

Is there a trick to find them?

Any idea how I could go about finding them among the unknown addresses?

The best and quickest way for this test, from any machine on the same network:

  • Installation of Python :

On Windows:

winget install Python.Python.3.12
python --version
pip --version

On Linux:

sudo apt update
sudo apt install python3 python3-pip
python3 --version
pip3 --version

On macOS:

brew install python
python3 --version
pip3 --version
  • Installation of TinyTuya (used by localTuya on HA) :

Windows (PowerShell)
python -m tinytuya scan

Linux / macOS
python3 -m tinytuya scan

And you should normally find the IP addresses of your devices on the local network like this:
image

![image|638x152](upload://mVwcQz

1 Like

You can normally do this:

python3 -m pip install --user tinytuya
python3 -m tinytuya scan

Enjoy your meal!!

Definitely GLaDOS:

image

Sorry, we might be able to do even better in Gladys ^^
Can you give me 5–10 minutes for an image update!!

I believe in it!! ^^
And I’ve already taken into account most of your previous comments ^^

Ok, so I updated the image. It should be pretty good ^^

As for Portainer, I don’t know about updating the image; on my side, I do:

docker pull terdious/gladys:tuya-test

docker stop gladys-tuya-test

docker rm gladys-tuya-test

docker run -d \
--log-opt max-size=10m \
--restart=always \
--privileged \
--network=host \
--name gladys-tuya-test \
-e NODE_ENV=production \
-e SERVER_PORT=81 \
-e TZ=Europe/Paris \
-e SQLITE_FILE_PATH=/var/lib/gladysassistant/gladys-tuya-test.db \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/gladysassistant:/var/lib/gladysassistant \
-v /dev:/dev \
terdious/gladys:tuya-test

So @Papashultz you now have all the requested links (I think) :
image

The QR-Code link isn’t currently possible on Gladys, or at least I haven’t found an « easy » solution yet.

From now on, on the discovery page, if you click the Scan Local button :
image

You should find your devices with their IP address and protocol :
image

Windows is no more cooperative than GlaDOS.

PS C:\WINDOWS\system32> python --version
Python 3.12.10
PS C:\WINDOWS\system32> pip --version
pip 25.0.1 from C:\Users\alain\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip (python 3.12)
PS C:\WINDOWS\system32> python -m tinytuya scan
C:\Users\alain\AppData\Local\Programs\Python\Python312\python.exe: No module named tinytuya
PS C:\WINDOWS\system32> python3 -m pip install --user tinytuya
Python est introuvable ; exÚcutez sans arguments Ó installer Ó partir du Microsoft Store ou dÚsactivez ce raccourci dans ParamÞtres > Applications > paramÞtres d
PS C:\WINDOWS\system32>

On the Portainer side:

image

image

image

image

Make sure everything is correct; you can add the version number on the image line.

image

All that’s left is to enable Re-pull image and redeploy and click Update

image

1 Like