Request for integration with Tuya

No worries, no rush!

For me, the PR2 - protocol 3.5 is therefore working fine. I haven’t tested it on my production environment, but I can if needed.

Thanks @GBoulvin,

I’ve updated the Docker image, which now also supports 3.4: it’s now routed to the fork @demirdeniz/tuyapi-newgen (the same one that handles 3.5), and a 3.4 version parser has been added to the local UDP scan between the 3.1 and 3.5 parsers. You can retest whenever you want with the new image.
If possible, also test the UDP scan (independently) to ensure everything works. Thanks in advance

On my side, normally no need: the changes add routing strictly triggered by protocolVersion === '3.4' or '3.5'. Devices 3.1 and 3.3 continue to use the legacy tuyapi library without any modification to the call path — so no risk of regression on what already worked.

That said, if you want to take the opportunity to validate on your production environment, it’s ideal: your 3.4 devices (which didn’t work) should now be functional, and your 3.1/3.3/3.5 devices should remain the same as before. No obligation, it’s just a bonus if you have 5 minutes.

EDIT:
For info @pierre-gilles, I renamed the PR by explicitly naming the 3.4 addition in addition to 3.5, both using the same library. The PR is a bit larger, but we’re still under 600 lines of changes, it’s mainly the tests that are significant (represent half of the added lines)

Dumb question maybe, but is the image still on the same tag (pr1)?

Yes, always ^^ Better to ask ^^

Hello!

I tested the available version and protocol 3.4 is detected and works directly. Local IP address detection also works (for 3.4, yes, but not for 3.5. I had already noticed, but my network setup isn’t the best for testing this, so it’s hard to confirm it’s due to the protocol).

All good for me then! Thanks!!

The following 2 PRs are awaiting review:

  • Adding support for protocols 3.4 and 3.5:
  • Adding the first cloud/local mapping bricks and notably local UDP discovery:

@GBoulvin, if you want to test PR3, I created a new image terdious/gladys:tuya-PR3, specifically:

  • starting with your database from the last test,
  • then performing an auto UDP local scan
  • then deleting the already registered devices, logging out, then logging back in and running another auto UDP local scan, to make sure everything is properly found.

Thanks in advance.

That’s good for me for PR2, it’s merged and will go out in the next version of Gladys :slight_smile:

For PR3, there are conflicts after the merge, let me know when I can take a look!

Thanks for the development!

Available in Gladys Assistant 4.77:

Hi @Terdious,

I’d really like to merge the PR 3, but there are conflicts:

As soon as you can run Claude on it to resolve them, let me know and I’ll merge it :wink:

Hi @pierre-gilles,

I’ll get back to it quickly and take a look!!
Thanks

EDIT: All good for me.

Super thanks @Terdious! It’s merged!
Is PR 4 ready? :smiley:

Hi @pierre-gilles,

Thanks for merging the PR3 :+1:

For the PR4 #2467, it’s ready. I just merged master into it to resolve the 3 conflicts that GitHub was reporting

It’s good for me for PR4, it’s merged and it will go out in the next version of Gladys :slight_smile:

Thanks for the PR :raising_hands:

Top, thanks a lot for merging PR4 and all the previous ones :raising_hands: :rocket:

As for PR5, I just updated master in it as well, it’s ready for review: #2470

Quick note : you can take your time with this one, I’d prefer we wait for feedback from @GBoulvin on the Docker image Terdious:tuya-smart-meter (currently building) before merging. It’s the first complete Tuya integration for cloud + local management, and the cloud Thing Model strategy is new — real-world testing on his meter wouldn’t hurt before it goes into release, even though he’s already tested it before. We made a few changes in the first three PRs (supposedly non-impactful) :slight_smile:


Hi @GBoulvin

PR5 is ready on the code side and the Docker image Terdious:tuya-smart-meter will be available in about 30 minutes (build in progress).

Could you test it on your Smart Meter when you have a moment? The goal is to validate in real-world conditions:

  • cloud device detection
  • reading values (instantaneous power, total energy, voltage, current)
  • cloud polling stability over time
  • local device detection
  • reading values (instantaneous power, total energy, voltage, current) locally
  • local polling stability over time

Your feedback will determine the merge on Pierre-Gilles’ side. Thanks in advance :pray:

Hi @Terdious,

Small access rights issue with your test image (not public?). If you know where to look… Sorry for my lack of responsiveness!

Edit, I found it: terdious/gladys:tuya-smart-meter :wink:

Here’s my feedback. I tested it and it seems that everything works. It’s stable, I clicked like a madman and put zeros everywhere, and everything held up :wink: The units are good, local and cloud polling are running smoothly.

Just one thing of little importance:

It says „forword“ instead of „forward“. I’m not even sure if this comes from the PR o:-)

Regarding energy accounting, are the „every 30 minutes“ calculations still to be implemented or is this already planned?

I’ll let it run this weekend to see how it goes, but for me, it’s all good!

Thanks @Terdious!

Oops!! ^^ Sorry for the wrong image name.

Thanks a lot for the tests :folded_hands: @GBoulvin

Well spotted ^^ indeed, the DP code returned by the Tuya API for these meters is literally spelled energy_forword_a / energy_forword_b, so it’s an error on their side that I replicated for consistency with the API documentation… but indeed, it bothers me too :sweat_smile:

@pierre-gilles, what do you think? Keep the error or correct it in Gladys for the feature naming?

Otherwise, following the convincing tests, I’ll leave you in charge of the PR review when you can :wink:

Fix it on Gladys’s side :slightly_smiling_face: It would be a shame to perpetuate an error in our own features. :grinning_face_with_smiling_eyes:

After 48 hours of testing, no bugs, disconnections, or anything!

Hi @pierre-gilles,

It’s done, features renamed. Thanks to you.

I’m good to go for the review on PR5 - Adding support for Smart Meter, I’ve assigned it to you:

PR6, a PR mainly grouping fixes, will also be ready for review:

Thanks!!