Module "xplfilters"

The filter object for xPL devices. It maintains a list of filters for matching incoming messages.
No global will be created, it just returns the filter class. The main xPL module will create a global xpl.classes.xplfilters to access it.
 
An xpl filter is a set of xpl message elements; [msgtype].[vendor].[device].[instance].[schema-class].[schema-type] For each element a '*' can be used as a wildcard. Only arriving messages that match at least 1 filter entry will be dealt with by an xpl device.
 
 Example (assuming self is an xpldevice object)
 self.filter = xpl.classes.xplfilters:new({})
 self.filter:add("xpl-cmnd.*.*.*.homeeasy.basic")
 self.filter:add("xpl-cmnd.*.*.*.x10.*")
 

Copyright © 2011 Thijs Schreijer

Release: Version 0.1, LuaxPL framework.

Tables

filter-table Internal representation of a filter entry.
xplfilter fields/properties Members of the filter object

Functions

flt:add (flt) Add a filter entry to the filter list.
flt:match (flt) Checks if a filter matches any of the filters in the list.
flt:remove (flt) Remove filter from list
flt:split (flt) splits a filter string into a filter table.


Tables

filter-table
Internal representation of a filter entry.

Fields

  • filter: the full filter string formatted as [msgtype].[vendor].[device].[instance].[schema-class].[schema-type]
  • 1: value for the msgtype
  • 2: value for the source address vendor id
  • 3: value for the source address device id
  • 4: value for the source address instance id
  • 5: value for the schema class
  • 6: value for the schema type
xplfilter fields/properties
Members of the filter object

Fields

  • list: Table to store the individual filter entries, each filter-table in the list is keyed by its full filter string.

Functions

flt:add (flt)
Add a filter entry to the filter list. Duplicates will be silently dismissed (no error).

Parameters:

  • flt: filter to add, either a filter string or a filter table

Return value:

filter table added

See also:

flt:match (flt)
Checks if a filter matches any of the filters in the list. Wildcards are allowed both in the list (obvious), but also in the filter being matched.

Parameters:

  • flt: filter to match (either a string or a table)

Return value:

true if the filter matches an entry in the list, false otherwise. If the filter object does not contain any filters it will true (default xpl behaviour with absent filters).
flt:remove (flt)
Remove filter from list

Parameters:

  • flt: filter to remove, either a filter string or a filter table. If it doesn't exist no error will be thrown.

Return value:

true
flt:split (flt)
splits a filter string into a filter table. A '-' between vendor and device is accepted. It can be called as a function or as a method, either way works (see example below).

Parameters:

  • flt: Filter (string) as [msgtype].[vendor].[device].[instance].[class].[type]

Usage:

-- create a new filter object
local flt = xpl.classes.xplfilter()
-- call as a function
local f = flt.split("xpl-cmnd.vendor.device.instance.class.type")
-- call as a method
local f = flt:split("xpl-cmnd.vendor.device.instance.class.type")

Return value:

a filter table with 6 indices for each filter element, and the filter key with the full filter string value

See also:

Valid XHTML 1.0!