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

Put inactive alarms to the end of sorted list #205

Merged
merged 2 commits into from Apr 14, 2021

Conversation

KapJI
Copy link
Collaborator

@KapJI KapJI commented Apr 14, 2021

  • Add them to the end but still sorted.
  • If next alarm is inactive, set state to unavailable.

Fixes #204

@KapJI KapJI marked this pull request as draft April 14, 2021 10:37
@KapJI KapJI marked this pull request as ready for review April 14, 2021 10:39
@KapJI KapJI added the bug Something isn't working label Apr 14, 2021
Copy link
Owner

@leikoilja leikoilja left a comment

Choose a reason for hiding this comment

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

Hard to tell if this will work fine, but it looks good 👍 Thanks for fixing it.

Comment on lines +73 to +78
return sorted(
self._alarms,
key=lambda k: k.fire_time
if k.status != GoogleHomeAlarmStatus.INACTIVE
else k.fire_time + sys.maxsize,
)
Copy link
Owner

Choose a reason for hiding this comment

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

oh i really want to start introducing smaller unit tests for features like that to make sure they work 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you're welcome to add them 😀

Copy link
Owner

Choose a reason for hiding this comment

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

one day i ll get my hands on them :D

@KapJI KapJI merged commit 2cc8576 into leikoilja:master Apr 14, 2021
@KapJI KapJI deleted the sort-alarms branch April 14, 2021 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display Home devices keep old alarms thus "next alarm" is always the same old alarm in the sensor state
2 participants