Skip to content

Conversation

@nschimme
Copy link

@nschimme nschimme commented Nov 20, 2025

Proposed change

This allows soil moisture and humidity to both been seen. Previously, only temperature, soil moisture, and battery were shown. Even worse, soil moisture was incorrectly displayed as humidity due to it being reported under cluster 0x405.

Additional information

Other attempts to add support via the TuyaQuirkBuilder did not work because of how soil moisture would overwrite the humidity since they all shared the same endpoint. This quirk now uses endpoints 2 and 3 for Soil Moisture (DP 3) and Relative Humidity (DP 109), respectively. This prevents values from being overwritten when they are reported simultaneously by the device, ensuring stable readings for both attributes. We also drop the 0x405 cluster that was incorrectly reporting soil as humidity.

image

Device diagnostics

zha-01K8BQMJSKZFPA3YC43C2Q4TB0-HOBEIAN ZG-303Z-8ec34d4e404ba4a5f4ec9dcf4bc9e3c8-2.json

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
  • Device diagnostics data has been attached

@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.25%. Comparing base (bf73aa9) to head (1127707).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #4510   +/-   ##
=======================================
  Coverage   92.24%   92.25%           
=======================================
  Files         369      370    +1     
  Lines       12094    12109   +15     
=======================================
+ Hits        11156    11171   +15     
  Misses        938      938           

☔ 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.

The HOBEIAN ZG-303Z quirk now uses endpoints 2 and 3 for Soil
Moisture (DP 3) and Relative Humidity (DP 109), respectively. This
prevents values from being overwritten when they are reported
simultaneously by the device, ensuring stable readings for both
attributes.
@nschimme
Copy link
Author

nschimme commented Nov 21, 2025

@TheJulianJES this is ready to go. I've looked at what is needed to enhance the V2 API to do the same thing and it doesn't look trivial. I suggest we do it in a second pass.

@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Nov 21, 2025
@mjbogusz
Copy link

So far (few hours) this works way better than previous ones, though it would be nice to re-add the low moisture warning and configuration/calibration endpoints - it could be a followup though to get this merged sooner.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants