You are currently viewing the Homey Apps SDK v2 documentation. New apps should use Homey Apps SDK v3 ››

Homey.ManagerCron

const { ManagerCron } = require('homey');

Table of Contents

Methods

getTask(id, callbackopt) → {Promise}

Get a specific task belonging to this app.

Parameters:
Name Type Attributes Description
id string

ID of the task (must be lowercase, alphanumeric).

callback function <optional>
Name Type Description
err Error
task CronTask
Returns:
Type:
Promise

getTasks(callbackopt) → {Promise}

Get all tasks belonging to this app.

Parameters:
Name Type Attributes Description
callback function <optional>
Name Type Description
err Error
logs Array

An array of CronTask instances

Returns:
Type:
Promise

registerTask(id, when, data, callbackopt) → {Promise}

Create a task.

Parameters:
Name Type Attributes Description
id string

ID of the task (must be lowercase, alphanumeric).

when Date | String

The run date or interval. When provided a Date, the task will run once and automatically unregister. When provided a string in the cron-format (e.g. * * * * * * will trigger every second), the task will run forever.

data Object
callback function <optional>
Name Type Description
err Error
task CronTask
Returns:
Type:
Promise

unregisterAllTasks(callbackopt) → {Promise}

Unregister all tasks.

Parameters:
Name Type Attributes Description
callback function <optional>
Name Type Description
err Error
Returns:
Type:
Promise

unregisterTask(id, callbackopt) → {Promise}

Unregister a specific task.

Parameters:
Name Type Attributes Description
id string

ID of the task (must be lowercase, alphanumeric).

callback function <optional>
Name Type Description
err Error
Returns:
Type:
Promise