LogoLogo
OverviewDemos and ResourcesContact
  • What is Engine?
  • Key Concepts
    • Drivers
    • Modules
    • Systems
    • Zones
    • Settings
    • Interfaces
    • Triggers
  • Security
  • Deployment
    • System Architecture
    • Single Sign-On
      • Configuring Engine for SAML2
      • SAML2 with Azure AD
      • SAML2 with ADFS
      • SAML2 with Auth0
      • SAML2 with GSuite
      • OAuth2
  • Integrations
    • Supported Integrations
    • Directory Services
      • Microsoft Office365
    • IoT
      • Device Drivers
      • Node-RED
      • Azure IOT Hub
    • Location Services
      • Locating Users on a Network
      • SVG Map Creation
      • Cisco CMX
      • Cisco Meraki RTLS
      • Desk Sensors
  • Administration
    • Backoffice
      • Systems
      • Devices
      • Drivers
      • Zones
      • Triggers
      • Metrics
      • Users
      • Domains
        • Applications
  • Developer Guide
    • Development Environment
    • Building Drivers
      • Discovery and Metadata
      • State
      • Scheduling Actions
      • Response Tokenisation
      • Device Drivers
      • SSH Drivers
      • Service Drivers
      • Logic Drivers
      • Testing
      • Live Monitoring
      • Logging
      • Security
      • Utilities and Helpers
    • User Interfaces
      • Composer
      • Virtual Systems
      • Widgets
      • Settings.json
  • API
    • Authentication
    • Control
      • Systems
      • Modules
      • Dependencies
      • Zones
      • Websocket
        • Commands
          • bind
          • unbind
          • exec
          • debug
          • ignore
        • Heartbeat
        • Errors
  • Support
    • Service Desk
Powered by GitBook
On this page

Was this helpful?

  1. Developer Guide
  2. Building Drivers

Scheduling Actions

Every driver can schedule events to occur in a number of different ways. Schedules are automatically cleared when a driver is terminated.

  • Integer arguments are in milliseconds. 1000 == 1 second

  • Strings can be used for a friendly representation of the time

    • '30s' == 30 seconds

    • '5m' == 5 minutes

    • '1w2d3h5m' == 1 week, 2 days, 3 hours and 5 minutes

    • '2Y1M' == 2 years, 1 month

Function

Arguments

Description

schedule.in

String or Integer

schedule a task to run once in the time specified (formats above)

schedule.at

Time or String

schedule.every

String or Integer

schedule a task to run every time period on repeat

schedule.cron

String

schedule.clear

shortcut for cancelling any active schedules

Examples

schedule.every('1m') do
    # perform some action, such as polling
end

schedule.in(500) do
    # ...
end

schedule.at(Time.now + 2.hours) do
    # ...
end

schedule.at('2018-02-02T15:32:41+11:00') do
    # ...
end

# Every day at 8am
schedule.cron('0 8 * * *') do
    # ...
end

# Canceling an individual schedule
@email_sched = schedule.in(500) do
    send_email
end
@email_sched.cancel

There are often situations where you want to run the block immediately.

def connected
    schedule.every('1m', :run_now) do
        poll_current_state
    end
end

CRON also supports time zones - which should always be configured

schedule.cron('0 8 * * *', timezone: 'Sydney') do
    # ...
end
PreviousStateNextResponse Tokenisation

Last updated 6 years ago

Was this helpful?

schedule a task at a time represented by a or a parsable

A schedule that will fire based on a string

See the list of supported and information .

time zone strings
about time zones
Time object
time string
CRON