===================================================================================================== */
$executionID = round(microtime(true)*1000)-(IPS_GetKernelStartTime()*1000);
SendDebug($_IPS[‚SELF‘], ‚S||||‘.$executionID, ‚‘, 0);
$M1 = new IPSEntityInstance($_IPS, 20805);
$M2 = new IPSEntityModuleIf($_IPS);
$M3 = new IPSEntityModuleActionCustM3($_IPS, true,false,false,false,false,false,false,false);
if ($M1->Evaluate()) {
SendDebug($_IPS[‚SELF‘], ‚M1|Motion|M2|SetCondition|‘.$executionID,$M1->GetValue(‚Motion‘),0);
$M2->SetCondition($M1->GetValue(‚Motion‘));
}
if ($M2->Evaluate()===true) {
SendDebug($_IPS[‚SELF‘], ‚M2|GetTrue|M3|SetValue1|‘.$executionID,$M2->GetTrue(),0);
$M3->SetValue1($M2->GetTrue());
} else if ($M2->Evaluate()===false) {
} else {}
$M3->Evaluate();
/* -----------------------------------------------------------------------*/
function SendDebug($id, $message, $data, $format) {
if (is_numeric($data)) {
$data = (string)round($data, 2);
} else if (is_string($data)) {
$data = ‚"‘.$data.’"’;
} else {}
IPS_SendDebug($id, $message, $data, $format);
}
/* -----------------------------------------------------------------------*/
function GetTypeConvertedValue($variableID, $value) {
$variableType = IPS_GetVariable($variableID)[‚VariableType‘];
if ($variableType == 0) return (bool)$value;
else if ($variableType == 1) return (int)$value;
else if ($variableType == 2) return (float)$value;
else return $value;
}
/* -----------------------------------------------------------------------*/
class IPSEntityInstance {
private $ips;
private $id;
public function __construct($ips, $id) {
$this->ips = $ips;
$this->id = $id;
}
private function GetTypeConvertedValue($ident, $value) {
return GetTypeConvertedValue(IPS_GetObjectIDByIdent($ident, $this->id), $value);
}
public function SetValue($ident, $value) {
IPS_RequestAction($this->id, $ident, $this->GetTypeConvertedValue($ident, $value));
}
public function GetValue($ident) {
return GetValue(IPS_GetObjectIDByIdent($ident, $this->id));
}
public function Evaluate() {
return true;
}
}
/* -----------------------------------------------------------------------*/
class IPSEntityModuleIf {
private $ips;
private $value = false;
private $input = false;
public function __construct($ips) {
$this->ips = $ips;
}
public function SetCondition($value) {
$this->value = $value;
$this->input = true;
}
public function GetTrue() {
return $this->value==true;
}
public function GetFalse() {
return $this->value==false;
}
public function Evaluate() {
return $this->input ? $this->value : null;
}
}
/* -----------------------------------------------------------------------*/
class IPSEntityModuleActionCustM3 {
private $ips;
private $result = 0;
private $evaluation = 0;
private $value = array();
private $input = array();
private $linked = array();
public function __construct($ips, $linked1, $linked2, $linked3, $linked4, $linked5, $linked6, $linked7, $linked8) {
$this->ips = $ips;
$this->linked[0] = $linked1;
$this->linked[1] = $linked2;
$this->linked[2] = $linked3;
$this->linked[3] = $linked4;
$this->linked[4] = $linked5;
$this->linked[5] = $linked6;
$this->linked[6] = $linked7;
$this->linked[7] = $linked8;
for ($idx = 0;$idx < 8;$idx++) {
$this->value[$idx] = -1;
$this->input[$idx] = false;
}
}
private function SetValue($idx, $value) {
$this->value[$idx] = $value;
$this->input[$idx] = true;
}
public function SetValue1($value) {
$this->SetValue(0, $value);
}
public function SetValue2($value) {
$this->SetValue(1, $value);
}
public function SetValue3($value) {
$this->SetValue(2, $value);
}
public function SetValue4($value) {
$this->SetValue(3, $value);
}
public function SetValue5($value) {
$this->SetValue(4, $value);
}
public function SetValue6($value) {
$this->SetValue(5, $value);
}
public function SetValue7($value) {
$this->SetValue(6, $value);
}
public function SetValue8($value) {
$this->SetValue(7, $value);
}
public function GetResult() {
return $this->result;
}
public function Evaluate() {
$value1 = $this->value[0];
$value2 = $this->value[1];
$value3 = $this->value[2];
$value4 = $this->value[3];
$value5 = $this->value[4];
$value6 = $this->value[5];
$value7 = $this->value[6];
$value8 = $this->value[7];
$this->evaluation = true;
for ($idx = 0 ; $idx < 8 ; $idx++)
$this->evaluation = $this->evaluation && ($this->input[$idx]==$this->linked[$idx]);
if ($this->evaluation) {
http://192.168.0.94:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Webhook&method="Incoming"&version=1&token=S5QxwGZV2oFAmYBw36HVup2kSyD2AvMV6RFNtOCVuPkXXXXXXXXXXXXXX
}
return $this->evaluation;
}
}
SendDebug($_IPS[‚SELF‘], ‚F||||‘.$executionID, ‚‘, 0);