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

Schedule every n days #97

Merged
merged 2 commits into from Jan 23, 2023
Merged

Schedule every n days #97

merged 2 commits into from Jan 23, 2023

Conversation

aws404
Copy link
Contributor

@aws404 aws404 commented Jan 2, 2023

This PR add the ability to schedule a run every n days.

Example Use Case

I have a system with 16 irrigation 'zones' which I split up into 3 sequences (2 zones in each), which I want to run sequentially one day after the other (ie. Day 1 = Sequence A, ... , Day 3 = Sequence C, Day 5 = Sequence A, ect.).
As the three sequences do not fit into the seven days of the week, I am unable to do this currently (as far as I can see).
This can now be achieved using the following configuration which features:

  • The same number in the every_n_days option
  • Incremented start_n_days to stagger the alternation
    - name: 'Sequenced Controller'
      zones:
        - name: Station 1
        - name: Station 2
        - name: Station 3
        - name: Station 4
        - name: Station 5
        - name: Station 6
      sequences:
      - name: "Program A"
        schedules:
          - time: "19:15"
            day:
              every_n_days: 3
              start_n_days: 2022-01-01 # Starting date
        zones:
        - zone_id: 1
          duration: "00:10"
        - zone_id: 2
          duration: "00:10"
      - name: "Program B"
        schedules:
          - time: "19:15"
            day:
              every_n_days: 3
              start_n_days: 2022-01-02 # Starting date + 1
        zones:
        - zone_id: 3
          duration: "00:10"
        - zone_id: 4
          duration: "00:10"
      - name: "Program C"
        schedules:
          - time: "19:15"
            day:
              every_n_days: 3
              start_n_days: 2022-01-03 # Starting date + 2
        zones:
        - zone_id: 5
          duration: "00:10"
        - zone_id: 6
          duration: "00:10"

FEEDBACK WANTED

  • Is this something you would consider?
  • Is inside the day option the best place for these options?
  • Are these the best choices for the option names?
    • every_n_days to alternate_n_days?
    • start_n_days to alternation_start?

@rgc99
Copy link
Owner

rgc99 commented Jan 4, 2023

I like the idea. Inside the day parameter probably makes the most sense. Option names are fine. Coding looks good.

The only thing that needs to be done is a test unit. Rather than add the setup to configuration.yaml create a new file in tests/configs like test_every_n_days.yaml - use test_model.yaml as an example. In the tests directory, copy test_model.py to test_every_n_days.py and adjust to suit your needs. Documentation is in the tests directory. Probably create a config that has a sequence run every 2 days, another 3 days and even another on 4 days for good measure.

The test needs to pass along with all the existing tests. If this is too much to handle I can setup the test unit.

@rgc99 rgc99 merged commit 23c06bb into rgc99:master Jan 23, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants