Giter VIP home page Giter VIP logo

uamanager / homebridge-cron-scheduler Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 480 KB

⏰ Cron Scheduler plugin for Homebridge, which allows scheduling of triggers using cron expressions.

Home Page: https://www.npmjs.com/package/homebridge-cron-scheduler

License: Apache License 2.0

TypeScript 100.00%
automation homebridge-automation homebridge cron cron-expression cronjob cronjob-scheduler homebridge-plugin homekit scenarios

homebridge-cron-scheduler's Introduction

⏰ Homebridge Cron Scheduler verified-by-homebridge

Support Ukraine Badge "Buy Me A Coffee" "Ko-fi"

npm npm npm

Creating and maintaining Homebridge plugins consume a lot of time and effort, if you would like to share your appreciation, feel free to "Star" or donate.

Click here to review more of my plugins.

Info

Cron Scheduler plugin for Homebridge, which allows scheduling of triggers using cron expressions.

Installation

After Homebridge has been installed:

sudo npm install -g --unsafe-perm homebridge-cron-scheduler@latest

Example Config

{
  //...
  "platforms": [
    {
      "platform": "CronScheduler",
      "debug": true,
      "tasks": [
        {
          "taskName": "min-1-default",
          // uses default `taskActive` with value `true`
          // uses default `taskCronExpression` with value `* * * * *`
          // uses default `taskStateResetInterval` with value `0`
        },
        {
          "taskName": "min-3-inactive",
          "taskActive": false,
          // task will be inactive, but can be activated using Home app by switching corresponding switch
          "taskCronExpression": "*/3 * * * *"
          // task will be triggered every 3 minutes
        },
        {
          "taskName": "min-3-reset-1",
          // uses default `taskActive` with value `true`
          "taskCronExpression": "*/3 * * * *",
          // task will be triggered every 3 minutes
          "taskStateResetInterval": 1
          // task will be reset every 1 minute after it was triggered
        },
        {
          "taskName": "working-day-toggle",
          // uses default `taskActive` with value `true`
          "taskCronExpression": "0 9,17 * * *",
          // task will be triggered at 9:00 and 17:00
          "taskStateResetInterval": -1
          // task will toggle sensor state when triggered, so sensor will be active from 9:00 to 17:00 every day
        },
        {
          "taskName": "next-ny-once",
          // uses default `taskActive` with value `true`
          "taskCronExpression": "0 0 31 12 *",
          // 31st of December at 00:00
          "taskMaxRuns": 1
          // task will be triggered only once at next 31st of December at 00:00
        }
      ]
    }
  ]
}
Config Field Description Default Required
platform Must always be CronScheduler. "CronScheduler" Yes
debug Enable for displaying debug messages. false No
timezone Timezone in 'Europe/Kiev' format to use for all tasks. Leave blank for using the system timezone. undefined No
tasks Array of cron tasks. [] No
Task Config Field Description Default Required
taskActive Defines whether the task is active or not. true No
taskName A unique name for the task. Will be used as the accessory name. "task-name1" Yes
taskCronExpression The cron expression to use for the task. * * * * * No
taskMaxRuns Maximum number of times the task can run. Leave blank for unlimited. Infinite No
taskStateResetInterval The interval in minutes after which the task state will be reset. Leave '0' for immediate reset, change to '-1' for enabling toggle mode. 0 No
taskStartAt Time at which the task should start. Leave blank for immediate start. ISO 8601 formatted datetime (2021-10-17T23:43:00) in local time. undefined No
taskStopAt Time at which the task should stop. Leave blank for no stop. ISO 8601 formatted datetime (2021-10-17T23:43:00) in local time. undefined No
timezone Timezone override in 'Europe/Kiev' format to use for this tasks. Leave blank for using the global timezone. undefined No

Cron Expression

  • Cron expressions support the following additional modifiers
  • ? A question mark is substituted with cron initialization time, as an example - ? * * * * would be substituted with 8 * * * * if time is <any hour>:08. The question mark can be used in any field.
  • L L can be used in the day of month field, to specify the last day of the month.
// ┌────────────── minute (0 - 59)
// │ ┌──────────── hour (0 - 23)
// │ │ ┌────────── day of month (1 - 31)
// │ │ │ ┌──────── month (1 - 12, JAN-DEC)
// │ │ │ │ ┌────── day of week (0 - 6, SUN-Mon) 
// │ │ │ │ │       (0 to 6 are Sunday to Saturday; 7 is Sunday, the same as 0)
// │ │ │ │ │
// * * * * *
Field Required Allowed values Allowed special characters Remarks
Minutes Yes 0-59 * , - / ?
Hours Yes 0-23 * , - / ?
Day of Month Yes 1-31 * , - / ? L
Month Yes 1-12 or JAN-DEC * , - / ?
Day of Week Yes 0-7 or SUN-MON * , - / ? 0 to 6 are Sunday to Saturday
7 is Sunday, the same as 0

Note Weekday and month names are case insensitive. Both MON and mon works.

See Cron Expression for more details.

Contributing

You can contribute to this homebridge plugin in following ways:

  • Report issues and help verify fixes as they are checked in.
  • Review the source code changes.
  • Contribute bug fixes.
  • Contribute changes to extend the capabilities
  • Pull requests are accepted.

See CONTRIBUTING

homebridge-cron-scheduler's People

Contributors

renovate[bot] avatar uamanager avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

quatmo

homebridge-cron-scheduler's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • actions/setup-node v3
.github/workflows/codeql-analysis.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/issue-auto-assign.yml
  • pozil/auto-assign-issue v1.12.0
npm
package.json
  • croner 7.0.1
  • homebridge-util-accessory-manager 0.0.13
  • @types/node 20.12.11
  • @typescript-eslint/eslint-plugin 7.2.0
  • @typescript-eslint/parser 7.2.0
  • eslint 8.57.0
  • homebridge 1.6.1
  • nodemon 3.1.0
  • standard-version 9.5.0
  • ts-node 10.9.2
  • typescript 5.4.5
  • node >=16
  • minimist 1.2.8

  • Check this box to trigger a request for Renovate to run again on this repository

Basic functionality

Is your feature request related to a problem? Please describe:
Sometimes Home App automations is just not enough as scheduling there is pretty awful.

Describe the solution you'd like:
It would be nice to have plugin for scheduling using cron expressions.

Describe alternatives you've considered:

Additional context:

Different accessory types

Is your feature request related to a problem? Please describe:
I’d like to use another type of accessory in Home in order to hide the cron service from the activity history.

Describe the solution you'd like:
Another type of accessory, e.g. a light bulb or switch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.