1.3.1 • Published 8 months ago

homebridge-cron-scheduler v1.3.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

⏰ 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 FieldDescriptionDefaultRequired
platformMust always be CronScheduler."CronScheduler"Yes
debugEnable for displaying debug messages.falseNo
timezoneTimezone in 'Europe/Kiev' format to use for all tasks. Leave blank for using the system timezone.undefinedNo
tasksArray of cron tasks.[]No
Task Config FieldDescriptionDefaultRequired
taskActiveDefines whether the task is active or not.trueNo
taskNameA unique name for the task. Will be used as the accessory name."task-name1"Yes
taskCronExpressionThe cron expression to use for the task.* * * * *No
taskMaxRunsMaximum number of times the task can run. Leave blank for unlimited.InfiniteNo
taskStateResetIntervalThe interval in minutes after which the task state will be reset. Leave '0' for immediate reset, change to '-1' for enabling toggle mode.0No
taskStartAtTime at which the task should start. Leave blank for immediate start. ISO 8601 formatted datetime (2021-10-17T23:43:00) in local time.undefinedNo
taskStopAtTime at which the task should stop. Leave blank for no stop. ISO 8601 formatted datetime (2021-10-17T23:43:00) in local time.undefinedNo
timezoneTimezone override in 'Europe/Kiev' format to use for this tasks. Leave blank for using the global timezone.undefinedNo

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)
// │ │ │ │ │
// * * * * *
FieldRequiredAllowed valuesAllowed special charactersRemarks
MinutesYes0-59* , - / ?
HoursYes0-23* , - / ?
Day of MonthYes1-31* , - / ? L
MonthYes1-12 or JAN-DEC* , - / ?
Day of WeekYes0-7 or SUN-MON* , - / ?0 to 6 are Sunday to Saturday7 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