Und die Moral von der Geschichte…Skript ist veraltet mit alten Systemvariablen…die müssen durch die neuen ersetzt werden:
Systemvariablen — IP-Symcon :: Automatisierungssoftware
Die Zeile mit „Script #0 does not exist“ kann ich grad nicht zuordnen
Was kommt davor noch?
Und was steckt da im Skript dahinter für ein Befehl/Code? >> 48860.ips.php on Line 47
Hier mal meine überarbeitete/neue Version vom „sendData“ Skript:
<?
// 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;
}
?>
Und so sieht das bei mir aus im Objektbaum:
![terremote_clientsocket.jpg](https://community.symcon.de/uploads/default/original/2X/0/0886bae44fc470016c24e96521807b06f9e24ae8.jpeg)
[HR][/HR]
Das hier ist dann der ServerSocket:
![terremote_serversocket.jpg](https://community.symcon.de/uploads/default/original/2X/6/625b1d4a3bed9788ac79f2311d614a8f59b6ec8a.jpeg)
Und das hier der Inhalt von meinem überarbeiteten/neuen „receiveData“ Skript:
<?
// This Script receives events fom any Eventghost compatible Client via IPS_Server_Socket -> RegisterVariable
// Incoming Events are interpreted as IPS - Variables, Payloads are interpreted their content
// This means: If a event with payload is received. Then the payload is written in the variable with the same name as event has.
// If a event without payload is received. Then the the Variable with the same name as the event is set to ""
//
// Payloads are interpreted as String.
// PLEASE NOTE: Only one Payload is allowed !!!
// The Script had been tested with: Eventghost for PC , Eventghost for Anroid, terRemote for Android
// rev 1.0 created by Bernhard Baptist 03.10.2012
// Change ID to your ClientServerID
$ID_ServerSocket = 26555 /*[Tablet WZ SS]*/;
// Set to false if you want to create variables manually --> take care the variable must 100% match with event name
// IF set to true the script will create a new variable each time a new event is received first --> less work if you have lot of events
$autoCreateVariables = true;
// Default: Variables are located below the ClientServer Instance.
// Option: Change ID to the Categorie or Instance you want to have your Variables stored
$IDInstanceVariables = 56779 /*[Hardware\Tablets\Android_13.3_WZ erRemote_Variablen]*/; //$ID_ServerSocket;
//----------------------------------------------------------------------------------------------------------------------------------
// below here nothing to be changed
$IDRegVar = @IPS_GetObjectIDByName("regVarDataBuffer", $ID_ServerSocket);
$IDPayloadBuffer = CreateVariableByName($ID_ServerSocket, "ReceiveBuffer", 3);
$data = trim($_IPS['VALUE']);
$myID = "IPS_Server"; // any random IDString
$hash = md5($myID.":"); // calculate hash
Switch ($data) {
Case "quintessence": // ready to send data
RegVar_SendText($IDRegVar, $myID."
"); // send your ID String, Client will calculate hash
Break;
Case $hash:
RegVar_SendText($IDRegVar, "accept"."
"); // Confirm hash is correct and initiat data transfer
Break;
Default:
if ( substr($data,0,7) == "payload") { // check if paylod or event received
$payload = substr($data,8); // remove string payload
if ($payload == "withoutRelease") { // Eventghost PC send always with payload, but if empty the content is "withoutRelease"
$payload = "";
}
SetValueString($IDPayloadBuffer,$payload); // write Payload to Buffer temporarly
}
else { // we got an event
$event = substr($data,strpos($data,"close")); // remove "close" <<<-- maybe to be adjusted for alternative EG Clients
if ($autoCreateVariables == true) {
$IDVar = CreateVariableByName($IDInstanceVariables, $event, 3);
}
else {
$IDVar = @IPS_GetVariableIDByName($event, $IDInstanceVariables);
}
If ($IDVar <> Null) {
$payload = GetValue($IDPayloadBuffer); // fetch payload from Buffer
SetValueString($IDVar,$payload); // write data to variable
SetValueString($IDPayloadBuffer,"");
}
}
Break;
}
// ---------------------------------------------------------------------------------------------------------------------
// Standard Function to Get VarID
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;
}
?>
Ich hab mal bewusst alles geposted, weil ich keine Ahnung mehr habe, was ich da so geändert habe oder nicht
Irgendwas war da…aber ist zu lang her ![:smiley: :smiley:](https://community.symcon.de/images/emoji/win10/smiley.png?v=9)
Ich weiß noch, dass das bei mir auch nicht gleich auf Anhieb lief. Immer mal den Port vom terRemote geändert und Tablet Neustart usw usw usw…und irgendwann lief es dann
Glaub das terRemote wollte bei mir auch nicht als Dienst laufen oder keine Ahnung g
Schau einfach mal, was du mit den ganzen Infos so anfangen kannst, übearbeite die Skripte oder tausche sie aus und dann kannst dich ja mit neuen Fragen/Fehlern melden ![:slight_smile: :slight_smile:](https://community.symcon.de/images/emoji/win10/slight_smile.png?v=9)
Grüße,
Chris