So, schon mal einen Schritt weiter…
Mit deinem Skript, bzw beiden Skripten wurde nun der Timer angelegt.
Allerdings kommt jetzt dieser Fehler im Logger
IPS-Err-PHP 2016-02-19 22:46:36.017 Warning: Parameter type of InstanceID does not match
Error in Script /usr/share/symcon/scripts/48860.ips.php on Line 46
134 in IPSLibrary/app/core/IPSLogger/IPSLogger.inc.php (call IPSLogger_Out)
37 in IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php (call IPSLogger_Err)
in IPSLogger_PhpErrorHandler
46 in 48860.ips.php (call RegVar_SendText)
Zeile 46 ist
RegVar_SendText($IDRegVar, "quintessence
\r"); // start handshake
mein sendData Skript ist wie erwähnt analog deinem
<?
// This Script send events to any Eventghost compatible Client via RegisterVariable -> IPS_Client_Socket
// Outgoing Events are read from "BufferToSend" Variable. This works like a send Buffer
// You should use my "SendToDroid() function to write Commands to the Buffer.
// Register variable MUST be named: "regVarDataBuffer"
// If you want to communicate with Eventghost PC please read comment near line 80
// During communication idle and Client Socket is dissabled (Gray Icon), this improved stability and prevent from mess up logging
// If Client is not reachable (Cleint Software Down) ClintSocket become Red Icon, this is cleard after first succesfull Event transfer.
// It works fine for me, but maybe your enviroment need any aditional error handling, check area around line 62
// The Script had been tested with: Eventghost for PC , Eventghost for Anroid, terRemote for Android
// rev 1.0 created by Bernhard Baptist 04.10.2012
// Change Configuration parameters if needed
$maxRetry = 5; // retries until buffer is cleared
$socketReadyDelay = 10; //delay between retries if socket not ready
$msgDelay = 10; // delay in sec until timeout and command re-send command
//-------------------------------------------------------------------------------------------
// Nothing to configure below this line
$Id_ClientSocket = IPS_GetParent($_IPS['SELF']);
$IDRegVar = @IPS_GetObjectIDByName("RegVarDataBuffer", $Id_ClientSocket);
$IDBuffer = CreateVariableByName($Id_ClientSocket, 'BufferToSend', 3);
$IDerrorCount = CreateVariableByName($Id_ClientSocket, 'errorCount', 1);
Switch ($_IPS['SENDER'])
{
Case "Execute":
// reserved for debug
break;
Case "RunScript":
if (IPS_GetInstance($Id_ClientSocket)['InstanceStatus'] != 102) {// Check if Socket is Active
CSCK_SetOpen($Id_ClientSocket,true);
IPS_ApplyChanges($Id_ClientSocket);
if (IPS_GetInstance($Id_ClientSocket)['InstanceStatus'] != 102) {
IPS_SetScriptTimer($_IPS['SELF'], $socketReadyDelay); //arm Timer for retry
echo "Keine Verbindung zu ".IPS_GetName($Id_ClientSocket);
Return; // Stop in case Socket Open fail
}
}
RegVar_SendText($IDRegVar, "quintessence
\r"); // start handshake
IPS_SetScriptTimer($_IPS['SELF'], $msgDelay); //arm Timer for retry if Fail
break;
Case "TimerEvent":
IPS_SetScriptTimer($_IPS['SELF'], 0); //stop Timer
$errorCount=GetValue($IDerrorCount);
$errorCount=$errorCount+1;
if ($errorCount < $maxRetry) {
SetValue($IDerrorCount,$errorCount);
IPS_RunScript($_IPS['SELF']); // Run next try
}
else {
SetValue($IDerrorCount,0);
SetValueString($IDBuffer,"nothing to send");
// todo: add additional error processing there
}
break;
Case "RegisterVariable":
$data = $_IPS['VALUE'];
$data = trim($data);
Switch ($data) {
Case "accept": // ready to send data
$buffer=GetValueString($IDBuffer); //re-read in case modified meanwhile
$data_to_send= substr($buffer,0,strpos ($buffer ,"_+_"));
$posPayload = strpos ($data_to_send ,",");
if ($posPayload > 0){ // check if Payload should be added
$payload = "payload ".substr($data_to_send,$posPayload+1);
RegVar_SendText($IDRegVar,$payload."
"); //here the payload is sent
$data_to_send= substr($data_to_send,0,$posPayload);
RegVar_SendText($IDRegVar,$data_to_send."
\r"); //here the event is sent
}
else {
RegVar_SendText($IDRegVar,$data_to_send."
\r"); //here the event is sent
}
RegVar_SendText($IDRegVar, "close
\r");
// Eventghost PC does not send "close" so we cannot do proper handshake
// Remark next three lines in case your Client is Eventghost PC
// unremark this line: // sleep(1);
IPS_SetScriptTimer($_IPS['SELF'], $msgDelay); //arm Timer for retry if Fail
break;
case "close": // data successfull send
IPS_SetScriptTimer($_IPS['SELF'], 0); //Send Ok, stop Timer
SetValue($IDerrorCount,0);
CSCK_SetOpen($Id_ClientSocket,false);
$buffer=GetValueString($IDBuffer); //re-read in case modified meanwhile
if (substr_count ($buffer,"_+_")> 1) {
$pos_next =strpos ($buffer ,"_+_");
SetValueString($IDBuffer,substr($buffer,$pos_next+3,strlen($buffer))); //update
// sleep(1); // todo: find minimum delay
IPS_RunScript($_IPS['SELF']); // re-run to process next command
}
else{
SetValueString($IDBuffer,"nothing to send");
}
break;
case "declined": // any problem
// todo: add logic to recover,
CSCK_SetOpen($Id_ClientSocket,false);
IPS_SetScriptTimer($_IPS['SELF'], 1); //arm Timer for retry
break;
Default: // send Hash ti initiate handshake
$data .= ":";
$hash = md5($data);
$hash .= "
";
RegVar_SendText($IDRegVar, $hash);
Break;
}
}
// common helper Function
function CreateVariableByName($id, $name, $type)
{
Global ${$_IPS['SELF']};
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid===false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, "This Variable was created by Script #".$_IPS['SELF']);
}
return $vid;
}
?>
sendtoDroid
<?
// Call this function to add new command to ClientSocket message queue
// Args[$IDBuffer = ID of ClientSocket] [$new... command to be send]
function SendtoDroid($Id_ClientSocket,$new) {
$IDBuffer = @IPS_GetObjectIDByName("BufferToSend", $Id_ClientSocket);
$IDSendScript = @IPS_GetObjectIDByName("sendData", $Id_ClientSocket);
$maxQueueLenght = 10; // max Commands in Queue
$old = GetValueString($IDBuffer);
// cleanup queue if too much commands pending
if (substr_count ($old,"_+_") > $maxQueueLenght) {
$old ='nothing to send'; //todo: add error processing if required
}
if ($old == 'nothing to send') {
SetValue($IDBuffer,$new."_+_");
IPS_RunScript($IDSendScript);
}
else {
SetValue($IDBuffer,$old.$new."_+_");
}
}
?>
„Testmeldung“ (Skript zum Senden)
<?
include_once "SendToDroid_include.ips.php";
// this library provides SendtoDroid() function;
$Wohnzimmer = 32907 /*[Client Socket TZM Tab1]*/;
SendtoDroid($Wohnzimmer,"Say,Bewegung im Garten erkannt");
?>
sind evtl in den letzten beiden Skripten auch noch alte Variablen??
Die Zeile mit „Script #0 does not exist“ kann ich grad nicht zuordnen Was kommt davor noch?
Vor diesem Fehler stand nichts mehr… tritt aber nun auch nicht mehr auf