We are constantly trying to provide the flespi broker with new, useful features. Without breaking the standard, we have implemented additional methods for filtering messages.
Subscription filter format:
$filter/cid={cid filter}&modified_since={timestamp}&payload={expression}/{filter topic}
cid - message filter from the specified subaccount
modified_since - message filter by publication time
payload - message filter by content. The content of the message must comply with the JSON specification - be a number, a double-quoted string, null, true/false, JSON object, JSON array. Expression format: https://flespi.com/kb/expressions-the-way-to-analyze-message
Filters are listed with '&', the filter value must be urlencoded.
Payload filter added as an optional parameter to the REST API method GET /mqtt/messages.
Example 1, subscription to temperature sensors:
topic: sensor/1/temperature, payload: 21, filter: $>20
Subscription filter:
$filter/payload=%24%3E20/sensor/+/temperature
Example 2, subscription to active alarm sensors
topic: alarm/2/status, payload: true, fitler: $=true
Subscription filter:
$filter/payload=%24%3Dtrue/alarm/+/status
Example 3, telemetry subscription for generators with voltages outside the specified range
topic: generator/3, payload: {"name": "test", "voltage": 12}, filter: voltage<10||voltage>=12
Subscription filter:
$filter/payload=voltage%3C10%7C%7Cvoltage%3E12/generator/+