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

Clarify meaning of filter_status property #480

Merged
merged 3 commits into from Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions pytradfri/device/air_purifier.py
Expand Up @@ -92,9 +92,13 @@ def filter_runtime(self) -> int:
return self.raw.filter_runtime

@property
def filter_status(self) -> int:
"""Return filter status."""
return self.raw.filter_status
def filter_status(self) -> bool:
"""
Return True if filter needs to be replaced.

This property is true when filter_lifetime_remaining is less than zero.
"""
return bool(self.raw.filter_status)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change although minor I would say. Booleans are subclass of integers so it will behave mostly the same, just the type will be different.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, a major version bump in a follow up?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, good to stay consistent with semver.


@property
def is_auto_mode(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_air_purifiers.py
Expand Up @@ -82,7 +82,7 @@ def test_filter_status(device):
"""Test filter status."""

air_purifier = device.air_purifier_control.air_purifiers[0]
assert air_purifier.filter_status == 0
assert air_purifier.filter_status is False


def test_filter_lifetime_remaining(device):
Expand Down