core icon indicating copy to clipboard operation
core copied to clipboard

PC321-TY Single/3-phase Power Clamp unsupported

Open lassehol opened this issue 1 year ago • 14 comments

The problem

Tuya integration lacks support of the Tuya Smart Life compliant energy meter.

The Tuya integration integrates all Powered by Tuya devices you have added to the Tuya Smart and Tuya Smart Life apps.

What version of Home Assistant Core has the issue?

core-2024.2.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Tuya

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tuya

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

lassehol avatar Apr 22 '24 12:04 lassehol

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tuya can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign tuya Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tuya documentation tuya source (message by IssueLinks)

home-assistant[bot] avatar Apr 22 '24 12:04 home-assistant[bot]

I have the same problem, PC321-W-TY(Bi-Directional) is unsupported.

Testingfor101 avatar May 06 '24 21:05 Testingfor101

Same problem

vahvakarhu avatar May 08 '24 12:05 vahvakarhu

Same problem, bump

mateuszbrzezinski avatar May 13 '24 12:05 mateuszbrzezinski

add me to the list anything I can provide to help? Mine is electricity monitor model ST-1168

Grey-Lancaster avatar May 17 '24 21:05 Grey-Lancaster

Same problem

bachihans avatar Jun 14 '24 12:06 bachihans

Same here

nehu187 avatar Jul 26 '24 20:07 nehu187

Same probem, PC321-W-TY(Bi-Directional) Unsuported

GBRAVOG avatar Aug 22 '24 04:08 GBRAVOG

Same problem, PC321-W-TY unsupported. Had it working with Local Tuya but has also stopped working.

FreemanJD avatar Sep 21 '24 09:09 FreemanJD

Same model/same behaviour for me. Is it supposed to work ? Is there anything we can do to help debugging ?

gomusan avatar Sep 22 '24 17:09 gomusan

Maybe this could be a clue https://github.com/home-assistant/core/issues/99422

gomusan avatar Sep 22 '24 20:09 gomusan

After a hard reset of the device, by removing it from smart life and re adding it back in I was able to add the device back into home assistant through Local Tuya. This is a long process if you want all dp values but I’ve only done three (Active Power, Total Consumed and Total Exported). It’s been a headache and would be nice if it was just supported by the tuya integration.

FreemanJD avatar Sep 22 '24 21:09 FreemanJD

So this device is still reported as unsupported. It appears that devices need to be specifically listed in code in order to be supported. I don't have development environment but I did a liitle digging into the code in order to see where the problem lies.

The Tuya category is "Energy" and subcategory is "Smart Electricity Meter (zndb)" described here: https://developer.tuya.com/en/docs/iot/smart-meter?id=Kaiuz4gv6ack7

in HASS core, the code that handles Tuya integration is here: https://github.com/home-assistant/core/tree/dev/homeassistant/components/tuya/

in file switch.py there is a table called SWITCHES which contains

# Smart Electricity Meter # https://developer.tuya.com/en/docs/iot/smart-meter?id=Kaiuz4gv6ack7 "zndb": ( SwitchEntityDescription( key=DPCode.SWITCH, translation_key="switch", ),

so in theory this device should work. Maybe the problem is that this energy meter does not actually have any switches to be operated on.

korlcek avatar Oct 14 '24 09:10 korlcek

I followed this comment: https://github.com/home-assistant/core/issues/99422#issuecomment-1731532400 Has worked fine for me thus far. I tried the local tuya first, but for some reason it stops bringing values after some hours to some days. The command line circumvention seems solid enough.

Lähetetty sovelluksesta Outlook for iOShttps://aka.ms/o0ukef


