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

Refactored common curtain/tilt code to shared base class #231

Merged
merged 21 commits into from
Feb 11, 2024

Conversation

dcmeglio
Copy link
Contributor

This is still a WIP (haven't tested at all yet except running existing unit tests) but wanted to see if this was along the lines you were thinking before I go too far down this road.

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (7894a85) 51.38% compared to head (3cd8503) 58.59%.

Files Patch % Lines
switchbot/devices/blind_tilt.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #231      +/-   ##
==========================================
+ Coverage   51.38%   58.59%   +7.21%     
==========================================
  Files          33       34       +1     
  Lines        1444     1495      +51     
==========================================
+ Hits          742      876     +134     
+ Misses        702      619      -83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco
Copy link
Collaborator

bdraco commented Feb 10, 2024

Seems like a reasonable path forward

tests/test_blind_tilt.py Outdated Show resolved Hide resolved
tests/test_blind_tilt.py Outdated Show resolved Hide resolved
tests/test_blind_tilt.py Outdated Show resolved Hide resolved
@dcmeglio
Copy link
Contributor Author

Other than that assumed bug which I'm now almost positive about looking at get_extended_info_adv I've added code coverage and unit tests for my changes. I'm going to work on some formatting cleanups and also still need to test with some actual devices. Otherwise I think this should fix the issue.

@bdraco
Copy link
Collaborator

bdraco commented Feb 10, 2024

You can probably do

isort switchbot
black switchbot
ruff --fix switchbot

@bdraco
Copy link
Collaborator

bdraco commented Feb 10, 2024

I'll test this tomorrow

@dcmeglio
Copy link
Contributor Author

My tilt won't be here for a few days so I can't test that, but my curtains still work fully and the is_opening/is_closing are still fine too. I'm going to consider this ready for review. Let me know how your testing goes. It should just require a version bump in HA.

Technically this is a breaking change in the API since the base class for the Tilt has been changed? If someone was relying on Tilt inheriting from Curtain, this will now cause an issue.

@dcmeglio dcmeglio marked this pull request as ready for review February 11, 2024 02:07
@bdraco
Copy link
Collaborator

bdraco commented Feb 11, 2024

Technically this is a breaking change in the API since the base class for the Tilt has been changed? If someone was relying on Tilt inheriting from Curtain, this will now cause an issue.

That's a stretch for a breaking change. Should be ok

@dcmeglio
Copy link
Contributor Author

People are reporting it still happens with this code. I’m not spotting the issue right now. Might have to wait till my tilt arrives

@bdraco bdraco changed the title Refactored common curtain/tilt code to shared base class. Refactored common curtain/tilt code to shared base class Feb 11, 2024
@bdraco
Copy link
Collaborator

bdraco commented Feb 11, 2024

I did some adjustments. I think the blind tilt now has all the previous methods so it should work now

@bdraco
Copy link
Collaborator

bdraco commented Feb 11, 2024

Device just showed up

Charging it now

Will test shortly.

@bdraco
Copy link
Collaborator

bdraco commented Feb 11, 2024

Its working with the latest changes I pushed

@bdraco bdraco merged commit 857597b into Danielhiversen:master Feb 11, 2024
6 checks passed
@bdraco
Copy link
Collaborator

bdraco commented Feb 11, 2024

Thanks @dcmeglio

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.

None yet

3 participants