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

Initial Blind Tilt support #181

Merged
merged 10 commits into from
Jan 25, 2023

Conversation

jesserockz
Copy link
Contributor

@jesserockz jesserockz commented Jan 7, 2023

closes #172

Co-authored-by: Ben Morton <ben.morton91@gmail.com>
Comment on lines 15 to 19
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Switchbot Blind Tilt/woBlindTilt constructor."""

super().__init__(*args, **kwargs)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Switchbot Blind Tilt/woBlindTilt constructor."""
super().__init__(*args, **kwargs)

Looks like a useless constructor?

@BTMorton
Copy link
Contributor

I'm wondering if it's worth doing open, close_up, and close_down methods for the blind tilts like offered in the app, rather than just open/close like the curtains. Not 100% sure how Home Assistant would handle it. Might result in only supporting open and one of the two close directions, but it would better reflect the unit's actual behaviour. Happy to do the impl?

Also, should there be another helper method in discovery.py?

    async def get_blind_tilts(self) -> dict[str, SwitchBotAdvertisement]:
        """Return all WoBlindTilt/BlindTilts devices with services data."""
        return await self._get_devices_by_model("x")

Add support for discovering curtains in pairing mode
Fix calibrated status bit parsing
Update default reverse mode to be disabled
Add open/close_up/close_down/close blind tilt methods
@BTMorton
Copy link
Contributor

I did the changes I proposed to add close_up/close_down methods in a new branch, and did an integration with Home Assistant. This is tested and running with the blind tilt devices in my local install.

Lib changes: master...BTMorton:pySwitchbot:add_blind_tilt_support
HA integration: home-assistant/core@dev...BTMorton:home-assistant-core:add-switchbot-blind-tilt-support

It works pretty nicely as an integration as it matches the up/down arrows in the UI. The problem is that the behaviour isn't super intuitive from the cover service naming. Calling "open" when the blind is already open will close the blind up, because the "open" arrow in the UI points up. Likewise when it's closed, calling "close" will open the blind. It makes sense from an interface perspective, but not so much on the automation front.

There's potentially a limitation in the base cover tilt implementation in that it doesn't seem to support bi-directional closing. Making an assumption and limiting it to close one-way or the other will upset someone somewhere, although it could be worked around by calibrating the device in reverse.

This solution was a "light-touch" way to add full support. I'll leave it to you guys to decide next steps.

If this is the wrong place to put this, let me know and I can re-post somewhere more appropriate.

@bdraco
Copy link
Collaborator

bdraco commented Jan 15, 2023

@BTMorton maybe send a PR to Jesse's branch?

@jesserockz
Copy link
Contributor Author

Please feel free to PR into this branch. I have had no time myself to look into this so I am glad someone is.

In regards to the HA side, I did implement it a little, but because this is setting the tilt of a curtain/blind, I made the entity only support tilt, not actual position with open/close functions which better represents what it actually is. Feel free to disagree there.

@jesserockz jesserockz marked this pull request as ready for review January 25, 2023 03:54
@jesserockz
Copy link
Contributor Author

With the suggestions by @BTMorton merged, this now opens and closes nicely from HA. The default HA frontend controls don't like to allow open when the position is already at 100, but the service calls to open work, and it opens to 50% nicely.

@bdraco bdraco merged commit fbd0cfc into Danielhiversen:master Jan 25, 2023
@jesserockz jesserockz deleted the jesserockz-2023-001 branch January 25, 2023 22:40
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.

Adding support for new SwitchBot Blind Tilt
3 participants