Fix inverted work_state on Smart Towel Rack (yghsoyzoicezv8sy)#956
Open
multinet33 wants to merge 1 commit into
Open
Fix inverted work_state on Smart Towel Rack (yghsoyzoicezv8sy)#956multinet33 wants to merge 1 commit into
multinet33 wants to merge 1 commit into
Conversation
The Tuya cloud reports the `work_state` enum (dpId 14) inverted on this
product: "heating" while the device is off/idle and "standby" while it is
actually heating. The integration forwards the raw cloud value unchanged
(value_convert "default" is not registered in tuya-device-sharing-sdk, so
the conversion is a no-op), so the sensor shows the opposite of reality.
Add a per-product value override table consulted on the report path in
XTDevice.apply_dpcode_strategy(), and register the heating<->standby swap
for product_id yghsoyzoicezv8sy. The override is keyed by
product_id -> dpcode -> {raw: corrected} and only touches reported values,
leaving writable dpcodes and all other products untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix inverted
work_stateon Smart Towel Rack (yghsoyzoicezv8sy)Problem
On a Tuya Smart Towel Rack (product_id
yghsoyzoicezv8sy, categorymjj), thework_stateenum sensor (dpId 14, range["heating", "standby"]) reports theopposite of the device's real state:
heatingstandbyThe inverted value comes straight from the Tuya cloud — a single status payload
contains
{"switch": false, "work_state": "heating"}while the rail is off. Theofficial
tuyaintegration shows the same, confirming the bad semantics are upstreamof this integration.
Why it isn't fixed today
XTDevice.apply_dpcode_strategy()callstuya_sharing.strategy.convert("default", …),but
tuya-device-sharing-sdk==0.2.8does not register adefaultstrategy andnever consults
enumMappingMap. The call raises, the exception is swallowed, and theraw cloud value is forwarded unchanged. So neither a corrected enum range nor an
enumMappingMapentry would take effect — the value must be remapped explicitly.Fix
Add a small per-product value-override table consulted on the report (read) path
inside
apply_dpcode_strategy(), keyedproduct_id -> dpcode -> {raw: corrected}, andregister the
heating ⇄ standbyswap foryghsoyzoicezv8sy.unaffected (unknown values pass through unchanged).
work_stateenum members stay within the declared range, so the sensor's enumoptions remain valid.
tuya_iot,tuya_sharingandmulti_managerupdate paths, which all funnel through
apply_dpcode_strategy().Testing
passthrough, other dpcodes/products untouched).
temp_currentclimb toward the 70 °Csetpoint while the corrected sensor now reads
heating(andstandby/off when idle).Notes / open questions
cloud_fix.pyorconst.py) if youprefer a different home — it lives in
shared_classes.pyto avoid a circular import,since that is where it is applied on every update.
local_keyinclear text. Might be worth redacting separately.
Closes #955