« Back to Product

Documentation

Data management

Require: IP-Symcon >= 4.0

Description

A module basically has four different forms of managing data. These are properties, attributes, buffers and status variables. These differ in terms of task, access options and persistence.

Properties
Attributes
Buffer
Status Variables

Properties

Properties are persistent data of a module which should/must be configured by the user. This data is only saved when "Apply" is clicked. Properties are, for example, required login data, device ID or interval for calling up sensor values. This is usually done via the configuration page, which is defined via the form.json.

Function name Brief description
ReadPropertyBoolean Returns the value of a boolean property
ReadPropertyFloat Returns the value of a float property
ReadPropertyInteger Returns the value of an integer property
ReadPropertyString Returns the value of a string property
RegisterPropertyBoolean Creates a boolean property
RegisterPropertyFloat Creates a float property
RegisterPropertyInteger Creates an integer property
RegisterPropertyString Creates a string property
public function Create() {
     //Never delete this line!
     parent::Create();
     $this->RegisterPropertyBoolean("EmulateStatus", true);
     $this->RegisterPropertyFloat("Faktor", 0.5);
     $this->RegisterPropertyInteger("DeviceID", 0);
     $this->RegisterPropertyString("Text", "");
 }

Attributes

Attributes are persistent data of a module, which are only set by the module itself and saved immediately. These are, for example, tokens for encrypted connections or saved values of a scene control.

Function name Brief description
ReadAttributeBoolean Returns the value of a boolean attribute
ReadAttributeFloat Returns the value of a float attribute
ReadAttributeInteger Returns the value of an integer attribute
ReadAttributeString Returns the value of a string attribute
RegisterAttributeBoolean Creates a boolean attribute
RegisterAttributeFloat Creates a float attribute
RegisterAttributeInteger Creates an integer attribute
RegisterAttributeString Creates a string attribute
WriteAttributeBoolean Writes in a boolean attribute
WriteAttributeFloat Writes to a float attribute
WriteAttributeInteger Writes in an integer attribute
WriteAttributeString Writes to a string attribute

Example

public function Create() {
     //Never delete this line!
     parent::Create();
     $this->RegisterAttributeBoolean("BoolAttr", true);
     $this->RegisterAttributeInteger("IntAttr", 5);
     $this->RegisterAttributeFloat("FloatAttr", 3.7);
     $this->RegisterAttributeString("StrAttr", "lalala");
 }
public function BumpAndShow() {
var_dump($this->ReadAttributeBoolean("BoolAttr"));
     var_dump($this->ReadAttributeInteger("IntAttr"));
     var_dump($this->ReadAttributeFloat("FloatAttr"));
     var_dump($this->ReadAttributeString("StrAttr"));
     $this->WriteAttributeBoolean("BoolAttr", !$this->ReadAttributeBoolean("BoolAttr"));
     $this->WriteAttributeInteger("IntAttr", $this->ReadAttributeInteger("IntAttr")*2);
     $this->WriteAttributeFloat("FloatAttr", $this->ReadAttributeFloat("FloatAttr")+0.1);
     $this->WriteAttributeString("StrAttr", $this->ReadAttributeString("StrAttr") . "öäü");
 }

Buffer

Buffers are non-persistent data of a module, which should only be managed by the module itself. These are, for example, incoming data records that are not transmitted in one, but arrive gradually and therefore have to be put together. These are only taken from the buffer and processed by the module when the data record is complete.

Function name Brief description
GetBuffer Returns the content of a buffer
GetBufferList Returns an array of all buffers
SetBuffer Creates a buffer

Example

public function ReceiveData($JSONString) {
     //Decode JSONString
     $data = json_decode($JSONString);
     //Parse and write values to our buffer
     $this->SetBuffer("Test", utf8_decode($data->Buffer));
     //Print buffer
     IPS_LogMessage("IOTest", $this->GetBuffer("Test"));
 }

Status Variables

Status variables are persistent data of a module, which can be changed by the module at any time. These are visible in the object tree and are available for further processing and display in the Visualizations. Status variables are, for example, sensor values, actuator values to be displayed on the WebFront and status values for further processing.

Function name Brief description
DisableAction Disables the default action
EnableAction Activates the default action
GetValue Returns the value of a variable
SetValue Sets the value of a variable
MaintainAction Calls DisableAction or EnableAction
MaintainVariable Configures a status variable
RegisterVariableBoolean Creates a Boolean status variable
RegisterVariableFloat Creates a float status variable
RegisterVariableInteger Creates an integer status variable
RegisterVariableString Creates a string status variable
RequestAction Sets the value of a status variable
UnregisterVariable Deletes a status variable

Example

public function Create() {
     //Never delete this line!
     parent::Create();
     // Variables
     $this->RegisterVariableString("TextData", "TextData", "");
     IPS_SetHidden($this->GetIDForIdent("TextData"), true);
     $this->RegisterVariableString("SimulationView", "SimulationView", "~HTMLBox");
     $this->RegisterVariableInteger("SimulationCounter", "SimulationCounter" , "");
     $this->RegisterVariableFloat("Factor", "Zoom Factor Wall Display", "Factor.Display");
     $this->RegisterVariableBoolean("Active", "Simulation active", "~Switch");
     $this->EnableAction("Active");
 }
Any questions?