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

static schedule : start_time ignored for weeks ? #72

Open
aschor opened this issue Dec 13, 2021 · 0 comments
Open

static schedule : start_time ignored for weeks ? #72

aschor opened this issue Dec 13, 2021 · 0 comments

Comments

@aschor
Copy link

aschor commented Dec 13, 2021

Hi, I'm having difficulties setting a schedule that could be expressed like so :
"thursday, every 6 weeks, starting from december 30, 2021, and going on forever over following monthes/years"

(It's for my glass garbage pickup).

I have tried :

schedy_calendrier_poubelles:  # This is our app instance name.
  module: hass_apps_loader
  class: SchedyApp

  actor_type: generic2
  actor_templates:
    une_date:
      send_retries: 0
      attributes:
      - attribute: state
      values:
      - value: ["*"]
        calls:
        - service: input_datetime.set_datetime
          data:
            date: "{attr1}"
      ignore_case: true

  schedule_snippets:
    ordures_verres:
      - v : '2021-09-01'  #la valeur ne sera jamais utilisée, juste la prochaine date d'itération
        weekdays: 4
        weeks: "*/6"
        start_date: { year: 2021, month: 12, day: 27}

  rooms:
    exterieur_verres:
      actors:
        input_datetime.date_next_ordures_verres:
          template: une_date
      schedule:
        - x: |
            results = schedule.next_results(
                schedule_snippets["ordures_verres"],
                end=now+datetime.timedelta(days=90),
            )
            result="2020-01-01"
            for when, (value, markers, rule) in results:
              if (when.month==12 and when.day==25) or (when.month==1 and when.day==1):
                continue
              result=when.strftime("%Y-%m-%d")
              break

and ... whatever date I set in "start_date" in the snipet ...... every time the next schedule is 2022-01-06 and not 2021-12-30. So that Is what I suppose could be a bug ? or a design choice ? I had hopes that setting the "start_time" would shift the weeks numbers, and so change the result.

I have for now set up a datetime.timedelta(weeks=1) in the code, But I have the feeling that the rule will not work correctly next year, because it is based on week number, and not on the (start_date week + xxx weeks ) modulo 6 (is such a contraint achievable ?)

bonus question : do I need a "sensor.time" (or sensor.wod) in the watched entities for the schedule to work ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant