Skip to content

Conversation

Lukk17
Copy link

@Lukk17 Lukk17 commented Aug 5, 2025

Add support for Tuya DIN Power Meter Switch (ZCR1-40EM)

Proposed change

This PR adds support for the Tuya DIN Power Meter Switch (ZCR1-40EM).

Implemented features:

  • On/Off control
  • Power measurement (W)
  • Energy monitoring (kWh)
  • Voltage monitoring (V)
  • Current monitoring (A)
  • Power factor calculation
  • Support for power_on_state configuration

Implementation based on:

Additional information

  • Device physically tested with Home Assistant
  • Custom quirk implementation using TuyaMCUCluster
  • Added unit tests for signature matching and data conversion
  • All quirk-specific tests pass

Device specifications:

  • Maximum current: 50A
  • Voltage range: 110-250V AC
  • Power measurement accuracy: ±0.5%

Home Assistant correctly see device:
image

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

Lukk17 and others added 3 commits August 5, 2025 21:46
- Implement device signature and clusters.
- Add tests for signature matching and energy measurement conversion.
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.07%. Comparing base (ad0dc81) to head (df32885).
⚠️ Report is 19 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4236      +/-   ##
==========================================
+ Coverage   92.05%   92.07%   +0.02%     
==========================================
  Files         350      351       +1     
  Lines       11602    11679      +77     
==========================================
+ Hits        10680    10754      +74     
- Misses        922      925       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Refactor electrical measurements test for clarity.
- Add new tests for energy data conversion.
- Implement tests for command handling and attribute updates.
@TheJulianJES TheJulianJES added Tuya Request/PR regarding a Tuya device needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). labels Aug 24, 2025
@TheJulianJES TheJulianJES changed the title Add Tuya TS0601 DIN Power Meter Switch ZCR1-40EM support. Add Tuya TS0601 DIN power meter switch ZCR1-40EM support Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants