home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.93k stars 30.98k forks source link

PC321-TY Single/3-phase Power Clamp unsupported #115964

Open lassehol opened 7 months ago

lassehol commented 7 months ago

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

home-assistant[bot] commented 7 months ago

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)

Testingfor101 commented 6 months ago

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

vahvakarhu commented 6 months ago

Same problem

mateuszbrzezinski commented 6 months ago

Same problem, bump

Grey-Lancaster commented 6 months ago

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

bachihans commented 5 months ago

Same problem

nehu187 commented 4 months ago

Same here

GBRAVOG commented 3 months ago

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

FreemanJD commented 2 months ago

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

gomusan commented 2 months ago

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

gomusan commented 2 months ago

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

FreemanJD commented 2 months ago

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.

korlcek commented 1 month ago

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.

lassehol commented 1 month ago

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: @.***>

korlcek commented 1 month ago

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.

guidobbb commented 3 weeks ago

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
GreenI commented 1 week ago

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