Lähettäjä: korlcek @.> Lähetetty: Monday, October 14, 2024 12:20:19 PM Vastaanottaja: home-assistant/core @.> Kopio: lassehol @.>; Author @.> Aihe: Re: [home-assistant/core] PC321-TY Single/3-phase Power Clamp unsupported (Issue #115964)

So this device is still reported as unsupported. It appears that devices need to be specifically listed in code in order to be supported. I don't have development environment but I did a liitle digging into the code in order to see where the problem lies.

The Tuya category is "Energy" and subcategory is "Smart Electricity Meter (zndb)" described here: https://developer.tuya.com/en/docs/iot/smart-meter?id=Kaiuz4gv6ack7

in HASS core, the code that handles Tuya integration is here: https://github.com/home-assistant/core/tree/dev/homeassistant/components/tuya/

in file switch.py there is a table called SWITCHES which contains

Smart Electricity Meter # https://developer.tuya.com/en/docs/iot/smart-meter?id=Kaiuz4gv6ack7 "zndb": ( SwitchEntityDescription( key=DPCode.SWITCH, translation_key="switch", ),

so in theory this device should work. Maybe the problem is that this energy meter does not actually have any switches to be operated on.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/115964#issuecomment-2410557226, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDSWZOWJ6YR3GHYGVFGXRDTZ3OEFHAVCNFSM6AAAAABGSWLIZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJQGU2TOMRSGY. You are receiving this because you authored the thread.Message ID: @.***>

lassehol avatar Oct 14 '24 09:10 lassehol

It works, thanks for the tip. Changes were needed for the YAML

command_line:
  sensor:
    name: Meter PC321-W-TY
    unique_id: meter_PC321_W_TY
    command: 'python3 /config/tuya.py <device_ID>'
    device_class: power
    state_class: measurement
    unit_of_measurement: W
    scan_interval: 10
    json_attributes:
        - ActivePowerA
        - ActivePowerB
        - ActivePowerC
    value_template: "{{ value_json.ActivePower }}"

This solution however requires a cloud project on tuya developer platform. As I understood the official Tuya integration only needs user code from the app.

korlcek avatar Oct 14 '24 16:10 korlcek

I just watched the excelent video of Amrut Prabhu, YT channel Smart Home Circle https://www.youtube.com/watch?v=wtzw_d4KMEQ. When checking the code, in the code I saw this message: "msg": "No permissions. Your subscription to cloud development plan has expired.". Other state that a dev account only works -if it works- for 1 month. I wanted to create a new account, but then found the TuyaLocal project.

Also an excelent video of Mark Watt, YT channel Mark Watt Tech https://www.youtube.com/watch?v=YKvGYXw-_cE. He explaines how to get the local key. Do use his TuyaKeyExtractor tool, as notepad(++) does not translate some characters. After using his tool, it worked!

I am new to HA, so if someone already made a 'translation' table with the values, I am happy to learn how to integrate that/ using yaml.

[edit] Editing one item is a pain in the ass, but it works. I think it's directly saved in the database, so no yaml code available to copy-paste it in? Thats a lot of work if I want to add a few extra ones!

hope this helpes: PC321-W-TY(Bi-Directional)

unit()-A(L1)-B(L2)-C(L3)-scaling factor-resolutie/precicion
Voltage(V)-101-111-121-0,1-1
Current(A)-102-112-122-0,001-3
Power(kW)-103-113-123-0,001-3
power_factor(pf)-104-114-124-0,01-2
energy_consumed(kWh)-106-116-126-0,01-2
energy_produced(kWh)-107-117-127-0,01-2

frequency(Hz)-135-scaling factor 0-resolutie/precicion 0  (I see a flat 50 over a 24 hour period, also in the Tuya app)
unkown 136 (I see these values in a couple of hours: 332, 339, 325, 318)
unkown 137 (I see these values in a couple of hours: 0, 8)
unkown 138 (I see these values in a couple of hours: 2, 4)

total energy consumed(kWh)-131-scaling factor 0,01-resolutie/precicion 2
Total Current(A)-132-scaling factor 0,001-resolutie/precicion 3
Total Active Power(kW)-133-scaling factor 0,001-resolutie/precicion 3
total energy produced(kWh)-139-scaling factor 0,01-resolutie/precicion 2

guidobbb avatar Oct 29 '24 15:10 guidobbb

Another newbie here - I don't want to have to start learning YAML just yet - but I would like to see support for this power meter

GreenI avatar Nov 12 '24 14:11 GreenI

It works, thanks for the tip. Changes were needed for the YAML

command_line:
  sensor:
    name: Meter PC321-W-TY
    unique_id: meter_PC321_W_TY
    command: 'python3 /config/tuya.py <device_ID>'
    device_class: power
    state_class: measurement
    unit_of_measurement: W
    scan_interval: 10
    json_attributes:
        - ActivePowerA
        - ActivePowerB
        - ActivePowerC
    value_template: "{{ value_json.ActivePower }}"

This solution however requires a cloud project on tuya developer platform. As I understood the official Tuya integration only needs user code from the app.

Good day! Tell me where exactly this piece of code needs to be entered? I can't find it(

dullabha avatar Jan 07 '25 08:01 dullabha

Hi all, Anyone who made this working mind sharing some details please for newbies? Thanks a lot...

203agent203 avatar Mar 27 '25 16:03 203agent203

Hello, I made the integration using Tuya Local (careful Not Local Tuya).... I seem to remember it was reasonably straight forward... The Power clamp and all entities were recognised, then I was able to add to the Energy dashboard. I think that you will. Need to install HACS in order to get Tuya Local

On Thu, 27 Mar 2025, 17:08 203agent203, @.***> wrote:

Hi all, Anyone who made this working mind sharing some details please for newbies? Thanks a lot...

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/115964#issuecomment-2758600489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKRNYGVLOPT5NU57XRQRBD2WQIAFAVCNFSM6AAAAABGSWLIZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONJYGYYDANBYHE . You are receiving this because you commented.Message ID: @.***> [image: 203agent203]203agent203 left a comment (home-assistant/core#115964) https://github.com/home-assistant/core/issues/115964#issuecomment-2758600489

Hi all, Anyone who made this working mind sharing some details please for newbies? Thanks a lot...

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/115964#issuecomment-2758600489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKRNYGVLOPT5NU57XRQRBD2WQIAFAVCNFSM6AAAAABGSWLIZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONJYGYYDANBYHE . You are receiving this because you commented.Message ID: @.***>

GreenI avatar Mar 27 '25 16:03 GreenI

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Hello, I made the integration using Tuya Local (careful Not Local Tuya).... I seem to remember it was reasonably straight forward... The Power clamp and all entities were recognised, then I was able to add to the Energy dashboard. I think that you will. Need to install HACS in order to get Tuya Local

Your hint regarding 'tuya local' vs 'local tuya' solved my misery. Next beer is on me, thanks a lot for your help, much appreciated!

203agent203 avatar Jun 26 '25 09:06 203agent203

Hello all,

I see from my Smart Life app that there is a firmware update available (to improve low power measurement). However, last time I made a firmware update, it broke my Tuya Local integration - and I had to redo eveything, and somehow lost the old data .... due to this I am a bit loathe to make another udate. Does anyone have experience of this firmware update - and if so how can we mitigate breaking the integration. TIA.

GreenI avatar Jun 26 '25 11:06 GreenI

I use python script method and it's working normally after upgrade.

korlcek avatar Jun 26 '25 15:06 korlcek

Thanks, guidobbb

Your info was very helpful to integrate this energy meter in my Home Assistant

Home7890 avatar Jun 27 '25 17:06 Home7890

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

this one still hasn't been solved as of today

korlcek avatar Sep 25 '25 18:09 korlcek

This is a feature request.

Please first check the diagnostic dump to ensure that the desired data is available in function/status_range/status.

  • if it is not available, you need to contact Tuya support
  • if it is available, then you need to open a feature request at https://github.com/orgs/home-assistant/discussions

epenet avatar Nov 19 '25 09:11 epenet