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 SmartThings Cover Set Position (for window shades) #96612

Merged
merged 2 commits into from Jul 18, 2023

Conversation

andrewsayre
Copy link
Member

@andrewsayre andrewsayre commented Jul 15, 2023

Proposed change

Restores the ability to set the cover position for SmartThings window shades.

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

SmartThings Edge Drivers now utilize the capability windowShadeLevel to represent the position of shades. As users are being migrated over to these new drivers, those that relied on the former switchLevel capability lost the ability in HA to set the position of their window shades. This PR adds support for the new capability while maintaining backward compabilility for switchLevel. Underlying library updates were required:

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 Black (black --fast 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:

@andrewsayre andrewsayre changed the title Fix Smartthings Cover Set Position (for window shades) Fix SmartThings Cover Set Position (for window shades) Jul 15, 2023
@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Jul 18, 2023
@emontnemery emontnemery added this to the 2023.7.3 milestone Jul 18, 2023
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @andrewsayre 👍

assert state.attributes[ATTR_CURRENT_POSITION] == 10
# Ensure API called

assert device._api.post_device_command.call_count == 1 # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize this test is following the same pattern as the existing tests, but wouldn't it make sense to check the parameters of post_device_command also to check the correct command and correct parameters are used?

This can be done in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. I don't really like the leaky abstraction of digging into the guts of the library to mock, so will explore mocking the API actually used by HA in the future.

@emontnemery emontnemery merged commit 4ae6978 into dev Jul 18, 2023
51 checks passed
@emontnemery emontnemery deleted the fix_smartthings_cover branch July 18, 2023 12:13
@github-actions github-actions bot locked and limited conversation to collaborators Jul 19, 2023
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.

New Smartthings Edge Driver for Window Shades breaks Set Position for Cover in Home Assistant
3 participants