What can we improve?

Documentation

(Edit)

ReceiveData

Requires: IP-Symcon >= 4.0

string ReceiveData (string $JSONString)

Parameters

JSONString Data package in JSON format

Returns

Optional response to the parent instance

Description

This function is called by IP-Symcon and processes sent data and, if necessary, forwards it to all child instances.
Data can be sent using the SendDataToChildren function.
Further information on data forwarding can be found under Dataflow.

The ReceiveData function is called by IP-Symcon. It must therefore be overwritten by the base class in order to add individual extensions

Up to IP-Symcon 5.3 this function had no return value.

Example

// Example within a gateway/splitter instance
public function ReceiveData($JSONString) {
 
    // Received data from I/O
    $data = json_decode($JSONString);
    IPS_LogMessage("ReceiveData", utf8_decode($data->Buffer));
 
    // This is where the data is processed
 
    // Forwarding to all device-/device-instances
    $results = $this->SendDataToChildren(json_encode(Array("DataID" => "{66164EB8-3439-4599-B937-A365D7A68567}", "Buffer" => $data->Buffer)));
 
    // If a child instance delivers a result, this can be used.
    foreach($results as $result) {
        IPS_LogMessage("IOSplitter RECV-RES", $result);
    }
}
 
// Example within a device-/device-instance
public function ReceiveData($JSONString) {
 
    // Received data from the gateway/splitter
    $data = json_decode($JSONString);
    IPS_LogMessage("ReceiveData", utf8_decode($data->Buffer));
 
    // Data processing and writing of the values in the status variables
    SetValue($this->GetIDForIdent("Value"), $data->Buffer);
 
    // Send result back to the gateway/splitter
    return "OK from " . $this->InstanceID;
}
Deutsche Webseite verfügbar
Go to cart
Any questions?