-
Notifications
You must be signed in to change notification settings - Fork 3
Event Handlers
Event handlers are used by add-ons to apply filters to events before processing them. Please refer to the documentation of respective add-ons to actually make use of event handlers - you cannot use event handlers directly. This page offers details on configuring the filtering part of add-ons that make use of event handlers.
In your qtoggleserver.conf, the add-on should be present in the event_handlers
configuration section. To specify filtering, simply add the filter
parameter to the event handler parameters:
...
event_handlers = [
...
{
...
filter = {
# here go your filtering rules
}
...
}
...
]
...
To process only events of a certain type, use type = "<event-type>"
. Following example will process only events of type value-change
:
filter = {
type = "value-change"
...
}
...
You can also specify a list of accepted event types:
filter = {
type = ["value-change", "port-update"]
...
}
...
To process only port events that occur on a port having a certain value, use port_value = <value>
. Following example will process only events on ports having value true
:
filter = {
port_value = true
...
}
...
You can also specify a list of accepted values:
filter = {
port_value = [1, 2]
...
}
...
You can even set it to an expression. Following example will process only events on ports having value equal to ten times the value of vport1
:
filter = {
port_value = "MUL($vport1, 10)"
...
}
...
If you want to handle events that occur on a port value transition, use port_value_transition = [<from_value>, <to_value>]
. Following example will process only events on ports whose value has just became true
:
filter = {
port_value_transition = [false, true]
...
}
...
To react on transitions from any or to any value, simply use any
, e.g. port_value_transition = [any, 10]
To process only port events that occur on a port having a certain attribute, use port_<attribute> = <value>
. Following example will process only events on writable ports:
filter = {
port_writable = true
...
}
...
You can also specify a list of accepted values. Following example will process only events on ports with id "bedroom_temperature"
or "kitchen_temperature"
:
filter = {
port_id = ["bedroom_temperature", "kitchen_temperature"]
...
}
...
If you want to handle events that occur on a port attribute transition, use port_<attribute>_transition = [<from_value>, <to_value>]
. Following example will process only events on ports that have just been enabled:
filter = {
port_enabled_transition = [false, true]
...
}
...
To react on transitions from any or to any attribute value, simply use any
, e.g. port_enabled_transition = [any, true]
To process only device events that occur on a device having a certain attribute, use device_<attribute> = <value>
. Following example will process only events on device when its battery is low:
filter = {
device_low_battery = true
...
}
...
You can also specify a list of accepted values. Following example will process only events when device's IP address is one of the given values:
filter = {
device_ip_address = ["192.168.0.5", "192.168.0.6"]
...
}
...
If you want to handle events that occur on a device attribute transition, use device_<attribute>_transition = [<from_value>, <to_value>]
. Following example will process only events on device when its battery becomes low:
filter = {
device_low_battery_transition = [false, true]
...
}
...
To react on transitions from any or to any attribute value, simply use any
, e.g. device_low_battery_transition = [any, true]
To process only slave device events that occur on a device having a certain attribute, use slave_<attribute> = <value>
. Following example will process only events on online devices:
filter = {
slave_online = true
...
}
...
You can also specify a list of accepted values. Following example will process only events on devices with name "bedroom_light"
or "kitchen_ight"
:
filter = {
slave_name = ["bedroom_light", "kitchen_light"]
...
}
...
If you want to handle events that occur on a slave device attribute transition, use slave_<attribute>_transition = [<from_value>, <to_value>]
. Following example will process only events on slave devices that have just been enabled:
filter = {
slave_enabled_transition = [false, true]
...
}
...
To react on transitions from any or to any attribute value, simply use any
, e.g. slave_enabled_transition = [any, true]