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

Fix TuyaDPType.VALUE payload #1984

Merged
merged 1 commit into from
Dec 4, 2022
Merged

Conversation

javicalle
Copy link
Collaborator

During the analisys of #1554 I have realized that something was wrong in the MCU logs for the LevelControl.
Comparing the status report from the device against the command send from HA it was clear that something don't work as expected:

2022-10-23 13:57:40.824 DEBUG (MainThread) [zigpy.zcl] [0x6F8F:1:0xef00] Received command 0x01 (TSN 101): get_data(data=
TuyaCommand(status=0, tsn=71, datapoints=[TuyaDatapointData(dp=2, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\xfa\x00\x00\x00', *payload=250))]))

2022-10-23 13:57:41.933 DEBUG (MainThread) [zigpy.zcl] [0x6F8F:1:0xef00] tuya_command: 
TuyaCommand(status=0, tsn=97, datapoints=[TuyaDatapointData(dp=2, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x02\x8a', *payload=2315386880))])

Once identified and the fixed, the tests that validated against the observed value have also had to be fixed.

The fix only affects to the MCU commands sended with a TuyaDPType.VALUE (i.e: current_level for the LevelControl cluster). I can't be a breaking change because the current implementation is wrong. I don't think that could be the reason for some weird behavior in dimmers but I can't validate by myself.

@codecov-commenter
Copy link

Codecov Report

Base: 83.16% // Head: 83.16% // No change to project coverage 👍

Coverage data is based on head (7e52934) compared to base (05ee519).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1984   +/-   ##
=======================================
  Coverage   83.16%   83.16%           
=======================================
  Files         248      248           
  Lines        7819     7819           
=======================================
  Hits         6503     6503           
  Misses       1316     1316           
Impacted Files Coverage Δ
zhaquirks/tuya/mcu/__init__.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

Pull Request Test Coverage Report for Build 3614545245

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 83.169%

Totals Coverage Status
Change from base Build 3577832421: 0.0%
Covered Lines: 6503
Relevant Lines: 7819

💛 - Coveralls

@dmulcahey dmulcahey merged commit ad9ad33 into zigpy:dev Dec 4, 2022
@javicalle
Copy link
Collaborator Author

Thanks David

@javicalle javicalle deleted the fix_mcu_payload branch December 4, 2022 23:36
Shulyaka added a commit to Shulyaka/zha-device-handlers that referenced this pull request Dec 5, 2022
dmulcahey pushed a commit that referenced this pull request Dec 7, 2022
* tuya mcu enhancements

* python3.9 compatibility fix

* fix to update multiple datapoints on attribute write

* lint

* reverse byte order of TuyaReverseStruct due to #1984

* apply suggestions from code review
javicalle added a commit to javicalle/zha-device-handlers that referenced this pull request Dec 8, 2022
@javicalle javicalle mentioned this pull request Dec 8, 2022
@javicalle javicalle restored the fix_mcu_payload branch December 10, 2022 22:36
dmulcahey pushed a commit that referenced this pull request Dec 12, 2022
* Revert PR #1984

* Update test_tuya_dimmer.py

* Update test_tuya_mcu.py

* Update test_tuya_valve.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants