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

Extend blebox shutterbox tilt support #110547

Conversation

swistakm
Copy link
Contributor

@swistakm swistakm commented Feb 14, 2024

Proposed change

Add CoverEntityFeature.OPEN_TILT and CoverEntityFeature.CLOSE_TILT to BleBoxCoverEntity.
The intermediary blebox_uniapi does not provide API for open/close tilt but it does have an API for setting specific tilt position. It means that open/close tilt can be achieved through set position. New API will come in future blebox_uniapi version so this change implements the feature in future-compatible way.

This PR also improves mapping of internal switchbox cover states into homeassistant states mainly by introducing proper failure states.

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:

@home-assistant
Copy link

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

Code owner commands

Code owners of blebox 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 blebox 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 blebox: extend shutterbox tilt support Extend blebox shutterbox tilt support Feb 14, 2024
@swistakm
Copy link
Contributor Author

Anything that needs to be done to move it forward?

@swistakm
Copy link
Contributor Author

@MartinHjelmare can we have another look? It is still relevant despite it is in limbo since February.

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.

Please answer the review questions and add tests for the new code to tests/components/blebox/test_cover.py

Comment on lines 68 to 70
BleboxCoverState.OVERLOAD: STATE_PROBLEM,
BleboxCoverState.MOTOR_FAILURE: STATE_PROBLEM,
Copy link
Contributor

Choose a reason for hiding this comment

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

problem is not a valid state for Home Assistant covers, have you tested this change, and it works the way you expect it to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm aware of that. As you have also noticed in other comment the same is for jammed state (which is closest conceptually to safety stop as it means engine has stopped because gate/shutter driver discovered obstacle).

It's a pity that neither STATE_JAMMED nor STATE_PROBLEM is in any way observed by HA covers. On the other hand, existence of this state here has no negative impact on integration.

What if we leave it here as is and let me figure out if I can make the base cover somehow observe problem/jammed state. This will be a bit more challenging to me as I need to look how such states are handled/implemented in other components. I could then submit such change as a separate PR so other integrations could benefit from it?

Copy link
Contributor

@emontnemery emontnemery Jun 5, 2024

Choose a reason for hiding this comment

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

I see. The end result is that the cover will in states problem and jammed get the "open" state, right? Also, this change should be moved to a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted, will submit separate PR

BleboxCoverState.OVERLOAD: STATE_PROBLEM,
BleboxCoverState.MOTOR_FAILURE: STATE_PROBLEM,
BleboxCoverState.UNUSED: None, # never used
BleboxCoverState.SAFETY_STOP: STATE_JAMMED,
Copy link
Contributor

Choose a reason for hiding this comment

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

jammed is not a valid state for Home Assistant covers, have you tested this change, and it works the way you expect it to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted, no longer relevant.

self._attr_supported_features = (
position | stop | CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changed? Is it just to make the code more readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it was meant to improve readability. I was constantly confused whether it has position and stop features.

homeassistant/components/blebox/cover.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft April 24, 2024 13:44
@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.

@swistakm swistakm force-pushed the blebox/switchbox-tilt-open-close-feature branch from e54dde6 to 30d9f3c Compare June 3, 2024 20:57
@swistakm
Copy link
Contributor Author

swistakm commented Jun 3, 2024

@emontnemery answered to the questions and added missing test

@swistakm swistakm marked this pull request as ready for review June 3, 2024 20:58
@home-assistant home-assistant bot requested a review from emontnemery June 3, 2024 20:58
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.

Please move all changes which are not related to the tilt support to a separate PR aimed to improved code quality.

Comment on lines 68 to 70
BleboxCoverState.OVERLOAD: STATE_PROBLEM,
BleboxCoverState.MOTOR_FAILURE: STATE_PROBLEM,
Copy link
Contributor

@emontnemery emontnemery Jun 5, 2024

Choose a reason for hiding this comment

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

I see. The end result is that the cover will in states problem and jammed get the "open" state, right? Also, this change should be moved to a separate PR.

@home-assistant home-assistant bot marked this pull request as draft June 5, 2024 10:08
@emontnemery
Copy link
Contributor

@swistakm Please move the unrelated changes to separate PRs so we can get this PR merged 👍

@swistakm
Copy link
Contributor Author

@emontnemery: sure! I've been swamped a little bit lately but will pick it up later this week.

@swistakm swistakm force-pushed the blebox/switchbox-tilt-open-close-feature branch from f349714 to bc0bde6 Compare August 20, 2024 13:17
@swistakm swistakm marked this pull request as ready for review August 20, 2024 13:18
@home-assistant home-assistant bot requested a review from emontnemery August 20, 2024 13:18
@swistakm
Copy link
Contributor Author

@emontnemery: reverted all the changes to BLEBOX_TO_HASS_COVER_STATES. Will submit separate PR for these changes.

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.

Thanks, @swistakm 👍

@emontnemery emontnemery merged commit 316a578 into home-assistant:dev Aug 21, 2024
26 checks passed
raman325 added a commit to raman325/home-assistant that referenced this pull request Aug 22, 2024
* dev: (642 commits)
  Improve config flow type hints (part 4) (home-assistant#124348)
  Improve config flow type hints (part 1) (home-assistant#124343)
  Add tests for Bring integration (home-assistant#123087)
  Add DROP Alert product support (home-assistant#117867)
  update ttn_client - fix crash with SenseCAP devices (home-assistant#124370)
  Add Aranet Radon Plus support (home-assistant#124197)
  Fix Spotify Media Browsing fails for new config entries (home-assistant#124368)
  Convert Bang & Olufsen testing logging patches to caplog (home-assistant#124366)
  Remove unneeded check for Bang & Olufsen events and device update (home-assistant#124363)
  Bump async-interrupt to 1.2.0 (home-assistant#124360)
  Rename OpenThermGatewayDevice to OpenThermGatewayHub (home-assistant#124361)
  Fix Weatherflow Cloud lightning (home-assistant#124082)
  Change POWER_VOLT_AMPERE_REACTIVE to UnitOfReactivePower (home-assistant#117153)
  Disable Habitica deprecated entities by default (home-assistant#123522)
  Add test cases for ViCare entities (home-assistant#122983)
  Add tests for IronOS integration (home-assistant#123078)
  Fix state name for binary_sensor Power from clear/detected to on/off (home-assistant#116994)
  Extend blebox shutterbox tilt support (home-assistant#110547)
  blebox: use blebox_uniapi.cover.BleboxCoverState enum members instead of plain integers (home-assistant#124302)
  Add custom panel for LCN configuration (home-assistant#108664)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 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.

2 participants