-
Notifications
You must be signed in to change notification settings - Fork 5
Feat: Enable support for snoo sleepytime timeout levels #46
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
Changes from 1 commit
1a9b50f
d9e51f1
a84c8ba
3e263b5
8a74f0c
04f2612
2e100ec
fa2232f
e8f7697
27d4a75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| #maybe we dont need this | ||
| from __future__ import annotations | ||
|
|
||
| import dataclasses | ||
| import datetime | ||
| from enum import StrEnum | ||
| from enum import StrEnum, IntEnum | ||
| from typing import Any, Union | ||
|
|
||
| from mashumaro.mixins.json import DataClassJSONMixin | ||
|
|
@@ -15,6 +18,44 @@ class SnooLevels(StrEnum): | |
| level4 = "LEVEL4" | ||
| stop = "ONLINE" | ||
|
|
||
| class SnooNoiseTimeoutLevels(IntEnum): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So walk me through it - what is the benefit of this IntEnum opposed to just passing in a int? Does Snoo only accept specific values?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability and "app feeling" cloning was the idea - I basically just replicated the setup for the snoo levels. I believe the API just wants an integer, however the app only provides it in 5 minute increments. I don't like passing magic numbers around hence the enum class
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay not completely against it - but you will have to see how this feels when you are adding it on the core side. It may be good to accept the IntEnum | int just to make your life easier in the function just in case you need to pivot.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When writing the HA core code, I had to replicate the structure over to the strings file to get it to look good for the UI - so realistically that code is now duplicated. I thought that I could just let the HA UI handle it, but then it would have that logic only in HA, leaving python_snoo with a potential foot-gun should someone decide to pass 190 minutes through to the API. I'm happy either way
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this may simplify things? https://developers.home-assistant.io/blog/2024/01/19/entity-translations-placeholders/
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realized this does not allow for translation placeholders in options... Will approve for now, but we will see what the actual core implementation looks like and what the HA devs think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will have a crack at it! Thanks! |
||
| _5_minutes = 5 | ||
| _10_minutes = 10 | ||
| _15_minutes = 15 | ||
| _20_minutes = 20 | ||
| _25_minutes = 25 | ||
| _30_minutes = 30 | ||
| _35_minutes = 35 | ||
| _40_minutes = 40 | ||
| _45_minutes = 45 | ||
| _50_minutes = 50 | ||
| _55_minutes = 55 | ||
| _60_minutes = 60 | ||
| _65_minutes = 65 | ||
| _70_minutes = 70 | ||
| _75_minutes = 75 | ||
| _80_minutes = 80 | ||
| _85_minutes = 85 | ||
| _90_minutes = 90 | ||
| _95_minutes = 95 | ||
| _100_minutes = 100 | ||
| _105_minutes = 105 | ||
| _110_minutes = 110 | ||
| _115_minutes = 115 | ||
| _120_minutes = 120 | ||
| _125_minutes = 125 | ||
| _130_minutes = 130 | ||
| _135_minutes = 135 | ||
| _140_minutes = 140 | ||
| _145_minutes = 145 | ||
| _150_minutes = 150 | ||
| _155_minutes = 155 | ||
| _160_minutes = 160 | ||
| _165_minutes = 165 | ||
| _170_minutes = 170 | ||
| _175_minutes = 175 | ||
| _180_minutes = 180 | ||
|
|
||
|
|
||
| class SnooStates(StrEnum): | ||
| baseline = "BASELINE" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we do - I like to avoid future annotations unless needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a couple of errors with the versioning I was doing to test, will remove