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

Support Tuya AM43(Zigbee) Blind drive motor #110629

Closed
wants to merge 0 commits into from

Conversation

nao-pon
Copy link

@nao-pon nao-pon commented Feb 15, 2024

Breaking change

Proposed change

  • Support for product_id "zah67ekd"
  • Addition of is_opening, is_closing properties
  • Support for devices whose Open/Close status is reversed

The existing curtain settings were unstable in supporting AM43 (Zigbee), so I fixed it.

I've fixed it for backwards compatibility, but please let us know if you encounter any problems.

The following is the debug log for AM43 (Zigbee).

2023-11-28 10:15:44.604 DEBUG (MainThread) [custom_components.smartlife] dpcode get device=CustomerDevice(active_time=1700483147, biz_type=18, category='cl', create_time=1700483147, icon='smart/icon/ay1520042877959dqQoX/cabc06d56803a5a189c9fff9fc78c56b.png', id='ebc769bdeae5xxxxxxxxxx', ip='', lat='xx.2500', local_key='xxxxxxxxxxxxxxxx', lon='xxx.8800', model='AM43', name='AM43-Zigbee', node_id='048727fffe4f23b7', online=True, owner_id='xxxxxxxxx', product_id='zah67ekd', product_name='AM43拉绳电机-Zigbee', status={'control': 'stop', 'percent_control': 0, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}, sub=True, time_zone='+09:00', uid='xxxxxxxxxxxxxxxxxxxx', update_time=1700483147, uuid='xxxxxxxxxxxxxxxx', function={'control': DeviceFunction(code='control', type='Enum', values='{"range":["open","stop","close","continue"]}'), 'percent_control': DeviceFunction(code='percent_control', type='Integer', values='{"unit":"%","min":0,"max":100,"scale":0,"step":1}'), 'control_back_mode': DeviceFunction(code='control_back_mode', type='Enum', values='{"range":["forward","back"]}')}, status_range={'control': DeviceStatusRange(code='control', type='Enum', values='{"range":["open","stop","close","continue"]}'), 'percent_control': DeviceStatusRange(code='percent_control', type='Integer', values='{"unit":"%","min":0,"max":100,"scale":0,"step":1}'), 'percent_state': DeviceStatusRange(code='percent_state', type='Integer', values='{"unit":"%","min":0,"max":100,"scale":0,"step":1}'), 'control_back_mode': DeviceStatusRange(code='control_back_mode', type='Enum', values='{"range":["forward","back"]}'), 'work_state': DeviceStatusRange(code='work_state', type='Enum', values='{"range":["opening","closing"]}'), 'situation_set': DeviceStatusRange(code='situation_set', type='Enum', values='{"range":["fully_open","fully_close"]}'), 'fault': DeviceStatusRange(code='fault', type='Bitmap', values='{"label":["motor_fault"]}')}, support_local=True, local_strategy={1: {'value_convert': 'default', 'status_code': 'control', 'config_item': {'statusFormat': '{"control":"$"}', 'valueDesc': '{"range":["open","stop","close","continue"]}', 'valueType': 'Enum', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}, 2: {'value_convert': 'default', 'status_code': 'percent_control', 'config_item': {'statusFormat': '{"percent_control":"$"}', 'valueDesc': '{"unit":"%","min":0,"max":100,"scale":0,"step":1}', 'valueType': 'Integer', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}, 3: {'value_convert': 'default', 'status_code': 'percent_state', 'config_item': {'statusFormat': '{"percent_state":"$"}', 'valueDesc': '{"unit":"%","min":0,"max":100,"scale":0,"step":1}', 'valueType': 'Integer', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}, 5: {'value_convert': 'default', 'status_code': 'control_back_mode', 'config_item': {'statusFormat': '{"control_back_mode":"$"}', 'valueDesc': '{"range":["forward","back"]}', 'valueType': 'Enum', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}, 7: {'value_convert': 'default', 'status_code': 'work_state', 'config_item': {'statusFormat': '{"work_state":"$"}', 'valueDesc': '{"range":["opening","closing"]}', 'valueType': 'Enum', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}, 11: {'value_convert': 'default', 'status_code': 'situation_set', 'config_item': {'statusFormat': '{"situation_set":"$"}', 'valueDesc': '{"range":["fully_open","fully_close"]}', 'valueType': 'Enum', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}, 12: {'value_convert': 'default', 'status_code': 'fault', 'config_item': {'statusFormat': '{"fault":"$"}', 'valueDesc': '{"label":["motor_fault"]}', 'valueType': 'Bitmap', 'enumMappingMap': {}, 'pid': 'zah67ekd'}}}, set_up=True) dpcode=percent_state key=status_range


2023-11-28 10:10:41.995 DEBUG (SyncWorker_7) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.CONTROL: 'control'>, 'value': 'open'}, {'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 100}]
2023-11-28 10:10:43.995 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'open', 'percent_control': 0, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:10:52.555 DEBUG (SyncWorker_6) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.CONTROL: 'control'>, 'value': 'open'}, {'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 100}]
2023-11-28 10:10:53.731 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'open', 'percent_control': 0, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:10:54.099 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 0, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:04.088 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 100, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:15.370 DEBUG (SyncWorker_0) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.CONTROL: 'control'>, 'value': 'close'}, {'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 0}]
2023-11-28 10:11:16.527 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 100, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:26.152 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 100, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:26.379 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 0, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:38.585 DEBUG (SyncWorker_9) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 50}]
2023-11-28 10:11:41.131 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 50, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:41.324 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 50, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:41.482 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'open', 'percent_control': 50, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:46.196 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'open', 'percent_control': 50, 'percent_state': 50, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:46.526 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 50, 'percent_state': 50, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:49.138 DEBUG (SyncWorker_4) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 100}]
2023-11-28 10:11:49.983 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 100, 'percent_state': 50, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:54.135 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device eb449b2a4186c3092d7l5s: {'control': 'stop', 'percent_control': 3, 'percent_state': 3, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:11:55.164 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 100, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:00.993 DEBUG (SyncWorker_1) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 50}]
2023-11-28 10:12:02.144 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 50, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:02.275 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 50, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:03.462 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 50, 'percent_state': 100, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:04.619 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device eb449b2a4186c3092d7l5s: {'control': 'stop', 'percent_control': 3, 'percent_state': 3, 'control_back_mode': 'back', 'work_state': 'opening', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:07.229 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 50, 'percent_state': 49, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:07.461 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 50, 'percent_state': 49, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:09.682 DEBUG (SyncWorker_2) [custom_components.smartlife] Sending commands for device ebc769bdeae5xxxxxxxxxx: [{'code': <DPCode.PERCENT_CONTROL: 'percent_control'>, 'value': 0}]
2023-11-28 10:12:11.400 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 50, 'percent_state': 49, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:16.291 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'close', 'percent_control': 50, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}
2023-11-28 10:12:16.382 DEBUG (Thread-7 (_thread_main)) [custom_components.smartlife] Received update for device ebc769bdeae5xxxxxxxxxx: {'control': 'stop', 'percent_control': 50, 'percent_state': 0, 'control_back_mode': 'back', 'work_state': 'closing', 'situation_set': 'fully_open', 'fault': 0}

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@nao-pon nao-pon requested a review from frenck as a code owner February 15, 2024 07:33
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @nao-pon

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this pull request as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tuya can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign tuya Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@MartinHjelmare MartinHjelmare changed the title [Tuya] Support AM43(Zigbee) Blind drive motor Support Tuya AM43(Zigbee) Blind drive motor Feb 15, 2024
@nao-pon nao-pon marked this pull request as ready for review February 16, 2024 01:12
@nao-pon nao-pon force-pushed the tuya_am43 branch 2 times, most recently from cc123fb to 75392ae Compare May 13, 2024 16:42
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

There is a merge conflict.

@home-assistant home-assistant bot marked this pull request as draft May 13, 2024 16:42
@nao-pon nao-pon closed this May 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants