10000 Fix BulbDevice for non-bulb devices by uzlonewolf · Pull Request #620 · jasonacox/tinytuya · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix BulbDevice for non-bulb devices #620

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

Merged
merged 4 commits into from
May 31, 2025

Conversation

uzlonewolf
Copy link
Collaborator

Some people may use BulbDevice as a default even for non-bulb devices, and turn_on()/turn_off() should still work even in that case. See #572

@uzlonewolf uzlonewolf mentioned this pull request May 29, 2025
@jasonacox jasonacox requested a review from Copilot May 31, 2025 17:56
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates BulbDevice so that turn_on()/turn_off() will work even when used on non-bulb devices by falling back to DP 1, tracks if status was attempted, and hardens capability mapping.

  • Bump version to 1.17.1
  • Replace obsolete retry attributes with a tried_status flag and modify turn_onoff to detect a bulb once and default to DP 1
  • Add a type check in set_bulb_capabilities to ensure mapping is always a dict

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tinytuya/core/core.py Bumped version_tuple to (1, 17, 1)
tinytuya/BulbDevice.py Replaced old retry fields with tried_status, updated turn_onoff and added mapping type check
tests.py Added tests for explicit bulb type and non-bulb fallback behavior
Comments suppressed due to low confidence (3)

tinytuya/BulbDevice.py:406

  • [nitpick] The docstring should be updated to note that when no switch DP is detected, this method now defaults to DP '1' for non-bulb devices.
def turn_onoff(self, on, switch=0, nowait=False):

tinytuya/BulbDevice.py:899

  • [nitpick] Consider adding a unit test for set_bulb_capabilities to verify that passing a non-dict (e.g., None) correctly falls back to an empty mapping.
if not isinstance( mapping, dict ):

tinytuya/core/core.py:96

  • [nitpick] Indentation appears inconsistent with surrounding top-level declarations; align this line to match the project style.
version_tuple = (1, 17, 1)  # Major, Minor, Patch

@jasonacox jasonacox merged commit 3b6c0f6 into jasonacox:master May 31, 2025
14 checks passed
@jasonacox
Copy link
Owner

View at:
https://pypi.org/project/tinytuya/1.17.1/

Thanks @uzlonewolf !

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.

2 participants
0