Ejemplo n.º 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()
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
 def __init__(self, thing_uid, status=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {"thingUID": thing_uid}
     if status is not None:
         configuration["status"] = status
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "core.ThingStatusUpdateTrigger").withConfiguration(
                 Configuration(configuration)).build()
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
 def __init__(self, item_name, state=None, trigger_name=None):
     trigger_name = validate_uid(trigger_name)
     configuration = {"itemName": item_name}
     if state is not None:
         configuration["state"] = state
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "core.ItemStateUpdateTrigger").withConfiguration(
                 Configuration(configuration)).build()
Ejemplo n.º 7
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":
                     "*/things/*",
                     "eventSource":
                     "/things/{}".format(thing_uid if thing_uid else ""),
                     "eventTypes":
                     event_types
                 })).build()
Ejemplo n.º 8
0
 def __init__(self,
              event_source,
              event_types,
              event_topic="*/*",
              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()
Ejemplo n.º 9
0
 def __init__(self,
              path,
              event_kinds=[ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY],
              watch_subdirectories=False):
     trigger_name = validate_uid(type(self).__name__)
     configuration = {
         'path': path,
         'event_kinds': str(event_kinds),
         'watch_subdirectories': watch_subdirectories,
     }
     self.trigger = TriggerBuilder.create().withId(
         trigger_name).withTypeUID(
             "jsr223.DirectoryTrigger").withConfiguration(
                 Configuration(configuration)).build()
Ejemplo n.º 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
Ejemplo n.º 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":
                     "smarthome/items/*",
                     "eventSource":
                     "smarthome/items/{}".format(
                         "{}/".format(item_name) if item_name else ""),
                     "eventTypes":
                     event_types
                 })).build()
Ejemplo n.º 12
0
 def __init__(self,
              thing_uid,
              event_types,
              event_topic="smarthome/things/*",
              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":
                     "smarthome/things/{}/".format(thing_uid),
                     "eventTypes":
                     event_types
                 })).build()
Ejemplo n.º 13
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()