smarthome icon indicating copy to clipboard operation
smarthome copied to clipboard

Extend crontab value to eval expression?

Open bmxp opened this issue 3 years ago • 3 comments

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?

bmxp avatar Feb 25 '22 06:02 bmxp

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

onkelandy avatar Feb 26 '22 05:02 onkelandy

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!

bmxp avatar Feb 26 '22 06:02 bmxp

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).

onkelandy avatar Feb 26 '22 07:02 onkelandy