-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Add weekdays to time trigger #147505
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
base: dev
Are you sure you want to change the base?
Add weekdays to time trigger #147505
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
monday_before_trigger = now.replace( | ||
year=2023, month=1, day=2, hour=4, minute=59, second=0, microsecond=0 | ||
) | ||
monday_trigger = now.replace( | ||
year=2023, month=1, day=2, hour=5, minute=0, second=0, microsecond=0 | ||
) | ||
|
||
freezer.move_to(monday_before_trigger) |
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.
monday_before_trigger = now.replace( | |
year=2023, month=1, day=2, hour=4, minute=59, second=0, microsecond=0 | |
) | |
monday_trigger = now.replace( | |
year=2023, month=1, day=2, hour=5, minute=0, second=0, microsecond=0 | |
) | |
freezer.move_to(monday_before_trigger) | |
monday_trigger = now.replace( | |
year=2023, month=1, day=2, hour=5, minute=0, second=0, microsecond=0 | |
) | |
freezer.move_to(monday_trigger) |
I am not sure I understand why we have monday_before_trigger
and monday_trigger
, but then do monday_trigger + timedelta(seconds=1)
. Couldn't we just have monday_trigger
?
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.
By the way, we could use the @pytest.mark.freeze_time("2023-01-02 05:00:00")
decorator, and then just use now
+ timedeltas instead of now().replace()
like tuesday_trigger = now + timedelta(days=1)
.
I think that would make the tests easier to read, but I am fine with either approache.
Proposed change
As requested in: https://github.com/orgs/home-assistant/discussions/26
Adds a weekday option to the time triggers, allowing you to fire it only on certain days of the week.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: