Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for Tongou circuit breaker (#2005) #2008

Closed
wants to merge 4 commits into from

Conversation

zleba
Copy link

@zleba zleba commented Dec 11, 2022

Related to #2005
The device is the following one
https://zigbee.blakadder.com/Tongou_TO-Q-SY1-JZT.html

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2022

Codecov Report

Base: 83.09% // Head: 83.09% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (5765ef1) compared to base (792d7e2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2008   +/-   ##
=======================================
  Coverage   83.09%   83.09%           
=======================================
  Files         248      248           
  Lines        7860     7863    +3     
=======================================
+ Hits         6531     6534    +3     
  Misses       1329     1329           
Impacted Files Coverage Δ
zhaquirks/tuya/ts011f_plug.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@coveralls
Copy link

coveralls commented Dec 11, 2022

Pull Request Test Coverage Report for Build 3673959930

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 83.098%

Totals Coverage Status
Change from base Build 3638608563: 0.006%
Covered Lines: 6534
Relevant Lines: 7863

💛 - Coveralls

Comment on lines +129 to +133
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont deleting the Zigbee GP endpoint in the replacement is one part of the device function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will keep the 242 endpoint, what confused me was that the "Plug" class does not keep it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, what is the meaning of the 0x402 cluster, it reports as "temperature" but the value is constant and always "-630" so it has likely some other meaning...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zleba I confirm it on my batch (all 4 show this, and it's certainly not a temperature), I think you are on the right path to ignore this reading, it's also not in the manual (as you confirmed here )

@zleba
Copy link
Author

zleba commented Dec 11, 2022

"Temperature" seems to have other meaning in reality and there is also a problem with the "Power factor" which is a typical problem for the Tuya plugs.
The "Power factor" can be calculated as
"Active power" / ("RMS current" * "RMS voltage"),
where all 3 numbers are available.


Screenshot from 2022-12-11 22-56-54

@javicalle
Copy link
Collaborator

0x0402 is the TemperatureMeasurement cluster:
https://github.com/zigpy/zigpy/blob/a5ae12efc6510df9c487e775bef7af8937ad85f5/zigpy/zcl/clusters/measurement.py#L72

Add the import at the top of the file and use it

@zleba
Copy link
Author

zleba commented Dec 12, 2022

@javicalle , for me it looks like it doesn't measure the temperature, we really don't have -6.3C all the time.
Also in the user guide, there is no mention of the temperature.
Maybe the manufacturer just used some non-standard labelling of the cluster.

Is there a way to remove this cluster until we understand what is stored inside?

2022-12-12 08:26:10.365 DEBUG (MainThread) [zigpy.zcl] [0x9C67:1:0x0402] Received ZCL frame: b'\x18\x12\n\x00\x00)\x8a\xfd'
2022-12-12 08:26:10.366 DEBUG (MainThread) [zigpy.zcl] [0x9C67:1:0x0402] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True, *is_reply=True), tsn=18, command_id=10, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2022-12-12 08:26:10.368 DEBUG (MainThread) [zigpy.zcl] [0x9C67:1:0x0402] Decoded ZCL frame: TemperatureMeasurement:Report_Attributes(attribute_reports=[Attribute(attrid=0x0000, value=TypeValue(type=int16s, value=-630))])
2022-12-12 08:26:10.369 DEBUG (MainThread) [zigpy.zcl] [0x9C67:1:0x0402] Received command 0x0A (TSN 18): Report_Attributes(attribute_reports=[Attribute(attrid=0x0000, value=TypeValue(type=int16s, value=-630))])
2022-12-12 08:26:10.372 DEBUG (MainThread) [zigpy.zcl] [0x9C67:1:0x0402] Attribute report received: measured_value=-630

@javicalle
Copy link
Collaborator

Sure, remove it in the replacement section (only here).

@MattWestb
Copy link
Contributor

If no one have "found" what tuya is using it for i think omitting its the best for not getting complains from users.
If some have one tuya ZBGW and can look what data they is using and sniffing if its needed we can "finding" what is being used for and implanting it.

@zleba
Copy link
Author

zleba commented Dec 12, 2022

@javicalle @MattWestb Ok, can I do something with the "Power factor" to not be displayed as "Unknown"?

@@ -95,6 +95,73 @@ class Plug(EnchantedDevice):
}


class CircuitBreaker(EnchantedDevice):
"""Tuya smart circuit breaker with metering (_TZ3000_qeuvnohg) https://www.aliexpress.com/item/1005004747066832.html."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, is it a permanent link or it can become inaccessible earlier than the product itself?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove it and also the _TZ3000_qeuvnohg reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zleba thanks for your contribution, maybe point to Tongou TO-Q-SY1-JZT rather?

Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
0x0402, # unknown meaning, it is not temperature
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the from zigpy.zcl.clusters.measurement import TemperatureMeasurement (between the TemperatureMeasurement and the Metering) and use the TemperatureMeasurement.cluster_id

@@ -95,6 +95,73 @@ class Plug(EnchantedDevice):
}


class CircuitBreaker(EnchantedDevice):
"""Tuya smart circuit breaker with metering (_TZ3000_qeuvnohg) https://www.aliexpress.com/item/1005004747066832.html."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove it and also the _TZ3000_qeuvnohg reference.

@Shulyaka
Copy link
Contributor

Ok, can I do something with the "Power factor" to not be displayed as "Unknown"?

ZHA adds this sensor automatically. A user can disable the entity with UI.

But as you correctly pointed out, you can calculate the value, here is my example:
c7df85f#diff-e9e69504176ec01e00193622a35fe1bb09552546852ca23d1648d97655dbf73dR260

@Shulyaka
Copy link
Contributor

By the way, ZHA expects this value in permille, which differs from the ZCL specification.

@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Jan 16, 2023
@TheJulianJES TheJulianJES added the waiting for changes Waiting for changes to the PR label Jan 25, 2023
@arsenyspb
Copy link
Contributor

arsenyspb commented Mar 5, 2023

Hi @zleba thank you this quirk PR to support of ZHA community 🤝 🙇 👍 Tongou TO-Q-SY1-JZT is popular: there were no mentions of it till Q3/22, but now a spike in issues and asks all over community.

I'm sure you may have seen it that Z2M's got workaround for division by 100 of summation and A to mA with division by 1000. I'm not sure how this would be solved in ZHA at the moment, but maybe you can add instructions for community in your original issue?

UPDATE: I got it how quirk works, following @javicalle 's hint here, and once quirk is installed this problem are gone through tuya/__init__.py

Really looking forward to seeing this PR merged.

UPDATE: I tried to push update zleba:tuyaCircuitBreaker but I totally forgot that it's only available for maintainers.

@TheJulianJES
Copy link
Collaborator

TheJulianJES commented Mar 7, 2023

Thanks for your contribution @zleba. The changes (and more) are included in:

TheJulianJES pushed a commit that referenced this pull request Mar 7, 2023
* Add `_TZ3000_qeuvnohg` Tongou TO-Q-SY1-JZT Tuya circuit breaker support

Original issue: #200
Original PR: #2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tuya Request/PR regarding a Tuya device waiting for changes Waiting for changes to the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for TUYA ZigBee Smart Circuit Breaker [TS011F _TZ3000_qeuvnohg]
8 participants