Requires: IP-Symcon >= 4.1
void SetForwardDataFilter (string $RequiredRegexRule)
RequiredRegexRule | RegexRule which should be used as a filter |
No Return |
Sets the filter using the RequiredRegexRule regular expression. ForwardData() is only called if the set filter is matching.
The page www.regex101.com can be used to test the RegEx-expression.
In certain special cases PHP json_encode() may change from upper to lower case. For example, the special character encoded JSON_string ""\u001D"" becomes ""\u001d"" after a json_decode.
//Add filter for ForwardData public function ApplyChanges() { [...] //Apply filters $this->SetForwardDataFilter(".*Hello.*"); } //Only called if “Hello” is found in the $JSONString public function ForwardData($JSONString) { $data = json_decode($JSONString); //Your code here [...] $this->SendDataToParent(json_encode(Array("DataID" => "{12345678-ABCD-EFAB-123456789123}", "Buffer" => $data->Buffer))); return "String data for the device instance!"; }