There are two ways to access the API

  1. Directly

    Use it the following way to access the api, if you have no access to the sh object in your method or function:

    # to get access to the object instance:
    from lib.scheduler import Scheduler
    scheduler = Scheduler.get_instance()
    # to access a method (eg. to trigger a logic):
  2. Through the main SmartHome object

    If you have access to the sh object in your method or function, you can use the following way:

    # to access a method (eg. to trigger a logic):

The API is implemented through the following library:


exception lib.scheduler.LeaveLogic[Quellcode]

Bases: Exception

class lib.scheduler.Scheduler(smarthome)[Quellcode]

Bases: threading.Thread

static get_instance()[Quellcode]

Returns the instance of the scheduler class, to be used to access the scheduler-api

Use it the following way to access the api:

from lib.scheduler import Scheduler
scheduler = Scheduler.get_instance()

# to access a method (eg. to trigger a logic):

scheduler instance


object or None


Get number of worker threads initialized by scheduler


number of worker threads


Get number of idle worker threads


number of worker threads


Get names on non-idle worker threads


list with names of worker threads


Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

trigger(name, obj=None, by='Logic', source=None, value=None, dest=None, prio=3, dt=None, from_smartplugin=False)[Quellcode]

triggers the execution of a logic optional at a certain datetime given with dt

  • name

  • obj

  • by

  • source

  • value

  • dest

  • prio

  • dt – a certain datetime


always None

remove(name, from_smartplugin=False)[Quellcode]

Remove a scheduler entry with given name. If a call is made from a SmartPlugin with an instance configuration the instance name is added to the name to be able to distinguish scheduler entries from different instances

  • name – scheduler entry name to remove

  • from_smartplugin

check_caller(name, from_smartplugin=False)[Quellcode]

Checks the calling stack if the calling function (one of get, change, remove, trigger) itself was called by a smartplugin instance. If there is an instance name of the calling smartplugin then the instance name of that calling smartplugin is appended to the name

  • name – the name of a scheduler entry

  • from_smartplugin


returns either the name or name combined with instance name

return_next(name, from_smartplugin=False)[Quellcode]
add(name, obj, prio=3, cron=None, cycle=None, value=None, offset=None, next=None, from_smartplugin=False)[Quellcode]

Adds an entry to the scheduler.

  • name – Name of the scheduler

  • obj – Method to call by the scheduler

  • prio – a priority with default of 3 having 1 as most important and higher numbers less important

  • cron – a crontab entry of type string or a list of entries

  • cycle – a time given as integer in seconds or a string with a time given in seconds and a value after an equal sign

  • value – Value that an item should be set to or to be handed to a logic, otherwise: None

  • offset – an optional offset for cycle. If not given, cycle start point will be varied between 10..15 seconds to prevent too many scheduler entries with the same starting times

  • next

  • from_smartplugin – Only to set to True, if called from the internal method in SmartPlugin class

get(name, from_smartplugin=False)[Quellcode]

takes a given name for a scheduler and returns either the matching scheduler or None

change(name, from_smartplugin=False, **kwargs)[Quellcode]