Hallo,
vielen Dank erst mal für die schnelle Rückmeldung!
Ja, die Variable im Objektbaum wird richtig gesetzt und damit das Aktionsskript ausgeführt.
Also scheint mein Problem in dem IPS_RunScriptEx Aufruf zu liegen.
Da werde ich mal noch etwas Fehleranalyse betreiben.
Falls jemand mal einen Blick darauf werfen möchte, hänge ich es hier mal hinten ran.
Vielleicht sieht der Profi auf die Schnelle etwas, wonach ich Stunden lang suchen muss.
(Kann gut sein, dass mein Code nicht sehr elegant ist)
Das Hochladen von Dateien funktioniert auf meinem Laptop irgendwie nicht, deshalb direkt im Post.
YamahaControl
<?
$host = '192.168.100.71'; //IP des Gerätes
// 0 = Power OFF
// 1 = Power ON
// 2 = Main Zone Mute ON
// 3 = Main Zone Mute Off
// 4 = Main Zone Mute On/Off
// 5 = Main Zone leiser (2 dB)
// 6 = Main Zone lauter (2 dB)
// 7 = Main Zone 55 dB setzten
// 8 = Power ON/OFF
// 11= Scene RADIO
// 12= Scene NET
// 13= Scene Windows
// 14= Scene CD
// 20= TUNER
// 21= TUNER Sunshine Live
// 22= TUNER RTL
// 23= TUNER Energy
// 24= TUNER rs.2
// 30= NetRadio
// 31= NetRadio Load Preset 1
// 32= NetRadio Load Preset 2
// 33= NetRadio Load Preset 3
// 34= NetRadio Load Preset 4
// 35= NetRadio Load Preset 5
// 36= NetRadio Load Preset 6
// 99= Power toggle
// 100= Get Power Status
// 101= Lautstärke abfragen
switch ($_IPS['Control']) {
//switch (101) {
case 0:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>Standby</Power></Power_Control></Main_Zone></YAMAHA_AV>');
//$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><System><Power_Control><Power>Standby</Power></Power_Control></System></YAMAHA_AV>');
break;
case 1:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>On</Power></Power_Control></Main_Zone></YAMAHA_AV>');
break;
case 2:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Mute>On</Mute></Volume></Main_Zone></YAMAHA_AV>');
break;
case 3:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Mute>Off</Mute></Volume></Main_Zone></YAMAHA_AV>');
break;
case 4:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Mute>On/Off</Mute></Volume></Main_Zone></YAMAHA_AV>');
break;
case 5:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>Down 2 dB</Val><Exp></Exp><Unit></Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
break;
case 6:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>Up 2 dB</Val><Exp></Exp><Unit></Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
break;
case 7:
// $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>-550</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>'.$_IPS['Volume'].'</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
break;
case 8:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>On/Standby</Power></Power_Control></Main_Zone></YAMAHA_AV>');
break;
case 11:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 4</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
break;
case 12:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 3</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
break;
case 13:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 2</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
break;
case 14:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 1</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
break;
case 20:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Input><Input_Sel>TUNER</Input_Sel></Input></Main_Zone></YAMAHA_AV>');
break;
case 21:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Tuner><Play_Control><Preset><Preset_Sel>1</Preset_Sel></Preset></Play_Control></Tuner></YAMAHA_AV>');
break;
case 22:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Tuner><Play_Control><Preset><Preset_Sel>2</Preset_Sel></Preset></Play_Control></Tuner></YAMAHA_AV>');
break;
case 23:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Tuner><Play_Control><Preset><Preset_Sel>3</Preset_Sel></Preset></Play_Control></Tuner></YAMAHA_AV>');
break;
case 30:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Input><Input_Sel>NET</Input_Sel></Input></Main_Zone></YAMAHA_AV>');
break;
case 31:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_1</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
break;
case 32:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_2</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
break;
case 33:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_3</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
break;
case 34:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_4</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
break;
case 35:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_5</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
break;
case 36:
$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_6</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
break;
case 100:
$send = send_to_host($host,'<YAMAHA_AV cmd="GET"><Main_Zone><Power_Control><Power>GetParam</Power></Power_Control></Main_Zone></YAMAHA_AV>');
// $send = send_to_host($host,'<YAMAHA_AV cmd="GET"><NET_RADIO><List_Info>GetParam</List_Info></NET_RADIO></YAMAHA_AV>');
// $send = send_to_host($host,'<YAMAHA_AV cmd="GET"><System><Config>GetParam</Config></System></YAMAHA_AV>');
if ($send == "On") SetValueBoolean(21468 /*[EG\Yamaha\Yamaha AV Receiver\Power]*/ , TRUE);
if ($send == "Standby") SetValueBoolean(21468 /*[EG\Yamaha\Yamaha AV Receiver\Power]*/ , FALSE);
break;
case 101:
$send = send_to_host($host,'<YAMAHA_AV cmd="GET"><Main_Zone><Volume><Lvl>GetParam</Lvl></Volume></Main_Zone></YAMAHA_AV>');
SetValue(20677 /*[EG\Yamaha\Yamaha AV Receiver\Volume]*/ ,substr($send,0,3).",".substr($send,3,1));
// SetValue(20677 /*[EG\Yamaha\Yamaha AV Receiver\Volume]*/ ,substr($send,0,4));
break;
}
//echo "
send: ".$send; //Wenn Ok dann wird true (1) zurückgegeben
function send_to_host($host, $data){
//echo $data; //zum prüfen
$command_lenght = strlen($data);
//echo $command_lenght; //zum prüfen
$head = "";
$head .= "POST /YamahaRemoteControl/ctrl HTTP/1.1
";
$head .= "Host: ".$host."
";
$head .= "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
";
$head .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
";
$head .= "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
";
$head .= "Accept-Encoding: gzip, deflate
";
$head .= "Connection: keep-alive
";
$head .= "Content-Type: text/xml; charset=UTF-8
";
$head .= "Referer: http://".$host."/
";
$head .= "Content-Length: ".$command_lenght."
";
$head .= "Pragma: no-cache
";
$head .= "Cache-Control: no-cache
";
$head .= $data;
// echo $head; //zum prüfen
$fp = fsockopen($host, 80) or die("Unable to open socket");
fputs($fp, $head);
$buf='';
$buf2='';
$buf = fgets($fp,128);
while(!feof($fp)) {
// receive the results of the request
$buf2 = fgets($fp,192);
}
fclose($fp);
$buf2 = strip_tags($buf2);
// echo "buf:
".$buf; //zum prüfen
// echo "buf2:
".$buf2."
"; //zum prüfen
$return = substr($buf,13,2);
if ($buf2 <> "") $return = $buf2;
return $return;
}
?>