To fiter messages, implement the filterMsg() function. The original message is contained in the “msg.text” parameter and was also assigned to the variable “content”.
The variable “content” is returned to the calling program and determines the content to be displayed.
The content of “content” must be of type string, i.e. if necessary, numeric values must be converted. Avoid complex code and actions that are not used to filter the message.
The result of the test run is displayed in the editor status line.
If you have already received news for your topic, the value of the last message will be preset but can be overwritten.
The following examples show how data is extracted and formatted from messages with different structures. You can also use ( > Insert Example > <Examples> > Insert Example > <Examples>) to insert the examples into your code and customize them:
Variables that can be accessed from the filterMsg() function:
|msg.text||Message content (original message interpreted as UTF-8 string, non-displayable characters as well as invalid values are replaced or marked by the � character|
|acc.user||MQTT user name|
|acc.pushServer||MQTT push server|
|view.setBackgroundColor(<value>)||Message background color, e.g. using the color constant MQTT.Color.LT_GREEN (see details)|
|view.setTextColor(<value>)||Message text color, e.g. 0xFF662233 (in hexadecimal ARGB notation with FF
defining an alpha value of 100%)