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

Extend crontab value to eval expression? #478

Closed
bmxp opened this issue Feb 25, 2022 · 8 comments
Closed

Extend crontab value to eval expression? #478

bmxp opened this issue Feb 25, 2022 · 8 comments

Comments

@bmxp
Copy link
Member

bmxp commented Feb 25, 2022

There is the wish to extend the existing crontab expression with an eval to react on a ubiquitous expression like eval.

syntax could be like

crontab:
    - sunset+20m = 1
    - 45 7 * * = False if shtime.is_holiday(shtime.now()) or shtime.is_weekend(shtime.now())) else None
    - 30 10 * * = True if (shtime.is_holiday(shtime.now()) or shtime.is_weekend(shtime.now())) else None

Any further ideas regarding this?

@onkelandy
Copy link
Member

Evals are always good ;)

Anyhow for the specific use case.. what about having a "7" for day in week to assign a "holiday"?
e.g. 30 10 * 5,6,7 = 0
-> weekend & holiday

@bmxp
Copy link
Member Author

bmxp commented Feb 26, 2022

The problem with extending with a day like 7 is that there is no mechanism to

  • exclude days
  • is hard to understand

Have a look at a situation where someone needs to open the blinds every morning, except for e.g. Easter Monday but also on Easter Sunday (has to work then :-)).
With an eval that could be solved. I don't see how we could introduce a 7 or 8 then...

Thanks for your thoughts!

@onkelandy
Copy link
Member

Sure, if you want to define that quite detailed you need an eval. Just thought a "7" might be quite intuitive for "all holidays in general" because that might also be a relevant use case and is easier then evals (just additionally).

@bmxp bmxp added this to the Version 1.10 milestone Apr 30, 2022
@Morg42 Morg42 modified the milestones: Version 1.10, Version 1.12 Dec 8, 2024
@bmxp
Copy link
Member Author

bmxp commented Jan 26, 2025

@onkelandy in case of 7 as holiday: where should this info come from?

@onkelandy
Copy link
Member

shtime.is_holiday? Or what do you mean?

@bmxp
Copy link
Member Author

bmxp commented Jan 26, 2025

If that is enough then it should be no problem to implement this...

@Morg42
Copy link
Member

Morg42 commented Mar 1, 2025

Eval parsing is implemented in develop. The same eval's can be used as everywhere else for the value part.

If the crontab is attached to an item, relative item references can be used.

@bmxp Do we need to work on the crontab part syntax/features? Otherwise, this can be closed.

@Morg42 Morg42 added the resolved label Mar 1, 2025
@bmxp
Copy link
Member Author

bmxp commented Mar 3, 2025

If the extension of crontab is really needed, we should open a new feature request. For now I think this Issue is finally solved by the new implementation.

@bmxp bmxp closed this as completed Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants