IRcodes per designer an ir-trans

Weil nicht jedes senden eines IR-commando ein script braucht diese lösung:


<?
/*
*******************************
 IP-SYMCON Event Scripting
*******************************
File     : irtrans.ips.php
Trigger  : 
Interval : 
*/
include(IPS_GetScriptFile("GlobalDefines"));

//debug
$ldebug=true;
$debug=GetValueBoolean("__debug");
$logfilepath=__myhome."/log/liv_irtrans.txt";

if ($debug) {
   $handle=fopen("$logfilepath", "a");
   if (!$handle){
      // error cannot open file
      echo("******* ERROR: Cannot open file '$tempfilepath'
");
   }
}
if ($IPS_SENDER=="Execute"){
  $IPS_COMPONENT="sony864|10|sony864|1|sony864|1";
 //               01234567890123456789
  $IPS_SENDER="Designer";
  $IPS_VARIABLE="vliv_lamp_bureau";
  $IPS_TRIGGER="";
  $IPS_VALUE="";
  if ($ldebug) echo("IPS_COMPENENT: '$IPS_COMPONENT'
");
}
if ($IPS_SENDER=="Designer"){
   $pos1=strpos($IPS_COMPONENT,"|");
   $pos2=strpos($IPS_COMPONENT,"|",$pos1+1);
   if ($ldebug) echo("pos1:'$pos1'	 pos2:'$pos2'
");
   $remote=substr($IPS_COMPONENT,0,$pos1);
}
if ($pos2==0){
   $command=substr($IPS_COMPONENT,$pos1+1);
}else{
   $command=substr($IPS_COMPONENT,$pos1+1,$pos2-$pos1-1);
}
$pos=$pos2;
if ($debug) fwrite($handle,time()."ONCE sender:'$IPS_SENDER' remote:'$remote' command:'$command'
");
if ($debug) echo("ONCE: remote:'$remote'  command:'$command'
");
WinLIRC_SendOnce(mliv_irtrans1,$remote, $command);
usleep(300000);
while ($pos2>0){
   $pos1=strpos($IPS_COMPONENT,"|",$pos2+1);
   if ($ldebug) echo("pos1=$pos1
");
   $pos2=strpos($IPS_COMPONENT,"|",$pos1+1);
   if ($ldebug) echo("pos2=$pos2
");
   if ($pos2==0) {
      $remote=substr($IPS_COMPONENT,$pos+1,$pos1-$pos-1);
      $command=substr($IPS_COMPONENT,$pos1+1);
   }else {
      $remote=substr($IPS_COMPONENT,$pos+1,$pos1-$pos-1);
      $command=substr($IPS_COMPONENT,$pos1+1,$pos2-$pos1-1);
   }
   if ($debug) fwrite($handle,time()."MULTIPLE sender:'$IPS_SENDER' remote:'$remote' command:'$command'
");
   if ($debug) echo("MULTI: remote:'$remote'  command:'$command'
");
   WinLIRC_SendOnce(mliv_irtrans1,$remote, $command);
   usleep(300000);
   $pos=$pos2;
}
if ($debug) fclose($handle);
?>

Jeder button im designer bekommt ein onclick-event die das oberige script triggert.
In die ‚IPSYMID‘ steht der aus zu sendene string zb:


sony864|10|sony864|1|sony864|1

Hier wird fur gerät sony864 eine ‚10‘, eine ‚1‘ und eine ‚1‘ gesendet.
In realität heisst es
10+ taste /
dan eine 1 1/_
und noch eine 1 1/1
gleicht kanal 11 am ferseher.

Wie der thread sagt: unfertig

PS: die

usleep(300000);

(2x) im script anpassen an die geschwidigkeit vom gerät. Erfahrungswert. (50000 war zu kurz fur meine ferseher.)