Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

Commit

Permalink
do not update without simulation data
Browse files Browse the repository at this point in the history
  • Loading branch information
paresy committed Jan 1, 2019
1 parent 6b9b3d6 commit b2e8405
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions AnwesenheitsSimulation/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,32 @@ public function UpdateTargets() {

if(!isset($NextSimulationData[$linkedTargetID])) {
$this->SendDebug("Update", "Device ".$linkedTargetID." has no simulation data for now!", 0);

$targetValue = false;
} else {
$this->SendDebug("Update", "Device ".$linkedTargetID." shall be ".(int)$NextSimulationData[$linkedTargetID]['currentValue']." since ".$NextSimulationData[$linkedTargetID]['currentTime']." and currently is ".(int)$v["VariableValue"], 0);

//Set variableValue, if there is a currentValue and its not the same as already set
$targetValue = $NextSimulationData[$linkedTargetID]['currentValue'];
}

if ($targetValue != $v["VariableValue"]) {

$o = IPS_GetObject($linkedTargetID);
if($v['VariableCustomAction'] != "") {
$actionID = $v['VariableCustomAction'];
} else {
$actionID = $v['VariableAction'];
}

$this->SendDebug("Action", "Device ".$linkedTargetID." will be updated!", 0);

if(IPS_InstanceExists($actionID)) {
IPS_RequestAction($actionID, $o['ObjectIdent'], $targetValue);
} else if(IPS_ScriptExists($actionID)) {
echo IPS_RunScriptWaitEx($actionID, Array("VARIABLE" => $linkedTargetID, "VALUE" => $targetValue));
//Only update if target differs
if ($targetValue != $v["VariableValue"]) {

$o = IPS_GetObject($linkedTargetID);
if($v['VariableCustomAction'] != "") {
$actionID = $v['VariableCustomAction'];
} else {
$actionID = $v['VariableAction'];
}

$this->SendDebug("Action", "Device ".$linkedTargetID." will be updated!", 0);

if(IPS_InstanceExists($actionID)) {
IPS_RequestAction($actionID, $o['ObjectIdent'], $targetValue);
} else if(IPS_ScriptExists($actionID)) {
echo IPS_RunScriptWaitEx($actionID, Array("VARIABLE" => $linkedTargetID, "VALUE" => $targetValue));
}

}

}
}

Expand Down

0 comments on commit b2e8405

Please sign in to comment.