Example #1
0
 def __init__(self, cron_expression, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {'cronExpression': cron_expression}
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "timer.GenericCronTrigger").withConfiguration(
                 Configuration(configuration)).build()
Example #2
0
 def __init__(self, event_types, thing_uid=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     self.trigger = TriggerBuilder.create().withId(trigger_name).withTypeUID("core.GenericEventTrigger").withConfiguration(Configuration({
         "eventTopic": "smarthome/things/*",
         "eventSource": "smarthome/things/{}".format("{}/".format(thing_uid) if thing_uid else ""),
         "eventTypes": event_types
     })).build()
Example #3
0
 def __init__(self, event_source, event_types, event_topic="smarthome/*", trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     self.trigger = TriggerBuilder.create().withId(trigger_name).withTypeUID("core.GenericEventTrigger").withConfiguration(Configuration({
         "eventTopic": event_topic,
         "eventSource": event_source,
         "eventTypes": event_types
     })).build()
Example #4
0
 def __init__(self, path, event_kinds=[ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY], watch_subdirectories=False, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {
         'path': path,
         'event_kinds': str(event_kinds),
         'watch_subdirectories': watch_subdirectories,
     }
     self.trigger = TriggerBuilder.create().withId(trigger_name).withTypeUID("jsr223.DirectoryEventTrigger").withConfiguration(Configuration(configuration)).build()
Example #5
0
 def __init__(self, thing_uid, previous_status=None, status=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {"thingUID": thing_uid}
     if previous_status is not None:
         configuration["previousStatus"] = previous_status
     if status is not None:
         configuration["status"] = status
     self.trigger = TriggerBuilder.create().withId(trigger_name).withTypeUID("core.ThingStatusChangeTrigger").withConfiguration(Configuration(configuration)).build()
Example #6
0
 def __init__(self, item_name, previous_state=None, state=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {"itemName": item_name}
     if state is not None:
         configuration["state"] = state
     if previous_state is not None:
         configuration["previousState"] = previous_state
     self.trigger = TriggerBuilder.create().withId(trigger_name).withTypeUID("core.ItemStateChangeTrigger").withConfiguration(Configuration(configuration)).build()
 def __init__(self, filter=None):
     self.filter = filter or (lambda event: True)
     triggerName = type(self).__name__ + "-" + uuid.uuid1().hex
     self.trigger = TriggerBuilder.create().withId(triggerName).withTypeUID(
         "jsr223.OsgiEventTrigger").withConfiguration(
             Configuration()).build()
     global osgi_triggers
     osgi_triggers[triggerName] = self
Example #8
0
 def __init__(self, channel_uid, event=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {"channelUID": channel_uid}
     if event is not None:
         configuration["event"] = event
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "core.ChannelEventTrigger").withConfiguration(
                 Configuration(configuration)).build()
Example #9
0
 def __init__(self, item_name, command=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {"itemName": item_name}
     if command is not None:
         configuration["command"] = command
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "core.ItemCommandTrigger").withConfiguration(
                 Configuration(configuration)).build()
Example #10
0
 def __init__(self, filter_predicate=None):
     """
     The filter_predicate is a predicate taking an event argument and
     returning True (keep) or False (drop).
     """
     self.filter = filter_predicate or (lambda event: True)
     trigger_name = type(self).__name__ + "-" + uuid.uuid1().hex
     self.trigger = TriggerBuilder.create().withId(trigger_name).withTypeUID("jsr223.OsgiEventTrigger").withConfiguration(Configuration()).build()
     LOG.warn("self.trigger.id: {}".format(self.trigger.id))
     LOG.warn("trigger_name: {}".format(trigger_name))
     OSGI_TRIGGERS[trigger_name] = self.trigger
Example #11
0
 def __init__(self, event_types, item_name=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "core.GenericEventTrigger").withConfiguration(
                 Configuration({
                     "eventTopic":
                     "*/items/*",
                     "eventSource":
                     "/items/{}".format(item_name if item_name else ""),
                     "eventTypes":
                     event_types
                 })).build()
Example #12
0
 def __init__(self, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "jsr223.StartupTrigger").withConfiguration(
                 Configuration()).build()