To subscribe to the events in the system log, use activate_on_events()
def f(ev): message("Event %s" % ev.type) activate_on_events("", "", f) activate_on_events("Motion Start", "", f) activate_on_events("", "Camera 1", f)
The first parameter can be an event type filter. You can view the possible event types in the rule editor. The second parameter can be a name filter or object identifier.Both filters can be passed together.
An event contains an event type, time, event source object, as well as the parameters p1, p2, and p3.
def f(ev): message("Event %s" % ev.type) message("Object identifier: %s" % ev.origin) message("Object name: %s" % ev.origin_object.name) message("Time: %s" % time.strftime("%H:%M:%S %d.%m.%Y", time.localtime(ev.ts/1000000))) activate_on_events("", "", f)
You can work with the origin_object just like any other object.
The values of p1, p2, and p3 depend on the event type. For example, the "Login Successful, %1 from %2" event has two parameters which can be found in p1 and p2.