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

Add Tuya Dimmer _TZE204_zenj4lxv variation #2661

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

danielgomezrico
Copy link
Contributor

@danielgomezrico danielgomezrico commented Oct 19, 2023

Proposed change

This dimmer is currently paired but does not expose any entity.

Fix: #2628

Additional information

It does not seems like a breaking change

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (28da816) 86.62% compared to head (dc0b40d) 86.62%.
Report is 1 commits behind head on dev.

❗ Current head dc0b40d differs from pull request most recent head 48dd13f. Consider uploading reports for the commit 48dd13f to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2661   +/-   ##
=======================================
  Coverage   86.62%   86.62%           
=======================================
  Files         279      279           
  Lines        8551     8551           
=======================================
  Hits         7407     7407           
  Misses       1144     1144           
Files Coverage Δ
zhaquirks/tuya/ts0601_dimmer.py 100.00% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danielgomezrico
Copy link
Contributor Author

Im not sure how to add the tests and how to test this with the device before merging, any hints?

@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Oct 19, 2023
@TheJulianJES
Copy link
Collaborator

Thanks for the PR! You don't need to add any unit tests for this small change.

For testing this, download the modified file and put it into a custom quirks folder in your /config directory.
Then, register that custom quirks folder in your configuration.yaml and restart HA. Check if the (custom) quirk loads for the device and if the entities work.

This is what you want in your configuration.yaml (and name the folder custom_zha_quirks, just put the .py file in there)
#693 (comment)

@danielgomezrico
Copy link
Contributor Author

@TheJulianJES I found that it does not work, I get:

2023-10-19 14:19:37.829 DEBUG (MainThread) [zigpy.zcl] [0x3B11:1:0xef00] Received command 0x02 (TSN 121): b'\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e'
2023-10-19 14:19:37.830 DEBUG (MainThread) [zigpy.zcl] [0x3B11:1:0xef00] No explicit handler for cluster command 0x02: b'\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e'
2023-10-19 14:19:37.831 DEBUG (Thread-10) [aiosqlite] executing functools.partial(<built-in method execute of sqlite3.Connection object at 0x7f85d45120>, 'UPDATE devices_v12\n SET last_seen=:ts\n WHERE ieee=:ieee AND :ts - last_seen > :min_update_delta', {'ts': 1697743177.827209, 'ieee': a4:c1:38:39:9e:1e:3d:0d, 'min_update_delta': 30.0})
2023-10-19 14:19:37.833 DEBUG (Thread-10) [aiosqlite] operation functools.partial(<built-in method execute of sqlite3.Connection object at 0x7f85d45120>, 'UPDATE devices_v12\n SET last_seen=:ts\n WHERE ieee=:ieee AND :ts - last_seen > :min_update_delta', {'ts': 1697743177.827209, 'ieee': a4:c1:38:39:9e:1e:3d:0d, 'min_update_delta': 30.0}) completed
2023-10-19 14:19:37.836 DEBUG (Thread-10) [aiosqlite] executing functools.partial(<built-in method commit of sqlite3.Connection object at 0x7f85d45120>)
2023-10-19 14:19:37.836 DEBUG (Thread-10) [aiosqlite] operation functools.partial(<built-in method commit of sqlite3.Connection object at 0x7f85d45120>) completed
2023-10-19 14:19:38.017 DEBUG (bellows.thread_0) [bellows.uart] Data frame: b'74a0b1a9112a15b65894a524ab5593499c26771bfcf59874f0cf1a8bfcaa2ba5ebc91e7c94f1d03c7e'
2023-10-19 14:19:38.018 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'8070787e'
2023-10-19 14:19:38.022 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame received incomingMessageHandler: [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=61184, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=104), 80, -80, 0x3b11, 255, 255, b'\ty\x02\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e']
2023-10-19 14:19:38.023 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=61184, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=104), 80, -80, 0x3b11, 255, 255, b'\ty\x02\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e']
2023-10-19 14:19:38.023 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x3B11), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=104, profile_id=260, cluster_id=61184, data=Serialized[b'\ty\x02\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=80, rssi=-80)
2023-10-19 14:19:38.024 DEBUG (MainThread) [zigpy.zcl] [0x3B11:1:0xef00] Received ZCL frame: b'\ty\x02\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e'
2023-10-19 14:19:38.025 DEBUG (MainThread) [zigpy.zcl] [0x3B11:1:0xef00] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=0, reserved=0, *is_cluster=True, *is_general=False), tsn=121, command_id=2, *direction=<Direction.Client_to_Server: 1>)
2023-10-19 14:19:38.025 WARNING (MainThread) [zigpy.zcl] [0x3B11:1:0xef00] Unknown cluster command 2 b'\x00\xd4\x14\x02\x00\x04\xc0\x13\x1b\x0e'

I will try to debug it better, thanks for the help

@danielgomezrico danielgomezrico marked this pull request as draft October 19, 2023 19:25
@TheJulianJES
Copy link
Collaborator

Does the custom quirk load at least?
(Can be verified by seeing if a "quirk" section not starting with zhaquirks. is present on the device page (when expanding the info on the left))

@danielgomezrico
Copy link
Contributor Author

danielgomezrico commented Oct 19, 2023

Oh no,
I can see this log:

2023-10-19 14:18:04.999 WARNING (MainThread) [zhaquirks] Loaded custom quirks. Please contribute them to https://github.com/zigpy/zha-device-handlers

But I can't find that section on the device info:
image

@danielgomezrico
Copy link
Contributor Author

It now appears!

Quirk: ts0601_dimmer.TuyaDoubleSwitchDimmerGP

It only appeared on the GP class, but Im not sure what a green power (GP) means and now I see the lights:
image

@danielgomezrico danielgomezrico marked this pull request as ready for review October 19, 2023 20:16
@danielgomezrico
Copy link
Contributor Author

danielgomezrico commented Oct 20, 2023

@TheJulianJES can you put this label on the pr? hacktoberfest-accepted

It will help me to participate on this https://hacktoberfest.com

@TheJulianJES TheJulianJES added the hacktoberfest-accepted PR is accepted to count towards the Hacktoberfest PR count. label Oct 20, 2023
@TheJulianJES
Copy link
Collaborator

Sure, I plan on doing that for all PRs that aren't merged in time.

Yours should be ready for merging now, right? Like, the device works as expected with the changes now?

Regarding ZigbeeGreenPower:
The GreenPower clusters are for energy harvesting devices to communicate with. If your mains-powered device provides them, it doesn't make a big difference other than that you need to put it into a different quirk (signature) which you seem to have done now.

@danielgomezrico
Copy link
Contributor Author

Thanks for the GP explanation :)

Yeah, it works, it lets me turn on and off and even dim my lights.

One part that I haven't been able to fully test is the dimmer because my lights are not dimerizable. I see that they are put lower and bigger in light, but occasionally, they flash badly, I fear that If I continue in that way it will crush my lights. :P

Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks again!

@TheJulianJES TheJulianJES changed the title Add Tuya Dimmer _TZE204_zenj4lxv Add Tuya Dimmer _TZE204_zenj4lxv variation Oct 20, 2023
@TheJulianJES TheJulianJES merged commit 32e956c into zigpy:dev Oct 20, 2023
elupus pushed a commit to elupus/zha-device-handlers that referenced this pull request Jan 17, 2024
lgraf pushed a commit to lgraf/zha-device-handlers that referenced this pull request May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted PR is accepted to count towards the Hacktoberfest PR count. Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Device Support Request] MOES Star Ring 2 gang Zigbee smart dimmer switch
2 participants