Sony Bravia TV 2014 per Lan steuern

Hi,

habe heute es mal hinbekommen, mein BRAVIA KDL-48W585B (Bj 2014) per IPS zu steuern.
Dazu habe ich folgendes unter Linux benutzt:

Dananch ein IPS Skript erstellt :

<?
$did = 1;
$cookie=GetValueString (21728 /*[.Skripte\Sony BRAVIA TV\Wohnen\Anmeldung Bravia 2014\auth :]*/ );
$controllerinfo = json_decode('{"id":10,"result":[{"bundled":true,"type":"RM-J1100"}
,[{"name":"PowerOff","value":"AAAAAQAAAAEAAAAvAw=="}
,{"name":"Input","value":"AAAAAQAAAAEAAAAlAw=="}
,{"name":"GGuide","value":"AAAAAQAAAAEAAAAOAw=="}
,{"name":"EPG","value":"AAAAAgAAAKQAAABbAw=="}
,{"name":"Favorites","value":"AAAAAgAAAHcAAAB2Aw=="}
,{"name":"Display","value":"AAAAAQAAAAEAAAA6Aw=="}
,{"name":"Home","value":"AAAAAQAAAAEAAABgAw=="}
,{"name":"Options","value":"AAAAAgAAAJcAAAA2Aw=="}
,{"name":"Return","value":"AAAAAgAAAJcAAAAjAw=="}
,{"name":"Up","value":"AAAAAQAAAAEAAAB0Aw=="}
,{"name":"Down","value":"AAAAAQAAAAEAAAB1Aw=="}
,{"name":"Right","value":"AAAAAQAAAAEAAAAzAw=="}
,{"name":"Left","value":"AAAAAQAAAAEAAAA0Aw=="}
,{"name":"Confirm","value":"AAAAAQAAAAEAAABlAw=="}
,{"name":"Red","value":"AAAAAgAAAJcAAAAlAw=="}
,{"name":"Green","value":"AAAAAgAAAJcAAAAmAw=="}
,{"name":"Yellow","value":"AAAAAgAAAJcAAAAnAw=="}
,{"name":"Blue","value":"AAAAAgAAAJcAAAAkAw=="}
,{"name":"Num1","value":"AAAAAQAAAAEAAAAAAw=="}
,{"name":"Num2","value":"AAAAAQAAAAEAAAABAw=="}
,{"name":"Num3","value":"AAAAAQAAAAEAAAACAw=="}
,{"name":"Num4","value":"AAAAAQAAAAEAAAADAw=="}
,{"name":"Num5","value":"AAAAAQAAAAEAAAAEAw=="}
,{"name":"Num6","value":"AAAAAQAAAAEAAAAFAw=="}
,{"name":"Num7","value":"AAAAAQAAAAEAAAAGAw=="}
,{"name":"Num8","value":"AAAAAQAAAAEAAAAHAw=="}
,{"name":"Num9","value":"AAAAAQAAAAEAAAAIAw=="}
,{"name":"Num0","value":"AAAAAQAAAAEAAAAJAw=="}
,{"name":"Num11","value":"AAAAAQAAAAEAAAAKAw=="}
,{"name":"Num12","value":"AAAAAQAAAAEAAAALAw=="}
,{"name":"VolumeUp","value":"AAAAAQAAAAEAAAASAw=="}
,{"name":"VolumeDown","value":"AAAAAQAAAAEAAAATAw=="}
,{"name":"Mute","value":"AAAAAQAAAAEAAAAUAw=="}
,{"name":"ChannelUp","value":"AAAAAQAAAAEAAAAQAw=="}
,{"name":"ChannelDown","value":"AAAAAQAAAAEAAAARAw=="}
,{"name":"SubTitle","value":"AAAAAgAAAJcAAAAoAw=="}
,{"name":"ClosedCaption","value":"AAAAAgAAAKQAAAAQAw=="}
,{"name":"Enter","value":"AAAAAQAAAAEAAAALAw=="}
,{"name":"DOT","value":"AAAAAgAAAJcAAAAdAw=="}
,{"name":"Analog","value":"AAAAAgAAAHcAAAANAw=="}
,{"name":"Teletext","value":"AAAAAQAAAAEAAAA/Aw=="}
,{"name":"Exit","value":"AAAAAQAAAAEAAABjAw=="}
,{"name":"Analog2","value":"AAAAAQAAAAEAAAA4Aw=="}
,{"name":"*AD","value":"AAAAAgAAABoAAAA7Aw=="}
,{"name":"Digital","value":"AAAAAgAAAJcAAAAyAw=="}
,{"name":"Analog?","value":"AAAAAgAAAJcAAAAuAw=="}
,{"name":"BS","value":"AAAAAgAAAJcAAAAsAw=="}
,{"name":"CS","value":"AAAAAgAAAJcAAAArAw=="}
,{"name":"BSCS","value":"AAAAAgAAAJcAAAAQAw=="}
,{"name":"Ddata","value":"AAAAAgAAAJcAAAAVAw=="}
,{"name":"PicOff","value":"AAAAAQAAAAEAAAA+Aw=="}
,{"name":"Tv_Radio","value":"AAAAAgAAABoAAABXAw=="}
,{"name":"Theater","value":"AAAAAgAAAHcAAABgAw=="}
,{"name":"SEN","value":"AAAAAgAAABoAAAB9Aw=="}
,{"name":"InternetWidgets","value":"AAAAAgAAABoAAAB6Aw=="}
,{"name":"InternetVideo","value":"AAAAAgAAABoAAAB5Aw=="}
,{"name":"Netflix","value":"AAAAAgAAABoAAAB8Aw=="}
,{"name":"SceneSelect","value":"AAAAAgAAABoAAAB4Aw=="}
,{"name":"Mode3D","value":"AAAAAgAAAHcAAABNAw=="}
,{"name":"iManual","value":"AAAAAgAAABoAAAB7Aw=="}
,{"name":"Audio","value":"AAAAAQAAAAEAAAAXAw=="}
,{"name":"Wide","value":"AAAAAgAAAKQAAAA9Aw=="}
,{"name":"Jump","value":"AAAAAQAAAAEAAAA7Aw=="}
,{"name":"PAP","value":"AAAAAgAAAKQAAAB3Aw=="}
,{"name":"MyEPG","value":"AAAAAgAAAHcAAABrAw=="}
,{"name":"ProgramDescription","value":"AAAAAgAAAJcAAAAWAw=="}
,{"name":"WriteChapter","value":"AAAAAgAAAHcAAABsAw=="}
,{"name":"TrackID","value":"AAAAAgAAABoAAAB+Aw=="}
,{"name":"TenKey","value":"AAAAAgAAAJcAAAAMAw=="}
,{"name":"AppliCast","value":"AAAAAgAAABoAAABvAw=="}
,{"name":"acTVila","value":"AAAAAgAAABoAAAByAw=="}
,{"name":"DeleteVideo","value":"AAAAAgAAAHcAAAAfAw=="}
,{"name":"PhotoFrame","value":"AAAAAgAAABoAAABVAw=="}
,{"name":"TvPause","value":"AAAAAgAAABoAAABnAw=="}
,{"name":"KeyPad","value":"AAAAAgAAABoAAAB1Aw=="}
,{"name":"Media","value":"AAAAAgAAAJcAAAA4Aw=="}
,{"name":"SyncMenu","value":"AAAAAgAAABoAAABYAw=="}
,{"name":"Forward","value":"AAAAAgAAAJcAAAAcAw=="}
,{"name":"Play","value":"AAAAAgAAAJcAAAAaAw=="}
,{"name":"Rewind","value":"AAAAAgAAAJcAAAAbAw=="}
,{"name":"Prev","value":"AAAAAgAAAJcAAAA8Aw=="}
,{"name":"Stop","value":"AAAAAgAAAJcAAAAYAw=="}
,{"name":"Next","value":"AAAAAgAAAJcAAAA9Aw=="}
,{"name":"Rec","value":"AAAAAgAAAJcAAAAgAw=="}
,{"name":"Pause","value":"AAAAAgAAAJcAAAAZAw=="}
,{"name":"Eject","value":"AAAAAgAAAJcAAABIAw=="}
,{"name":"FlashPlus","value":"AAAAAgAAAJcAAAB4Aw=="}
,{"name":"FlashMinus","value":"AAAAAgAAAJcAAAB5Aw=="}
,{"name":"TopMenu","value":"AAAAAgAAABoAAABgAw=="}
,{"name":"PopUpMenu","value":"AAAAAgAAABoAAABhAw=="}
,{"name":"RakurakuStart","value":"AAAAAgAAAHcAAABqAw=="}
,{"name":"OneTouchTimeRec","value":"AAAAAgAAABoAAABkAw=="}
,{"name":"OneTouchView","value":"AAAAAgAAABoAAABlAw=="}
,{"name":"OneTouchRec","value":"AAAAAgAAABoAAABiAw=="}
,{"name":"OneTouchStop","value":"AAAAAgAAABoAAABjAw=="}
,{"name":"DUX","value":"AAAAAgAAABoAAABzAw=="}
,{"name":"FootballMode","value":"AAAAAgAAABoAAAB2Aw=="}
,{"name":"Social","value":"AAAAAgAAABoAAAB0Aw=="}
]    ]}',true);
$codes = array();
foreach($controllerinfo['result'] as $k => $v) {
foreach($v as $code) {
if (isset($code['name'])) {
$codes[$code['name']] = $code['value'];
}
}
}

function sendCommand($key) {
global $codes;
$data = '<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>';
$data .= '<u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">
<IRCCCode>'.$codes[$key].'</IRCCCode>
</u:X_SendIRCC>';
$data .= '</s:Body>
</s:Envelope>';
sendCurlPost('/sony/IRCC',$data);

}

function sendCurlPost($url,$data, $auth = false) {
global $cookie, $tvip;
$headers = array();
// $cookie = "auth=e708c3f8033c42f46681c01aa5155eb451f00c88bb7969a2380a9c31eaabb48f";
$headers[] = "Cookie: " . $cookie;
$headers[] = 'Content-Type: text/xml; charset=UTF-8';
$headers[] = 'Content-Length: ' . strlen($data);
$ch = curl_init('http://'. $tvip . $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
return curl_exec($ch);
}

function WakeOnLan($mac, $addr) {
	$addr_byte = explode(':', $mac);
	$hw_addr = '';

	for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));

	$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);

	for ($a = 1; $a <= 16; $a++)    $msg .= $hw_addr;

	$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
	if ($s == false) {
		echo "Error creating socket!
";
		echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
		return false;
	} else {
		$opt_ret =  socket_set_option($s, 1, 6, TRUE);
		if($opt_ret < 0) {
			echo "setsockopt() failed, error: " . strerror($opt_ret) . "
";
			return false;
		}
		$e = socket_sendto($s, $msg, strlen($msg), 0, $addr, 2050);
		socket_close($s);
		return true;
	}
}

?>

$controllerinfo und $cookie habe ich mir aus den Linux Daten nach Ausführung gezogen.
Die „auth.sh“ legt eine Datei mit dem cookie an, die Daten in $cookie setzen.
Die „print_ircc_codes.sh“ zeigt Euch die $controllerinfo an, die Euer Gerät ünterstützt
Die Daten habe ich in der oberen „sony.ips.php“ eingetragen.

Auruf zum Test mit :

<?
include IPS_GetKernelDir().‚scripts/sony.ips.php‘;
$tvip = „192.168.1.61“; //mein TV IP
sendCommand(„Mute“); // Command aus $controllerinfo
?>

Somit kann ich alles machen.
Bei meinem TV muss erst eine Anmeldung erfolgen, über die „auth.sh“, dann erscheint für 60Sekunden ein Kennwort auf dem TV, innerhalb dieser 60 Sekunden muss die Eingabe in der „auth.sh“ erfolgen und bestätigt werden.

ps muss „Sony BRAVIA TV 2014 per Lan steuern“ heißen …

WakeOnLan eingebaut.

Habe das Thema mal in den generellen Anleitungen Bereich verschoben. Das müsste auf dem normalen IPS genauso laufen :slight_smile:

paresy

Hallo,

noch ein Anmelde Skript für die Sony Bravia TV 2014 direkt aus IPS :

<?
$tv_ip='192.168.1.61';
# use only A-Z a-z 0-9 for device. Probably. Haven't checked.
$my_device=GetValueString (56962 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\my_device]*/);
$my_nick=GetValueString (51239 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\my_nick]*/);
$my_uuid=GetValueString (43928 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\my_uuid]*/);

// Start anlernen
$url ='/sony/accessControl';
$data='{"method":"actRegister","params":[{"clientid":"'.$my_nick.':'.$my_uuid.'","nickname":"'.$my_nick.' ('.$my_device.')","level":"private"},[{"value":"yes","function":"WOL"}]],"id":8,"version":"1.0"}';
$ch = curl_init('http://'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
curl_close($ch);
//echo $ausgabe.chr(10);
// Hier auf Eingabe vom Code warten (WebFront)
$tv_key ='Neu';
SetValueString (40397 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\Code vom TV eingeben:]*/ , $tv_key);
$i = 0;
while( $tv_key === 'Neu')
{
	$tv_key=GetValueString (40397 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\Code vom TV eingeben:]*/ );
//	echo $tv_key;
	IPS_sleep(1000);
   $i++;
   if( $i == 40 )break;
}

// Key senden
$tv_key=GetValueString (40397 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\Code vom TV eingeben:]*/ );
//echo $tv_key;
$tv_key=':'.$tv_key;
$tv_challenge = base64_encode($tv_key);
$tv_auth_header='Authorization: Basic '.$tv_challenge;
//echo $tv_auth_header.chr(10);
$headers = array();
$headers[]=$tv_auth_header;
$ch = curl_init('http://'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
list($headers, $response) = explode("

", $ausgabe, 2);
$headers = explode("
", $headers);
foreach($headers as $header) {
    if (stripos($header, 'Set-Cookie:') !== false) {
//        echo $header.chr(10);
        $header = substr($header,0,strpos($header,";"));
        $auth = strstr($header, "a");
//		  echo $auth;
        SetValueString (21728 /*[.Skripte\Sony BRAVIA TV\Wohnen\Sony FB anmelden\auth]*/ , $auth );
    }
}
?>

im Webfrot sieht es so aus :
sony1.png

Und noch das Skript für die Tasten der FB (noch nicht alles drin…):

<?
include IPS_GetKernelDir().'scripts/57676.ips.php';
$tvip = "192.168.1.61";
$mac = "FC:F1:52:72:7E:A3"; //MAC Adresse Sony für WOL
$addr = "255.255.255.255"; // Broadcast adresse für WOL

$_befehl = "";
if($_IPS["SENDER"] == "WebFront")
{
    SetValue($_IPS["VARIABLE"], $_IPS["VALUE"]);
//	 print($_IPS["Value"]);
}
$_control = ($_IPS["VALUE"]);

  if ($_control === 0){
   WakeOnLan($mac, $addr);
  } else
  {
  if ($_control === 1) ($_befehl="PowerOff");
  if ($_control === 2) ($_befehl="Red" );
  if ($_control === 3) ($_befehl="Green" );
  if ($_control === 4) ($_befehl="Yellow" );
  if ($_control === 5) ($_befehl="Blue" );
  if ($_control === 6) ($_befehl="Up" );
  if ($_control === 7) ($_befehl="Left" );
  if ($_control === 8) ($_befehl="Right" );
  if ($_control === 9) ($_befehl="Down" );
  if ($_control === 10)($_befehl="Confirm" );
  if ($_control === 11)($_befehl="" );
  if ($_control === 12)($_befehl="VolumeDown" );
  if ($_control === 13)($_befehl="VolumeUp" );
  if ($_control === 14)($_befehl="Mute" );
  if ($_control === 15)($_befehl="Num1" );
  if ($_control === 16)($_befehl="Num2" );
  if ($_control === 17)($_befehl="Num3" );
  if ($_control === 18)($_befehl="Num4" );
  if ($_control === 19)($_befehl="Num5" );
  if ($_control === 20)($_befehl="Num6" );
  if ($_control === 21)($_befehl="Num7" );
  if ($_control === 22)($_befehl="Num8" );
  if ($_control === 23)($_befehl="Num9" );
  if ($_control === 24)($_befehl="Num0" );
  if ($_control === 25)($_befehl="Exit" );
  if ($_control === 26)($_befehl="" );
  sendCommand($_befehl);
  }
?>

Wer es mal testen mag,

ich habe ein Install Skript erstellt, welches alles automatisch anlegt und einige VAR’s vorbelegt.
Die Daten müssen dann per Webfront angepasst werden (IP und MAC).
Zuerst bitte am TV unter Netzwerk prüfen, ob RemoteController freigegeben ist !
Wenn nicht, freigeben…,wie auch WOL…

Danach bei eingeschaltetem TV auf Anmeldung klicken, dann sollte am TV ein 4 stelliger Code erscheinen, den unter TVCode im Webfrot eintragen und bestätigen(Enter).
Danach sollte die VAR : Cookie einen Wert haben.

Ist zwar noch nicht alles drin, aber die Grundfunktionen sind steuerbar.
Keine Ahnung, ob das unter Windows läuft, ist alles mit der „Banane“(Raspberry) erstellt.

Wie gesagt, fange erst mit PHP in IPS an, sind bestimmt viele Dinge drin, die besser gehen.

Hier jetzt das Install Skript, welches ein DUMMY Modul anlegt, und da drunter alle VAR’s und Skripte.


<?
// Variablen-Definitionen
	$VAR_Dummy ='Sony Bravia TV 2014';
	$VAR_Profile ='Sony_TV';
	$VarNames[0]         					= array('name'=>'KanalNr', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -99, 'default_value'=>'',);
   $VarNames[1]         					= array('name'=>'Kanal', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -98, 'default_value'=>'',);
   $VarNames[2]         					= array('name'=>'Sendung', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -97, 'default_value'=>'',);
	$VarNames[3]         					= array('name'=>'Sony_Tv', 'type'=>1, 'hidden'=>false, 'profil'=>$VAR_Profile, 'position'=> -100, 'default_value'=>0,);
	$VarNames[4]         					= array('name'=>'Cookie', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -90, 'default_value'=>'',);
	$VarNames[5]         					= array('name'=>'TVCode', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -91, 'default_value'=>'',);
	$VarNames[6]         					= array('name'=>'my_device', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -96, 'default_value'=>'',);
	$VarNames[7]         					= array('name'=>'my_nick', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -95, 'default_value'=>'',);
	$VarNames[8]         					= array('name'=>'my_uuid', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -94, 'default_value'=>'',);
	$VarNames[9]         					= array('name'=>'Tv-IP', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -93, 'default_value'=>'',);
	$VarNames[10]         					= array('name'=>'Tv-MAC fur WOL', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -92, 'default_value'=>'',);

// Skript-Definitionen
	$SkriptNames[0]        					= array('name'=>'Anmeldung',);
	$SkriptNames[1]        					= array('name'=>'Cookie holen',);
	$SkriptNames[2]        					= array('name'=>'Kanal anzeigen',);
	$SkriptNames[3]        					= array('name'=>'Sony FB',);
	$SkriptNames[4]        					= array('name'=>'SonyAktion',);
	$SkriptNames[5]        					= array('name'=>'Sony_Steuerung',);


function CreateScriptByName($ScriptNAME, $ParentID, $ScriptTEXT)
{
   global $IPS_SELF,$ScriptID;
    $ScriptID = @IPS_GetScriptIDByName($ScriptNAME, $ParentID);
    if ($ScriptID == 0){
       $ScriptID = IPS_CreateScript(0);
       IPS_SetName($ScriptID, $ScriptNAME);
       IPS_SetParent($ScriptID, $ParentID);
       IPS_SetInfo($ScriptID, "This script was created by: #$IPS_SELF#");
       $ScriptPath = $ScriptID.".ips.php";     //Skriptdatei
       IPS_SetScriptFile($ScriptID, $ScriptPath);
       IPS_SetHidden($ScriptID, false);
       IPS_SetScriptContent($ScriptID, $ScriptTEXT);
    }
}

// übergeordnete Instanz identifizieren
	$Parent           						= IPS_GetParent($_IPS['SELF']);
	$ParentModul								= IPS_GetObject($Parent);

// Auto-Update (überprüft, ob alle Skripte im Baum vorhanden sind
	for($i=0;$i<count($SkriptNames);$i++)
	{

	   if(@IPS_GetObjectIDByName($SkriptNames[$i]['name'], IPS_GetParent($_IPS['SELF'])) == false)
		{
			$Update_s 							= true;     // Update-Status auf true setzen
    		$i 									= 9999;     // Abbruch der Schleife bei fehlendem Objekt
		}
		else
		{
			$Update_s 							= false;     // alle Objekte vorhanden -> Update-Status auf false setzen
		}
	}

// Auto-Update (überprüft, ob alle Var's im Baum vorhanden sind
	for($i=0;$i<count($VarNames);$i++)
	{
	   if(@IPS_GetObjectIDByName($VarNames[$i]['name'], IPS_GetParent($_IPS['SELF'])) == false)
		{
			$Update_v							= true;     // Update-Status auf true setzen
    		$i 									= 9999;     // Abbruch der Schleife bei fehlendem Objekt
		}
		else
		{
			$Update_v 							= false;     // alle Objekte vorhanden -> Update-Status auf false setzen
		}
	}
	   if(($Update_s == true) or ($Update_v == true))
		{
	    $Update 								= true;     // Update-Status auf true setzen
    		$i 									= 9999;     // Abbruch der Schleife bei fehlendem Objekt
		}
		else
		{
			$Update 								= false;     // alle Objekte vorhanden -> Update-Status auf false setzen
		}


// Sony Auswertelogik
if(($ParentModul['ObjectType'] == 1) && ($ParentModul['ObjectName'] == $VAR_Dummy) && ($Update == false))
{
	// Variablen identifizieren
	   $KanalNr_ID 	= IPS_GetObjectIDByName($VarNames[0]['name'], IPS_GetParent($_IPS['SELF']));
	   $Kanal_ID      = IPS_GetObjectIDByName($VarNames[1]['name'], IPS_GetParent($_IPS['SELF']));
	   $Sendung_ID    = IPS_GetObjectIDByName($VarNames[2]['name'], IPS_GetParent($_IPS['SELF']));
	   $SonyTv_ID    	= IPS_GetObjectIDByName($VarNames[3]['name'], IPS_GetParent($_IPS['SELF']));
		$my_device_ID	= IPS_GetObjectIDByName($VarNames[6]['name'], IPS_GetParent($_IPS['SELF']));
		$my_nick_ID 	= IPS_GetObjectIDByName($VarNames[7]['name'], IPS_GetParent($_IPS['SELF']));
		$Tmy_uuid_ID 	= IPS_GetObjectIDByName($VarNames[8]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_MAC_ID 		= IPS_GetObjectIDByName($VarNames[9]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_IP_ID 		= IPS_GetObjectIDByName($VarNames[10]['name'], IPS_GetParent($_IPS['SELF']));


	// IPS Werte auslesen
//		$KanalNr	                = getValueString($KanalNr_ID);
//		$Kanal_ID	             = getValueString($Kanal_ID);
//		$Sendung_ID	             = getValueString($Sendung_ID);
}
#######################################################################################################################################
// Install-Routinen
elseif($_IPS['SENDER'] == 'Execute')
{
	// Profil Sony_TV anlegen
	if (IPS_VariableProfileExists($VAR_Profile))  IPS_DeleteVariableProfile($VAR_Profile);
	IPS_CreateVariableProfile($VAR_Profile, 1);
	IPS_SetVariableProfileValues($VAR_Profile, 0, 0, 0); //PName, Minimal, Maximal, Schrittweite
	IPS_SetVariableProfileAssociation($VAR_Profile, 0, "PowerOn", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 1, "PowerOff", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 2, "Red", "", 0xFF0000); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 3, "Green", "", 0x00FF00); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 4, "Yellow", "", 0xFFFF00); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 5, "Blue", "", 0x0000FF); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 6, "Up", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 7, "Left", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 8, "Right", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 9, "Down", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 10, "OK", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 11, "?", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 12, "Vol+", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 13, "Vol-", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 14, "Mute", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 15, "1", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 16, "2", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 17, "3", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 18, "4", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 19, "5", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 20, "6", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 21, "7", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 22, "8", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 23, "9", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 24, "0", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 25, "Exit", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 26, "?", "", 0); //P-Name, Value, Assotiation, Icon, Color

	if((($ParentModul['ObjectType'] != 1) && ($ParentModul['ObjectName'] != $VAR_Dummy)) || ($Update == true))
	{
	   if(($ParentModul['ObjectType'] != 1) && ($ParentModul['ObjectName'] != $VAR_Dummy))
	   {
		   // Dummy-Instanz anlegen und Script drunterhängen
	      $ModulID				= IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}");
	      IPS_SetName($ModulID, $VAR_Dummy);
	      IPS_SetParent($ModulID, $Parent);
	      IPS_SetParent($_IPS['SELF'], $ModulID);
	      IPS_SetHidden($_IPS['SELF'], true);
	      IPS_ApplyChanges($ModulID);
      }
///////////////////////////////////////////////////////////////////////
// Skripte anlegen

$Aktion ='<?
if($_IPS["SENDER"] == "WebFront")
{
    SetValue($_IPS["VARIABLE"], $_IPS["VALUE"]);
}
?>';




CreateScriptByName('SonyAktion',IPS_GetParent($_IPS['SELF']),$Aktion);
IPS_SetHidden($ScriptID, true);
$aktion_skript=$ScriptID;

////////////////////////////////////////////////////////////////////////////////
$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $mac_ID    				= IPS_GetObjectIDByName(\'Tv-MAC fur WOL\', IPS_GetParent($_IPS[\'SELF\']));

	// IPS Werte auslesen
		$cookie=getValueString($Cookie_ID);
		$tvip=getValueString($tv_ip_ID);
      $mac=getValueString($mac_ID);


$addr=\'255.255.255.255\';
$did = 1;
$controllerinfo = json_decode(\'{"id":10,"result":[{"bundled":true,"type":"RM-J1100"}
,[{"name":"PowerOff","value":"AAAAAQAAAAEAAAAvAw=="}
,{"name":"Input","value":"AAAAAQAAAAEAAAAlAw=="}
,{"name":"GGuide","value":"AAAAAQAAAAEAAAAOAw=="}
,{"name":"EPG","value":"AAAAAgAAAKQAAABbAw=="}
,{"name":"Favorites","value":"AAAAAgAAAHcAAAB2Aw=="}
,{"name":"Display","value":"AAAAAQAAAAEAAAA6Aw=="}
,{"name":"Home","value":"AAAAAQAAAAEAAABgAw=="}
,{"name":"Options","value":"AAAAAgAAAJcAAAA2Aw=="}
,{"name":"Return","value":"AAAAAgAAAJcAAAAjAw=="}
,{"name":"Up","value":"AAAAAQAAAAEAAAB0Aw=="}
,{"name":"Down","value":"AAAAAQAAAAEAAAB1Aw=="}
,{"name":"Right","value":"AAAAAQAAAAEAAAAzAw=="}
,{"name":"Left","value":"AAAAAQAAAAEAAAA0Aw=="}
,{"name":"Confirm","value":"AAAAAQAAAAEAAABlAw=="}
,{"name":"Red","value":"AAAAAgAAAJcAAAAlAw=="}
,{"name":"Green","value":"AAAAAgAAAJcAAAAmAw=="}
,{"name":"Yellow","value":"AAAAAgAAAJcAAAAnAw=="}
,{"name":"Blue","value":"AAAAAgAAAJcAAAAkAw=="}
,{"name":"Num1","value":"AAAAAQAAAAEAAAAAAw=="}
,{"name":"Num2","value":"AAAAAQAAAAEAAAABAw=="}
,{"name":"Num3","value":"AAAAAQAAAAEAAAACAw=="}
,{"name":"Num4","value":"AAAAAQAAAAEAAAADAw=="}
,{"name":"Num5","value":"AAAAAQAAAAEAAAAEAw=="}
,{"name":"Num6","value":"AAAAAQAAAAEAAAAFAw=="}
,{"name":"Num7","value":"AAAAAQAAAAEAAAAGAw=="}
,{"name":"Num8","value":"AAAAAQAAAAEAAAAHAw=="}
,{"name":"Num9","value":"AAAAAQAAAAEAAAAIAw=="}
,{"name":"Num0","value":"AAAAAQAAAAEAAAAJAw=="}
,{"name":"Num11","value":"AAAAAQAAAAEAAAAKAw=="}
,{"name":"Num12","value":"AAAAAQAAAAEAAAALAw=="}
,{"name":"VolumeUp","value":"AAAAAQAAAAEAAAASAw=="}
,{"name":"VolumeDown","value":"AAAAAQAAAAEAAAATAw=="}
,{"name":"Mute","value":"AAAAAQAAAAEAAAAUAw=="}
,{"name":"ChannelUp","value":"AAAAAQAAAAEAAAAQAw=="}
,{"name":"ChannelDown","value":"AAAAAQAAAAEAAAARAw=="}
,{"name":"SubTitle","value":"AAAAAgAAAJcAAAAoAw=="}
,{"name":"ClosedCaption","value":"AAAAAgAAAKQAAAAQAw=="}
,{"name":"Enter","value":"AAAAAQAAAAEAAAALAw=="}
,{"name":"DOT","value":"AAAAAgAAAJcAAAAdAw=="}
,{"name":"Analog","value":"AAAAAgAAAHcAAAANAw=="}
,{"name":"Teletext","value":"AAAAAQAAAAEAAAA/Aw=="}
,{"name":"Exit","value":"AAAAAQAAAAEAAABjAw=="}
,{"name":"Analog2","value":"AAAAAQAAAAEAAAA4Aw=="}
,{"name":"*AD","value":"AAAAAgAAABoAAAA7Aw=="}
,{"name":"Digital","value":"AAAAAgAAAJcAAAAyAw=="}
,{"name":"Analog?","value":"AAAAAgAAAJcAAAAuAw=="}
,{"name":"BS","value":"AAAAAgAAAJcAAAAsAw=="}
,{"name":"CS","value":"AAAAAgAAAJcAAAArAw=="}
,{"name":"BSCS","value":"AAAAAgAAAJcAAAAQAw=="}
,{"name":"Ddata","value":"AAAAAgAAAJcAAAAVAw=="}
,{"name":"PicOff","value":"AAAAAQAAAAEAAAA+Aw=="}
,{"name":"Tv_Radio","value":"AAAAAgAAABoAAABXAw=="}
,{"name":"Theater","value":"AAAAAgAAAHcAAABgAw=="}
,{"name":"SEN","value":"AAAAAgAAABoAAAB9Aw=="}
,{"name":"InternetWidgets","value":"AAAAAgAAABoAAAB6Aw=="}
,{"name":"InternetVideo","value":"AAAAAgAAABoAAAB5Aw=="}
,{"name":"Netflix","value":"AAAAAgAAABoAAAB8Aw=="}
,{"name":"SceneSelect","value":"AAAAAgAAABoAAAB4Aw=="}
,{"name":"Mode3D","value":"AAAAAgAAAHcAAABNAw=="}
,{"name":"iManual","value":"AAAAAgAAABoAAAB7Aw=="}
,{"name":"Audio","value":"AAAAAQAAAAEAAAAXAw=="}
,{"name":"Wide","value":"AAAAAgAAAKQAAAA9Aw=="}
,{"name":"Jump","value":"AAAAAQAAAAEAAAA7Aw=="}
,{"name":"PAP","value":"AAAAAgAAAKQAAAB3Aw=="}
,{"name":"MyEPG","value":"AAAAAgAAAHcAAABrAw=="}
,{"name":"ProgramDescription","value":"AAAAAgAAAJcAAAAWAw=="}
,{"name":"WriteChapter","value":"AAAAAgAAAHcAAABsAw=="}
,{"name":"TrackID","value":"AAAAAgAAABoAAAB+Aw=="}
,{"name":"TenKey","value":"AAAAAgAAAJcAAAAMAw=="}
,{"name":"AppliCast","value":"AAAAAgAAABoAAABvAw=="}
,{"name":"acTVila","value":"AAAAAgAAABoAAAByAw=="}
,{"name":"DeleteVideo","value":"AAAAAgAAAHcAAAAfAw=="}
,{"name":"PhotoFrame","value":"AAAAAgAAABoAAABVAw=="}
,{"name":"TvPause","value":"AAAAAgAAABoAAABnAw=="}
,{"name":"KeyPad","value":"AAAAAgAAABoAAAB1Aw=="}
,{"name":"Media","value":"AAAAAgAAAJcAAAA4Aw=="}
,{"name":"SyncMenu","value":"AAAAAgAAABoAAABYAw=="}
,{"name":"Forward","value":"AAAAAgAAAJcAAAAcAw=="}
,{"name":"Play","value":"AAAAAgAAAJcAAAAaAw=="}
,{"name":"Rewind","value":"AAAAAgAAAJcAAAAbAw=="}
,{"name":"Prev","value":"AAAAAgAAAJcAAAA8Aw=="}
,{"name":"Stop","value":"AAAAAgAAAJcAAAAYAw=="}
,{"name":"Next","value":"AAAAAgAAAJcAAAA9Aw=="}
,{"name":"Rec","value":"AAAAAgAAAJcAAAAgAw=="}
,{"name":"Pause","value":"AAAAAgAAAJcAAAAZAw=="}
,{"name":"Eject","value":"AAAAAgAAAJcAAABIAw=="}
,{"name":"FlashPlus","value":"AAAAAgAAAJcAAAB4Aw=="}
,{"name":"FlashMinus","value":"AAAAAgAAAJcAAAB5Aw=="}
,{"name":"TopMenu","value":"AAAAAgAAABoAAABgAw=="}
,{"name":"PopUpMenu","value":"AAAAAgAAABoAAABhAw=="}
,{"name":"RakurakuStart","value":"AAAAAgAAAHcAAABqAw=="}
,{"name":"OneTouchTimeRec","value":"AAAAAgAAABoAAABkAw=="}
,{"name":"OneTouchView","value":"AAAAAgAAABoAAABlAw=="}
,{"name":"OneTouchRec","value":"AAAAAgAAABoAAABiAw=="}
,{"name":"OneTouchStop","value":"AAAAAgAAABoAAABjAw=="}
,{"name":"DUX","value":"AAAAAgAAABoAAABzAw=="}
,{"name":"FootballMode","value":"AAAAAgAAABoAAAB2Aw=="}
,{"name":"Social","value":"AAAAAgAAABoAAAB0Aw=="}
]    ]}\',true);
$codes = array();
foreach($controllerinfo[\'result\'] as $k => $v) {
foreach($v as $code) {
if (isset($code[\'name\'])) {
$codes[$code[\'name\']] = $code[\'value\'];
}
}
}

function sendCommand($key) {
global $codes;
$data = \'<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>\';
$data .= \'<u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">
<IRCCCode>\'.$codes[$key].\'</IRCCCode>
</u:X_SendIRCC>\';
$data .= \'</s:Body>
</s:Envelope>\';
sendCurlPost(\'/sony/IRCC\',$data);
}

function sendCurlPost($url,$data, $auth = false) {
global $cookie, $tvip;
$headers = array();
// $cookie = "auth=e708c3f8033c42f46681c01aa5155eb451f00c88bb7969a2380a9c31eaabb48f";
$headers[] = "Cookie: " . $cookie;
$headers[] = "Content-Type: text/xml; charset=UTF-8";
$headers[] = "Content-Length: " . strlen($data);
$ch = curl_init(\'http://\'. $tvip . $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
return curl_exec($ch);
}

function WakeOnLan($mac, $addr) {
	$addr_byte = explode(\':\', $mac);
	$hw_addr = \'\';

	for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));

	$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);

	for ($a = 1; $a <= 16; $a++)    $msg .= $hw_addr;

	$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
	if ($s == false) {
		echo "Error creating socket!
";
		echo "Error code is \'".socket_last_error($s)."\' - " . socket_strerror(socket_last_error($s));
		return false;
	} else {
		$opt_ret =  socket_set_option($s, 1, 6, TRUE);
		if($opt_ret < 0) {
			echo "setsockopt() failed, error: " . strerror($opt_ret) . "
";
			return false;
		}
		$e = socket_sendto($s, $msg, strlen($msg), 0, $addr, 2050);
		socket_close($s);
		return true;
	}
}

?>';
CreateScriptByName('Sony_Steuerung',IPS_GetParent($_IPS['SELF']),$Sony_text);
IPS_SetHidden($ScriptID, true);

$aktion_steuerung=$ScriptID;
////////////////////////////////////////////////////////////////////////////////
$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
$tv_ip_ID    				= IPS_GetObjectIDByName(\'Sony_Steuerung\', IPS_GetParent($_IPS[\'SELF\']));
include IPS_GetKernelDir().\'scripts/\'.$tv_ip_ID.\'.ips.php\';

$addr = "255.255.255.255"; // Broadcast adresse für WOL

$_befehl = "";
if($_IPS["SENDER"] == "WebFront")
{
    SetValue($_IPS["VARIABLE"], $_IPS["VALUE"]);
//	 print($_IPS["Value"]);
}
$_control = ($_IPS["VALUE"]);

  if ($_control === 0){
   WakeOnLan($mac, $addr);
  } else
  {
  if ($_control === 1) ($_befehl="PowerOff");
  if ($_control === 2) ($_befehl="Red" );
  if ($_control === 3) ($_befehl="Green" );
  if ($_control === 4) ($_befehl="Yellow" );
  if ($_control === 5) ($_befehl="Blue" );
  if ($_control === 6) ($_befehl="Up" );
  if ($_control === 7) ($_befehl="Left" );
  if ($_control === 8) ($_befehl="Right" );
  if ($_control === 9) ($_befehl="Down" );
  if ($_control === 10)($_befehl="Confirm" );
  if ($_control === 11)($_befehl="" );
  if ($_control === 12)($_befehl="VolumeDown" );
  if ($_control === 13)($_befehl="VolumeUp" );
  if ($_control === 14)($_befehl="Mute" );
  if ($_control === 15)($_befehl="Num1" );
  if ($_control === 16)($_befehl="Num2" );
  if ($_control === 17)($_befehl="Num3" );
  if ($_control === 18)($_befehl="Num4" );
  if ($_control === 19)($_befehl="Num5" );
  if ($_control === 20)($_befehl="Num6" );
  if ($_control === 21)($_befehl="Num7" );
  if ($_control === 22)($_befehl="Num8" );
  if ($_control === 23)($_befehl="Num9" );
  if ($_control === 24)($_befehl="Num0" );
  if ($_control === 25)($_befehl="Exit" );
  if ($_control === 26)($_befehl="" );
  sendCommand($_befehl);
  }
?>';
CreateScriptByName('Sony FB',IPS_GetParent($_IPS['SELF']),$Sony_text);
IPS_SetHidden($ScriptID, true);
$aktion_FB=$ScriptID;


$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_device_ID    				= IPS_GetObjectIDByName(\'my_device\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_nick_ID    				= IPS_GetObjectIDByName(\'my_nick\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_uuid_ID    				= IPS_GetObjectIDByName(\'my_uuid\', IPS_GetParent($_IPS[\'SELF\']));
	   $TVCode_ID    				= IPS_GetObjectIDByName(\'TVCode\', IPS_GetParent($_IPS[\'SELF\']));
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	// IPS Werte auslesen


	// IPS Werte auslesen
		$tv_ip=getValueString($tv_ip_ID);
		$my_device=GetValueString ($my_device_ID);
		$my_nick=GetValueString ($my_nick_ID );
		$my_uuid=GetValueString ($my_uuid_ID );
		$TVCode=GetValueString ($TVCode_ID );
		$cookie= getValueString($Cookie_ID);

# use only A-Z a-z 0-9 for device. Probably. Havent checked.
// Start anlernen
$url =\'/sony/accessControl\';
$data=\'{"method":"actRegister","params":[{"clientid":"\'.$my_nick.\':\'.$my_uuid.\'","nickname":"\'.$my_nick.\' (\'.$my_device.\')","level":"private"},[{"value":"yes","function":"WOL"}]],"id":8,"version":"1.0"}\';
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
curl_close($ch);
//echo $ausgabe.chr(10);
// Hier auf Eingabe vom Code warten (WebFront)
$tv_key =\'Neu\';
SetValueString ($TVCode_ID , $tv_key);
$i = 0;
while( $tv_key === \'Neu\')
{
	$tv_key=GetValueString ($TVCode_ID);
//	echo $tv_key;
	IPS_sleep(1000);
   $i++;
   if( $i == 40 )break;
}

// Key senden
	$tv_key=GetValueString ($TVCode_ID);
//echo $tv_key;
$tv_key=\':\'.$tv_key;
$tv_challenge = base64_encode($tv_key);
$tv_auth_header=\'Authorization: Basic \'.$tv_challenge;
//echo $tv_auth_header.chr(10);
$headers = array();
$headers[]=$tv_auth_header;
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
list($headers, $response) = explode("

", $ausgabe, 2);
$headers = explode("
", $headers);
foreach($headers as $header) {
    if (stripos($header, \'Set-Cookie:\') !== false) {
//        echo $header.chr(10);
        $header = substr($header,0,strpos($header,";"));
        $auth = strstr($header, "a");
//		  echo $auth;
        SetValueString ($Cookie_ID , $auth );
    }
}
?>';
CreateScriptByName('Anmeldung',IPS_GetParent($_IPS['SELF']),$Sony_text);
//$aktion_FB=$ScriptID;

$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $mac_ID    				= IPS_GetObjectIDByName(\'Tv-MAC fur WOL\', IPS_GetParent($_IPS[\'SELF\']));

	   $KanalNr_ID    				= IPS_GetObjectIDByName(\'KanalNr\', IPS_GetParent($_IPS[\'SELF\']));
	   $Kanal_ID    				= IPS_GetObjectIDByName(\'Kanal\', IPS_GetParent($_IPS[\'SELF\']));
	   $Sendung_ID    				= IPS_GetObjectIDByName(\'Sendung\', IPS_GetParent($_IPS[\'SELF\']));

	// IPS Werte auslesen
		$cookie=getValueString($Cookie_ID);
		$tv_ip=getValueString($tv_ip_ID);
      $mac=getValueString($mac_ID);

$url =\'/sony/avContent\';
$data = \'{"method":"getPlayingContentInfo","params":[""],"id":1,"version":"1.0"}\';
$headers = array();
$headers[] = "Cookie: " . $cookie;
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false); //Header abgeschaltet
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
$error = 0;
$json_a = json_decode($ausgabe,true);

if (isset($json_a["error"])) {
    SetValueString($Kanal_ID ,$json_a["error"][1]);
	 SetValueString($Sendung_ID   ,\' \');
    SetValueString($KanalNr_ID  ,\' \');
}
else
{
//echo $json_a["result"][0]["programTitle"];
//echo $json_a["result"][0]["title"];
SetValueString($Kanal_ID , utf8_decode($json_a["result"][0]["title"]));
SetValueString($Sendung_ID  ,utf8_decode($json_a["result"][0]["programTitle"]));
SetValueString($KanalNr_ID   ,utf8_decode($json_a["result"][0]["dispNum"]));
}
?>';
CreateScriptByName('Kanal anzeigen',IPS_GetParent($_IPS['SELF']),$Sony_text);
//$aktion_FB=$ScriptID;

$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_device_ID    				= IPS_GetObjectIDByName(\'my_device\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_nick_ID    				= IPS_GetObjectIDByName(\'my_nick\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_uuid_ID    				= IPS_GetObjectIDByName(\'my_uuid\', IPS_GetParent($_IPS[\'SELF\']));
	   $TVCode_ID    				= IPS_GetObjectIDByName(\'TVCode\', IPS_GetParent($_IPS[\'SELF\']));
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	// IPS Werte auslesen


	// IPS Werte auslesen
		$tv_ip=getValueString($tv_ip_ID);
		$my_device=GetValueString ($my_device_ID);
		$my_nick=GetValueString ($my_nick_ID );
		$my_uuid=GetValueString ($my_uuid_ID );
		$TVCode=GetValueString ($TVCode_ID );
		$cookie= getValueString($Cookie_ID);

// Start anlernen
$url =\'/sony/accessControl\';
//[["actRegister",["{\"clientid\":\"string\",\"nickname\":\"string\",\"level\":\"string\"}","{\"function\":\"string\",\"value\":\"string\"}*"],[],"1.0"],["getMethodTypes",["string"],["string","string*","string*","string"],"1.0"],["getVersions",[],["string*"],"1.0"]]}

$data=\'{"method":"actRegister","params":[{"clientid":"\'.$my_nick.\':\'.$my_uuid.\'","nickname":"\'.$my_nick.\' (\'.$my_device.\')","level":"private"},[{"value":"yes","function":"WOL"}]],"id":8,"version":"1.0"}\';
$headers = array();
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
$json_a = json_decode($ausgabe,true);
//var_dump ($json_a);
if (isset($json_a["error"])) {

}
else
{

list($headers, $response) = explode("

", $ausgabe, 2);
$headers = explode("
", $headers);
foreach($headers as $header) {
    if (stripos($header, \'Set-Cookie:\') !== false) {
//        echo $header.chr(10);
        $header = substr($header,0,strpos($header,";"));
        $auth = strstr($header, "a");
//		  echo $auth;
        SetValueString ($Cookie_ID , $auth );
    }
}

}
?>';
CreateScriptByName('Cookie holen',IPS_GetParent($_IPS['SELF']),$Sony_text);
///////////////////////////////////////////////////////////////////////////////

		// Variablen anlegen - wenn nicht vorhanden
      // 1. vorhandene Vars auslesen
      $ModulID					= IPS_GetParent($_IPS['SELF']);

		for($i=0;$i<count($VarNames);$i++)
		{
		   if(@IPS_GetObjectIDByName($VarNames[$i]['name'], IPS_GetParent($_IPS['SELF'])) == false)
		   {
		   $VarID = IPS_CreateVariable($VarNames[$i]['type']);
		   IPS_SetName($VarID, $VarNames[$i]['name']);
		   IPS_SetHidden($VarID, $VarNames[$i]['hidden']);
		   IPS_SetPosition($VarID, $VarNames[$i]['position']);
		   IPS_SetParent($VarID, $ModulID);
		   SetValue($VarID, $VarNames[$i]['default_value']);
			}
   // Profile zuweisen
			$VarID = IPS_GetObjectIDByName($VarNames[$i]['name'], IPS_GetParent($_IPS['SELF']));
			IPS_SetVariableCustomProfile($VarID, $VarNames[$i]['profil']);
   // Aktion zuweisen
		   IPS_SetVariableCustomAction($VarID,$aktion_skript);

		}
	     $SonyTv_ID    	    			= IPS_GetObjectIDByName($VarNames[3]['name'], IPS_GetParent($_IPS['SELF']));
		  IPS_SetVariableCustomAction($SonyTv_ID,$aktion_FB);

		$my_device_ID = IPS_GetObjectIDByName($VarNames[6]['name'], IPS_GetParent($_IPS['SELF']));
		$my_nick_ID = IPS_GetObjectIDByName($VarNames[7]['name'], IPS_GetParent($_IPS['SELF']));
		$my_uuid_ID = IPS_GetObjectIDByName($VarNames[8]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_MAC_ID = IPS_GetObjectIDByName($VarNames[9]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_IP_ID = IPS_GetObjectIDByName($VarNames[10]['name'], IPS_GetParent($_IPS['SELF']));
      SetValueString ($my_device_ID , 'BananaPi2' );
      SetValueString ($my_nick_ID , 'IPS' );
      SetValueString ($my_uuid_ID , '17' );
      SetValueString ($TV_MAC_ID , '192.168.1.61' );
      SetValueString ($TV_IP_ID , 'FC:F1:52:72:7E:A3' );


	}
	 echo "#9999 IPS Sony: Install ready (neue Objekte angelegt)
";

}
else
{
	echo "Script #".$_IPS['SELF']." Sony: ohne Ergebnis gelaufen (keine Objekte gefunden/Objekte fehlerhaft
";
}


?>

Ich habe da vieles von dem „DWD Unwetterwarnung Skript“ benutzt, ab „guggen“.:confused:

Hi tomgr,

habe total vergessen mich für deine tolle Arbeit zu bedanken! Funktioniert bei mir unter Windows perfekt!

Einzig das TV einschalten musste ich bei mir anpassen auf ein anderes WOL, denn bei deiner Version ging das nur, wenn der TV kurz davor eingeschaltet war. Sobald der TV über Nacht ausgeschaltet war, dann ging nichts mehr. TV aber dann direkt aus, dann ging dein WOL.

Lange Rede, kurzer Sinn, hier das immer funktionierende WOL-Skript mit zugehöriger Funktion (die Funktion stammt nicht von mir, Infos dazu im Quelltext. Habe aber glaub ich was geändert :D)

Dazu habe ich noch ein paar eigene Variablen angelegt und die passenden Befehle zu meinem TV eingebaut. Sollte also jemand den gleichen TV haben, kann ich den Kram raussuchen und zur Verfügung stellen. Aber die „Codes“ finden sich auf einigen Webseiten und sind schnell einpflegt.

Mein Skript, welches die Funktion aufruft und den WOL ausführt:

<?
include 'WakeOnLan.ips.php';

$mac_address = GetValueString(42828 /*[Hardware\TV\Sony Bravia KD-65X8505B\Sony Bravia TV 2014\TV-MAC-Adresse]*/);
$addr = "192.168.50.50";  // IP-Adresse des Computer/Servers, von dem das WakeOnLan ausgeführt wird
$cidr = "24";
$port = "9";

WakeOnLan($mac_address, $addr, $cidr, $port);
?>

Dieses Skript habe ich umbenannt in WakeOnLan.ips.php :

<?php
 //
 // I have used the original PHP code from here:
 //
 // Version: 2
 // Author of this application:
 //	DS508_customer (http://www.synology.com/enu/forum/memberlist.php?mode=viewprofile&u=12636)
 //	Please inform the author of any suggestions on (the functionality, graphical design, ... of) this application.
 //	More info: http://wolviaphp.sourceforge.net
 // License: GPLv2.0
 //
 // many thanks for this starting point ;-)
 //
 // $mac_address = "00:00:00:00:00:00";  // SERVER
 // $addr = "192.168.0.10";              // Adresse aus dem eigenen Segment, Router oder aktueller Rechner sind OK.
 // $cidr = "24";                        // MASK: 255.255.255.0 ==> 24 (3 Byte * 8 Bit)
 // $port = "9";                         // Bei mir ging auch 1 und 7, weitere ?
 //
 
 function WakeOnLan($mac_address, $addr, $cidr, $port)
 {
    // Prepare magic packet: part 1/3 (defined constant)
 	$buf="";
 	for($a=0; $a<6; $a++) $buf .= chr(255); // the defined constant as represented in hexadecimal: FF FF FF FF FF FF (i.e., 6 bytes of hexadecimal FF)
 	//Check whether $mac_address is valid
 	$mac_address=strtoupper($mac_address);
 	$mac_address=str_replace(":", "-", $mac_address);
 	if ((!preg_match("/([A-F0-9]{2}[-]){5}([0-9A-F]){2}/",$mac_address)) || (strlen($mac_address) != 17))
 	{
 		$error = "Input error: Pattern of MAC-address is not \"xx-xx-xx-xx-xx-xx\" (x = digit or letter).<br>
";
 		return $error; // false
 	}
 	else
 	{
 		// Prepare magic packet: part 2/3 (16 times MAC-address)
 		$addr_byte = explode('-', $mac_address); // Split MAC-address into an array of (six) bytes
 		$hw_addr="";
 		for ($a=0; $a<6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a])); // Convert MAC-address from bytes to hexadecimal to decimal
 		$hw_addr_string="";
 		for ($a=0; $a<16; $a++) $hw_addr_string .= $hw_addr;
 		$buf .= $hw_addr_string;
 	}
 	// Resolve broadcast address
 	if (filter_var ($addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) // same as (but easier than):  preg_match("/\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b/",$addr)
 	{
 		// $addr has an IP-adres format
 	}
 	else
 	{
 		// Whitespaces confuse name lookups
 		$addr=trim($addr);
 		// If you pass to gethostbyname() an:
 		//	unresolvable domainname, gethostbyname() returns the domainname (rather than 'false')
 		//	IP address, gethostbyname() returns that IP address.
 		if (gethostbyname($addr) == $addr)
 		{
 			// $addr is NOT a resolvable domainname
 			$error = "Input error: host name of broadcast address is unresolvable.<br>
";
 			return $error; // false
 		}
 		else
 		{
 			// $addr IS a resolvable domainname
 			$addr = gethostbyname($addr);
 		}
 	}
 	// Store input value for cookie
 	$resolved_addr = $addr;
 	// If $cidr is set, replace $addr for its broadcast address
 	if ($cidr != "")
 	{
 		// Check whether $cidr is valid
 		if ((!ctype_digit($cidr)) || ($cidr < 0) || ($cidr > 32))
 		{
 			$error = "Input error: CIDR subnet mask is not a number within the range of 0 till 32.<br>
";
 			return $error; // false
 		}
 		// Convert $cidr from one decimal to one inverted binary array
 		$inverted_binary_cidr="";
 		for ($a=0; $a<$cidr; $a++) $inverted_binary_cidr .= "0"; // Build $inverted_binary_cidr by $cidr * zeros (this is the mask)
 		$inverted_binary_cidr = $inverted_binary_cidr.substr("11111111111111111111111111111111",0,32-strlen($inverted_binary_cidr)); // Invert the mask (by postfixing ones to $inverted_binary_cidr untill 32 bits are filled/ complete)
 		$inverted_binary_cidr_array = str_split($inverted_binary_cidr); // Convert $inverted_binary_cidr to an array of bits
 		// Convert IP address from four decimals to one binary array
 		$addr_byte = explode('.', $addr); // Split IP address into an array of (four) decimals
 		$binary_addr="";
 		for ($a=0; $a<4; $a++) {
 			$pre = substr("00000000",0,8-strlen(decbin($addr_byte[$a]))); // Prefix zeros
 			$post = decbin($addr_byte[$a]); // Postfix binary decimal
 			$binary_addr .= $pre.$post;
 		}
 		$binary_addr_array = str_split($binary_addr); // Convert $binary_addr to an array of bits
 		// Perform a bitwise OR operation on arrays ($binary_addr_array & $inverted_binary_cidr_array)
 		$binary_broadcast_addr_array="";
 		for ($a=0; $a<32; $a++) $binary_broadcast_addr_array[$a] = ($binary_addr_array[$a] | $inverted_binary_cidr_array[$a]); // binary array of 32 bit variables ('|' = logical operator 'or')
 		$binary_broadcast_addr = chunk_split(implode("", $binary_broadcast_addr_array),8,"."); // build binary address of four bundles of 8 bits (= 1 byte)
 		$binary_broadcast_addr = substr($binary_broadcast_addr,0,strlen($binary_broadcast_addr)-1); // chop off last dot ('.')
 		$binary_broadcast_addr_array = explode(".", $binary_broadcast_addr); // binary array of 4 byte variables
 		$broadcast_addr_array="";
 		for ($a=0; $a<4; $a++) $broadcast_addr_array[$a] = bindec($binary_broadcast_addr_array[$a]); // decimal array of 4 byte variables
 		$addr = implode(".", $broadcast_addr_array); // broadcast address
 	}
 	// Check whether $port is valid
 	if ((!ctype_digit($port)) || ($port < 0) || ($port > 65536))
 	{
 		$error = "Input error: Port is not a number within the range of 0 till 65536.<br>
";
 		return $error; // false
 	}
 	// Check whether UDP is supported
 	if (!array_search('udp', stream_get_transports()))
 	{
 		$error = "No magic packet can been sent, since UDP is unsupported (not a registered socket transport).<br>
";
 		return $error; // false
 	}
 	if (function_exists('fsockopen'))
 	{
 		// Try fsockopen function - To do: handle error 'Permission denied'
 		$socket=fsockopen("udp://" . $addr, $port, $errno, $errstr);
 		if($socket)
 		{
 			$socket_data = fwrite($socket, $buf);
 			if($socket_data)
 			{
 				$function = "fwrite";
 //				$sent_fsockopen = "A magic packet of ".$socket_data." bytes has been sent via UDP to IP address: ".$addr.":".$port.", using the '".$function."()' function.<br>";
 				$sent_fsockopen = "OK (fsockopen)" ;
 //				$content = bin2hex($buf);
 //				$sent_fsockopen = $sent_fsockopen."Contents of magic packet:<br><textarea rows=\"1\" name=\"content\" cols=\"".strlen($content)."\">".$content."</textarea><br>
";
 				fclose($socket);
 				unset($socket);
 				return $sent_fsockopen; // true
 			}
 			else
 			{
 				echo "Using 'fwrite()' failed, due to error: '".$errstr."' (".$errno.")<br>
";
 				fclose($socket);
 				unset($socket);
 			}
 		}
 		else
 		{
 			echo "Using 'fsockopen()' failed, due to denied permission.<br>
";
 			unset($socket);
 		}
 	}
 	// Try socket_create function
 	if (function_exists('socket_create'))
 	{
 		$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); // create socket based on IPv4, datagram and UDP
 		if($socket)
 		{
 			$level = SOL_SOCKET; // to enable manipulation of options at the socket level (you may have to change this to 1)
 			$optname = SO_BROADCAST; // to enable permission to transmit broadcast datagrams on the socket (you may have to change this to 6)
 			$optval = true;
 			$opt_returnvalue = socket_set_option($socket, $level, $optname, $optval);
 			if($opt_returnvalue < 0)
 			{
 				$error = "Using 'socket_set_option()' failed, due to error: '".socket_strerror($opt_returnvalue)."'<br>
";
 				return $error; // false
 			}
 			$flags = 0;
 			// To do: handle error 'Operation not permitted'
 			$socket_data = socket_sendto($socket, $buf, strlen($buf), $flags, $addr, $port);
 			if($socket_data)
 			{
 				$function = "socket_sendto";
 //				$socket_create = "A magic packet of ".$socket_data." bytes has been sent via UDP to IP address: ".$addr.":".$port.", using the '".$function."()' function.<br>";
 //				$content = bin2hex($buf);
 //				$socket_create = $socket_create."Contents of magic packet:<br><textarea rows=\"1\" name=\"content\" cols=\"".strlen($content)."\">".$content."</textarea><br>
";
 				$socket_create = "OK (create)";
 				socket_close($socket);
 				unset($socket);
 				return $socket_create; // true
 			}
 			else
 			{
 				$error = "Using 'socket_sendto()' failed, due to error: '".socket_strerror(socket_last_error($socket))."' (".socket_last_error($socket).")<br>
";
 				socket_close($socket);
 				unset($socket);
 				return $error; // false
 			}
 		}
 		else
 		{
 			$error = "Using 'socket_create()' failed, due to error: '".socket_strerror(socket_last_error($socket))."' (".socket_last_error($socket).")<br>
";
 			return $error; // false
 		}
 	}
 	else
 	{
 		$error = "No magic packet has been sent, since no functions are available to transmit it.<br>
";
 		return $error; // false
 	}
 }
 //
 //$Return_WakeOnLan = WakeOnLan($mac_address, $addr, $cidr, $port); // executes this function
 //
?>

Diese WakeOnLan-Funktion kann noch für andere Sachen verwendet werden, deshalb eben als Funktion und nicht direkt eingebaut :slight_smile:

Grüße,
Chris

Und hier noch mein Skript, mit welchem ich prüfen kann, ob der TV eingeschaltet oder ausgeschaltet ist :slight_smile: Um z.B. die korrekte Funktion vom WOL zu prüfen oder vom Aus-Befehl.

Funktioniert bestimmt auch bei anderen Modellen als bei meinem. Dazu einfach einen Port-Scan mit NMAP machen, schauen ob irgendwo eine schöne Rückmeldung kommt zum Prüfen und taaadaaa :slight_smile:

Diese Skript wird automatisch mit einem ScriptTimer aufgerufen (alle 11 Sekunden bei ausgeschaltetem TV und alle 5 Sekunden bei eingeschaltetem TV - kann man natürlich auf seine Wünsche/Geräte anpassen). Timeout hab ich auf 3 Sekunden gestellt, reicht völlig aus bei mir. Skript-Laufzeit sind normal 32ms und stören den TV nicht (zumindest bemerkt man nichts).

<?
$host = GetValue(37012 /*[Hardware\TV\Sony Bravia KD-65X8505B\Sony Bravia TV 2014\TV-IP]*/);
$port = 52323;
$TVstatus = 25817 /*[Hardware\TV\Sony Bravia KD-65X8505B\Sony Bravia TV 2014\TV-Status]*/;
$TVanzeige = 51342 /*[Skripte & Variablen\Szenen\Szenen-Steuerung\Geräte-Status\TV]*/;
$TVCheckVar = 0;

$fp = @fsockopen($host, $port, $errno, $errstr, 3);


if (!$fp) {
    //echo "SonyTV WZ - $errstr ($errno)<br />
";
    SetValue($TVstatus, false);
    SetValue($TVanzeige, false);
    IPS_SetScriptTimer($_IPS['SELF'], 11);
} else {
    $out = "GET / HTTP/1.1
";
    $out .= "Host: www.example.com
";
    $out .= "Connection: Close

";
    fwrite($fp, $out);
    while (!feof($fp)) {
        fgets($fp, 128);  // echo fgets($fp, 128);
        $tvChecktmp = fgets($fp, 128);
        preg_match('|BRAVIA KD-65X8505B|', $tvChecktmp, $match);
        if ($match) {
            $TVCheckVar = 1;
	     }
    }
    fclose($fp);
    
    if ($TVCheckVar == 1) {
       SetValue($TVstatus, true);
       SetValue($TVanzeige, true);
       IPS_SetScriptTimer($_IPS['SELF'], 5);
	 }
}
?>

Für andere Modelle/Geräte müsste natürlich diese Zeile angepasst werden:

preg_match('|BRAVIA KD-65X8505B|', $tvChecktmp, $match);

Schon super, was man mit NMAP alles so von seinen Geräten heraus finden und dann damit anstellen kann :slight_smile:

Grüße,
Chris

Hallo Chris,

Danke für deine Rückmeldung.
WOL geht bei meinem TV auch wenn er AUS ist, und nicht im Standby.

Ich habe inzwischen noch einige eingebaut, aber noch nicht im install Skript.
Cookie holen, nach dem einschalten, da die verfallen.

Das mit den verfallenden Cookies habe ich bemerkt. Nach ein paar Tagen/Wochen ist jeweils eine Neuanmeldung fällig. Danach läuft wieder alles.
> Das hast du schon gelöst? Das könnte ich seeehr gut brauchen :smiley:

Grüße,
Chris

Hab das Script schon länger laufen und bin sehr zufrieden.
Danke dafür!..

Hat schon jemand versucht die Lautstärke als absoluten Wert zu übergeben?
Wäre super für die Hausautomation. Keine Ahnung wie man das umsetzen kann
und ob es überhaupt funktioniert. Wenn man den TV über UPNP oder DLNA steuert
kann man die Lautstärke über den Slider steuern.

Vielleicht hat ja jemand ne Idee hierfür?!

Grüße Jo

Das skript „Cookie holen“ stosse ich bei Variablenänderung von VAR „Status“ an(Ereignis unter Cookie holen).
Status ist on,off, standby,(2,0,1 INT).

Bin leider noch nicht soweit, alles in „install.php“ zu packen…:confused:

@tomgr: Also wenn ich dich richtig verstanden habe, dann muss ich nur dann, wenn der TV eingeschaltet ist, einmal pro Tag, das Skript „Cookie holen“ ausführen und damit ist mein Problem mit der regelmäßigen Neu-Anmeldung erledigt? :slight_smile: :cool:

Danke für den Tipp! Hatte mir schon etwas gebaut, dass ich nur auf „neu anmelden“ drücken muss, Code eingeben, fertig. Aber deine Variante ist deutlich besser :slight_smile:

Einmal „Cookie holen“ ausgeführt und der Cookie-String ändert sich, sieht sehr gut aus :slight_smile: Danke!!! Jetzt nur noch in meinen TV-Watchdog einbauen und Ruhe is :slight_smile:

>> Nochmal ans Info für alle >> Mit meinem Skript auf Post #6 (Sony Bravia TV 2014 per Lan steuern) schreibe ich den Status vom TV (an/aus) in eine Variable. Und jetzt hab ich einfach im Skript „Cookie holen“ einen Trigger gesetzt auf „Variable TVstatus ist TRUE“ und damit wird immer wenn der TV eingeschaltet wird, das „Cookie holen“ Skript ausgeführt und fertig. So als workaround bis tomgr sein Update veröffentlicht und ihr auch das Problem mit dem ewigen neu anmelden habt.

@Jo: Ich schalte meinen TV nur AUS/EIN, alles weitere passiert über meinen Denon AVR (da hab ich eine Rückmeldung über die Lautstärke und kann einen Slider verwenden), oder über Dreambox.

Grüße,
Chris

Na,

da habe ich was angerichtet, als NOP:D
Ich habe das damals mal versucht als install zu verpacken, bin aber erfreut, wenn Ihr es erweitert.
Die letzte Version (ist nicht alles drin ! :


<?
// Variablen-Definitionen
	$VAR_Dummy ='Sony Bravia TV 2014';
	$VAR_Profile ='Sony_TV';
	$VAR_Profile2 ='Sony_Standby';

	$VarNames[0]         					= array('name'=>'KanalNr', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -99, 'default_value'=>'',);
   $VarNames[1]         					= array('name'=>'Kanal', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -98, 'default_value'=>'',);
   $VarNames[2]         					= array('name'=>'Sendung', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -97, 'default_value'=>'',);
	$VarNames[3]         					= array('name'=>'Sony_Tv', 'type'=>1, 'hidden'=>false, 'profil'=>$VAR_Profile, 'position'=> -100, 'default_value'=>0,);
	$VarNames[4]         					= array('name'=>'Cookie', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -90, 'default_value'=>'',);
	$VarNames[5]         					= array('name'=>'TVCode', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -91, 'default_value'=>'',);
	$VarNames[6]         					= array('name'=>'my_device', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -96, 'default_value'=>'',);
	$VarNames[7]         					= array('name'=>'my_nick', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -95, 'default_value'=>'',);
	$VarNames[8]         					= array('name'=>'my_uuid', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -94, 'default_value'=>'',);
	$VarNames[9]         					= array('name'=>'Tv-IP', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -93, 'default_value'=>'',);
	$VarNames[10]         					= array('name'=>'Tv-MAC fur WOL', 'type'=>3, 'hidden'=>false, 'profil'=>'~String', 'position'=> -92, 'default_value'=>'',);
	$VarNames[11]         					= array('name'=>'Status', 'type'=>1, 'hidden'=>false, 'profil'=>$VAR_Profile2, 'position'=> -92, 'default_value'=>0,);

// Skript-Definitionen
	$SkriptNames[0]        					= array('name'=>'Anmeldung',);
	$SkriptNames[1]        					= array('name'=>'Cookie holen',);
	$SkriptNames[2]        					= array('name'=>'Kanal anzeigen',);
	$SkriptNames[3]        					= array('name'=>'Sony FB',);
	$SkriptNames[4]        					= array('name'=>'SonyAktion',);
	$SkriptNames[5]        					= array('name'=>'Sony_Steuerung',);
	$SkriptNames[6]        					= array('name'=>'Ping',);


function CreateScriptByName($ScriptNAME, $ParentID, $ScriptTEXT)
{
   global $IPS_SELF,$ScriptID;
    $ScriptID = @IPS_GetScriptIDByName($ScriptNAME, $ParentID);
    if ($ScriptID == 0){
       $ScriptID = IPS_CreateScript(0);
       IPS_SetName($ScriptID, $ScriptNAME);
       IPS_SetParent($ScriptID, $ParentID);
       IPS_SetInfo($ScriptID, "This script was created by: #$IPS_SELF#");
       $ScriptPath = $ScriptID.".ips.php";     //Skriptdatei
       IPS_SetScriptFile($ScriptID, $ScriptPath);
       IPS_SetHidden($ScriptID, false);
       IPS_SetScriptContent($ScriptID, $ScriptTEXT);
    }
}

// übergeordnete Instanz identifizieren
	$Parent           						= IPS_GetParent($_IPS['SELF']);
	$ParentModul								= IPS_GetObject($Parent);

// Auto-Update (überprüft, ob alle Skripte im Baum vorhanden sind
	for($i=0;$i<count($SkriptNames);$i++)
	{

	   if(@IPS_GetObjectIDByName($SkriptNames[$i]['name'], IPS_GetParent($_IPS['SELF'])) == false)
		{
			$Update_s 							= true;     // Update-Status auf true setzen
    		$i 									= 9999;     // Abbruch der Schleife bei fehlendem Objekt
		}
		else
		{
			$Update_s 							= false;     // alle Objekte vorhanden -> Update-Status auf false setzen
		}
	}

// Auto-Update (überprüft, ob alle Var's im Baum vorhanden sind
	for($i=0;$i<count($VarNames);$i++)
	{
	   if(@IPS_GetObjectIDByName($VarNames[$i]['name'], IPS_GetParent($_IPS['SELF'])) == false)
		{
			$Update_v							= true;     // Update-Status auf true setzen
    		$i 									= 9999;     // Abbruch der Schleife bei fehlendem Objekt
		}
		else
		{
			$Update_v 							= false;     // alle Objekte vorhanden -> Update-Status auf false setzen
		}
	}
	   if(($Update_s == true) or ($Update_v == true))
		{
	    $Update 								= true;     // Update-Status auf true setzen
    		$i 									= 9999;     // Abbruch der Schleife bei fehlendem Objekt
		}
		else
		{
			$Update 								= false;     // alle Objekte vorhanden -> Update-Status auf false setzen
		}


// Sony Auswertelogik
if(($ParentModul['ObjectType'] == 1) && ($ParentModul['ObjectName'] == $VAR_Dummy) && ($Update == false))
{
	// Variablen identifizieren
	   $KanalNr_ID 	= IPS_GetObjectIDByName($VarNames[0]['name'], IPS_GetParent($_IPS['SELF']));
	   $Kanal_ID      = IPS_GetObjectIDByName($VarNames[1]['name'], IPS_GetParent($_IPS['SELF']));
	   $Sendung_ID    = IPS_GetObjectIDByName($VarNames[2]['name'], IPS_GetParent($_IPS['SELF']));
	   $SonyTv_ID    	= IPS_GetObjectIDByName($VarNames[3]['name'], IPS_GetParent($_IPS['SELF']));
		$my_device_ID	= IPS_GetObjectIDByName($VarNames[6]['name'], IPS_GetParent($_IPS['SELF']));
		$my_nick_ID 	= IPS_GetObjectIDByName($VarNames[7]['name'], IPS_GetParent($_IPS['SELF']));
		$Tmy_uuid_ID 	= IPS_GetObjectIDByName($VarNames[8]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_MAC_ID 		= IPS_GetObjectIDByName($VarNames[9]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_IP_ID 		= IPS_GetObjectIDByName($VarNames[10]['name'], IPS_GetParent($_IPS['SELF']));
	   $Status_ID 		= IPS_GetObjectIDByName($VarNames[11]['name'], IPS_GetParent($_IPS['SELF']));


	// IPS Werte auslesen
//		$KanalNr	                = getValueString($KanalNr_ID);
//		$Kanal_ID	             = getValueString($Kanal_ID);
//		$Sendung_ID	             = getValueString($Sendung_ID);
}
#######################################################################################################################################
// Install-Routinen
elseif($_IPS['SENDER'] == 'Execute')
{
	// Profil Sony_TV anlegen
	if (IPS_VariableProfileExists($VAR_Profile))  IPS_DeleteVariableProfile($VAR_Profile);
	IPS_CreateVariableProfile($VAR_Profile, 1);
	IPS_SetVariableProfileValues($VAR_Profile, 0, 0, 0); //PName, Minimal, Maximal, Schrittweite
	IPS_SetVariableProfileAssociation($VAR_Profile, 0, "PowerOn", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 1, "PowerOff", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 2, "Red", "", 0xFF0000); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 3, "Green", "", 0x00FF00); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 4, "Yellow", "", 0xFFFF00); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 5, "Blue", "", 0x0000FF); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 6, "Up", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 7, "Left", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 8, "Right", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 9, "Down", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 10, "OK", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 11, "?", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 12, "Vol+", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 13, "Vol-", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 14, "Mute", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 15, "1", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 16, "2", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 17, "3", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 18, "4", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 19, "5", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 20, "6", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 21, "7", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 22, "8", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 23, "9", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 24, "0", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 25, "Exit", "", 0); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile, 26, "?", "", 0); //P-Name, Value, Assotiation, Icon, Color

	if (IPS_VariableProfileExists($VAR_Profile2))  IPS_DeleteVariableProfile($VAR_Profile2);
	IPS_CreateVariableProfile($VAR_Profile2, 1);
	IPS_SetVariableProfileValues($VAR_Profile2, 0, 0, 0); //PName, Minimal, Maximal, Schrittweite
	IPS_SetVariableProfileAssociation($VAR_Profile2, 0, "Off", "", 0xFF0000); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile2, 2, "On", "", 0x00FF00); //P-Name, Value, Assotiation, Icon, Color
	IPS_SetVariableProfileAssociation($VAR_Profile2, 1, "Standby", "", 0xFFFF00); //P-Name, Value, Assotiation, Icon, Color

	if((($ParentModul['ObjectType'] != 1) && ($ParentModul['ObjectName'] != $VAR_Dummy)) || ($Update == true))
	{
	   if(($ParentModul['ObjectType'] != 1) && ($ParentModul['ObjectName'] != $VAR_Dummy))
	   {
		   // Dummy-Instanz anlegen und Script drunterhängen
	      $ModulID				= IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}");
	      IPS_SetName($ModulID, $VAR_Dummy);
	      IPS_SetParent($ModulID, $Parent);
	      IPS_SetParent($_IPS['SELF'], $ModulID);
	      IPS_SetHidden($_IPS['SELF'], true);
	      IPS_ApplyChanges($ModulID);
      }
///////////////////////////////////////////////////////////////////////
// Skripte anlegen

$Aktion ='<?
if($_IPS["SENDER"] == "WebFront")
{
    SetValue($_IPS["VARIABLE"], $_IPS["VALUE"]);
}
?>';
CreateScriptByName('SonyAktion',IPS_GetParent($_IPS['SELF']),$Aktion);
IPS_SetHidden($ScriptID, true);
$aktion_skript=$ScriptID;

////////////////////////////////////////////////////////////////////////////////
$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $mac_ID    				= IPS_GetObjectIDByName(\'Tv-MAC fur WOL\', IPS_GetParent($_IPS[\'SELF\']));

	// IPS Werte auslesen
		$cookie=getValueString($Cookie_ID);
		$tvip=getValueString($tv_ip_ID);
      $mac=getValueString($mac_ID);


$addr=\'255.255.255.255\';
$did = 1;
$controllerinfo = json_decode(\'{"id":10,"result":[{"bundled":true,"type":"RM-J1100"}
,[{"name":"PowerOff","value":"AAAAAQAAAAEAAAAvAw=="}
,{"name":"Input","value":"AAAAAQAAAAEAAAAlAw=="}
,{"name":"GGuide","value":"AAAAAQAAAAEAAAAOAw=="}
,{"name":"EPG","value":"AAAAAgAAAKQAAABbAw=="}
,{"name":"Favorites","value":"AAAAAgAAAHcAAAB2Aw=="}
,{"name":"Display","value":"AAAAAQAAAAEAAAA6Aw=="}
,{"name":"Home","value":"AAAAAQAAAAEAAABgAw=="}
,{"name":"Options","value":"AAAAAgAAAJcAAAA2Aw=="}
,{"name":"Return","value":"AAAAAgAAAJcAAAAjAw=="}
,{"name":"Up","value":"AAAAAQAAAAEAAAB0Aw=="}
,{"name":"Down","value":"AAAAAQAAAAEAAAB1Aw=="}
,{"name":"Right","value":"AAAAAQAAAAEAAAAzAw=="}
,{"name":"Left","value":"AAAAAQAAAAEAAAA0Aw=="}
,{"name":"Confirm","value":"AAAAAQAAAAEAAABlAw=="}
,{"name":"Red","value":"AAAAAgAAAJcAAAAlAw=="}
,{"name":"Green","value":"AAAAAgAAAJcAAAAmAw=="}
,{"name":"Yellow","value":"AAAAAgAAAJcAAAAnAw=="}
,{"name":"Blue","value":"AAAAAgAAAJcAAAAkAw=="}
,{"name":"Num1","value":"AAAAAQAAAAEAAAAAAw=="}
,{"name":"Num2","value":"AAAAAQAAAAEAAAABAw=="}
,{"name":"Num3","value":"AAAAAQAAAAEAAAACAw=="}
,{"name":"Num4","value":"AAAAAQAAAAEAAAADAw=="}
,{"name":"Num5","value":"AAAAAQAAAAEAAAAEAw=="}
,{"name":"Num6","value":"AAAAAQAAAAEAAAAFAw=="}
,{"name":"Num7","value":"AAAAAQAAAAEAAAAGAw=="}
,{"name":"Num8","value":"AAAAAQAAAAEAAAAHAw=="}
,{"name":"Num9","value":"AAAAAQAAAAEAAAAIAw=="}
,{"name":"Num0","value":"AAAAAQAAAAEAAAAJAw=="}
,{"name":"Num11","value":"AAAAAQAAAAEAAAAKAw=="}
,{"name":"Num12","value":"AAAAAQAAAAEAAAALAw=="}
,{"name":"VolumeUp","value":"AAAAAQAAAAEAAAASAw=="}
,{"name":"VolumeDown","value":"AAAAAQAAAAEAAAATAw=="}
,{"name":"Mute","value":"AAAAAQAAAAEAAAAUAw=="}
,{"name":"ChannelUp","value":"AAAAAQAAAAEAAAAQAw=="}
,{"name":"ChannelDown","value":"AAAAAQAAAAEAAAARAw=="}
,{"name":"SubTitle","value":"AAAAAgAAAJcAAAAoAw=="}
,{"name":"ClosedCaption","value":"AAAAAgAAAKQAAAAQAw=="}
,{"name":"Enter","value":"AAAAAQAAAAEAAAALAw=="}
,{"name":"DOT","value":"AAAAAgAAAJcAAAAdAw=="}
,{"name":"Analog","value":"AAAAAgAAAHcAAAANAw=="}
,{"name":"Teletext","value":"AAAAAQAAAAEAAAA/Aw=="}
,{"name":"Exit","value":"AAAAAQAAAAEAAABjAw=="}
,{"name":"Analog2","value":"AAAAAQAAAAEAAAA4Aw=="}
,{"name":"*AD","value":"AAAAAgAAABoAAAA7Aw=="}
,{"name":"Digital","value":"AAAAAgAAAJcAAAAyAw=="}
,{"name":"Analog?","value":"AAAAAgAAAJcAAAAuAw=="}
,{"name":"BS","value":"AAAAAgAAAJcAAAAsAw=="}
,{"name":"CS","value":"AAAAAgAAAJcAAAArAw=="}
,{"name":"BSCS","value":"AAAAAgAAAJcAAAAQAw=="}
,{"name":"Ddata","value":"AAAAAgAAAJcAAAAVAw=="}
,{"name":"PicOff","value":"AAAAAQAAAAEAAAA+Aw=="}
,{"name":"Tv_Radio","value":"AAAAAgAAABoAAABXAw=="}
,{"name":"Theater","value":"AAAAAgAAAHcAAABgAw=="}
,{"name":"SEN","value":"AAAAAgAAABoAAAB9Aw=="}
,{"name":"InternetWidgets","value":"AAAAAgAAABoAAAB6Aw=="}
,{"name":"InternetVideo","value":"AAAAAgAAABoAAAB5Aw=="}
,{"name":"Netflix","value":"AAAAAgAAABoAAAB8Aw=="}
,{"name":"SceneSelect","value":"AAAAAgAAABoAAAB4Aw=="}
,{"name":"Mode3D","value":"AAAAAgAAAHcAAABNAw=="}
,{"name":"iManual","value":"AAAAAgAAABoAAAB7Aw=="}
,{"name":"Audio","value":"AAAAAQAAAAEAAAAXAw=="}
,{"name":"Wide","value":"AAAAAgAAAKQAAAA9Aw=="}
,{"name":"Jump","value":"AAAAAQAAAAEAAAA7Aw=="}
,{"name":"PAP","value":"AAAAAgAAAKQAAAB3Aw=="}
,{"name":"MyEPG","value":"AAAAAgAAAHcAAABrAw=="}
,{"name":"ProgramDescription","value":"AAAAAgAAAJcAAAAWAw=="}
,{"name":"WriteChapter","value":"AAAAAgAAAHcAAABsAw=="}
,{"name":"TrackID","value":"AAAAAgAAABoAAAB+Aw=="}
,{"name":"TenKey","value":"AAAAAgAAAJcAAAAMAw=="}
,{"name":"AppliCast","value":"AAAAAgAAABoAAABvAw=="}
,{"name":"acTVila","value":"AAAAAgAAABoAAAByAw=="}
,{"name":"DeleteVideo","value":"AAAAAgAAAHcAAAAfAw=="}
,{"name":"PhotoFrame","value":"AAAAAgAAABoAAABVAw=="}
,{"name":"TvPause","value":"AAAAAgAAABoAAABnAw=="}
,{"name":"KeyPad","value":"AAAAAgAAABoAAAB1Aw=="}
,{"name":"Media","value":"AAAAAgAAAJcAAAA4Aw=="}
,{"name":"SyncMenu","value":"AAAAAgAAABoAAABYAw=="}
,{"name":"Forward","value":"AAAAAgAAAJcAAAAcAw=="}
,{"name":"Play","value":"AAAAAgAAAJcAAAAaAw=="}
,{"name":"Rewind","value":"AAAAAgAAAJcAAAAbAw=="}
,{"name":"Prev","value":"AAAAAgAAAJcAAAA8Aw=="}
,{"name":"Stop","value":"AAAAAgAAAJcAAAAYAw=="}
,{"name":"Next","value":"AAAAAgAAAJcAAAA9Aw=="}
,{"name":"Rec","value":"AAAAAgAAAJcAAAAgAw=="}
,{"name":"Pause","value":"AAAAAgAAAJcAAAAZAw=="}
,{"name":"Eject","value":"AAAAAgAAAJcAAABIAw=="}
,{"name":"FlashPlus","value":"AAAAAgAAAJcAAAB4Aw=="}
,{"name":"FlashMinus","value":"AAAAAgAAAJcAAAB5Aw=="}
,{"name":"TopMenu","value":"AAAAAgAAABoAAABgAw=="}
,{"name":"PopUpMenu","value":"AAAAAgAAABoAAABhAw=="}
,{"name":"RakurakuStart","value":"AAAAAgAAAHcAAABqAw=="}
,{"name":"OneTouchTimeRec","value":"AAAAAgAAABoAAABkAw=="}
,{"name":"OneTouchView","value":"AAAAAgAAABoAAABlAw=="}
,{"name":"OneTouchRec","value":"AAAAAgAAABoAAABiAw=="}
,{"name":"OneTouchStop","value":"AAAAAgAAABoAAABjAw=="}
,{"name":"DUX","value":"AAAAAgAAABoAAABzAw=="}
,{"name":"FootballMode","value":"AAAAAgAAABoAAAB2Aw=="}
,{"name":"Social","value":"AAAAAgAAABoAAAB0Aw=="}
]    ]}\',true);
$codes = array();
foreach($controllerinfo[\'result\'] as $k => $v) {
foreach($v as $code) {
if (isset($code[\'name\'])) {
$codes[$code[\'name\']] = $code[\'value\'];
}
}
}

function sendCommand($key) {
global $codes;
$data = \'<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>\';
$data .= \'<u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">
<IRCCCode>\'.$codes[$key].\'</IRCCCode>
</u:X_SendIRCC>\';
$data .= \'</s:Body>
</s:Envelope>\';
sendCurlPost(\'/sony/IRCC\',$data);
}

function sendCurlPost($url,$data, $auth = false) {
global $cookie, $tvip;
$headers = array();
// $cookie = "auth=e708c3f8033c42f46681c01aa5155eb451f00c88bb7969a2380a9c31eaabb48f";
$headers[] = "Cookie: " . $cookie;
$headers[] = "Content-Type: text/xml; charset=UTF-8";
$headers[] = "Content-Length: " . strlen($data);
$ch = curl_init(\'http://\'. $tvip . $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
return curl_exec($ch);
}

function WakeOnLan($mac, $addr) {
	$addr_byte = explode(\':\', $mac);
	$hw_addr = \'\';

	for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));

	$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);

	for ($a = 1; $a <= 16; $a++)    $msg .= $hw_addr;

	$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
	if ($s == false) {
		echo "Error creating socket!
";
		echo "Error code is \'".socket_last_error($s)."\' - " . socket_strerror(socket_last_error($s));
		return false;
	} else {
		$opt_ret =  socket_set_option($s, 1, 6, TRUE);
		if($opt_ret < 0) {
			echo "setsockopt() failed, error: " . strerror($opt_ret) . "
";
			return false;
		}
		$e = socket_sendto($s, $msg, strlen($msg), 0, $addr, 2050);
		socket_close($s);
		return true;
	}
}

?>';
CreateScriptByName('Sony_Steuerung',IPS_GetParent($_IPS['SELF']),$Sony_text);
IPS_SetHidden($ScriptID, true);

$aktion_steuerung=$ScriptID;
////////////////////////////////////////////////////////////////////////////////
$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
$tv_ip_ID    				= IPS_GetObjectIDByName(\'Sony_Steuerung\', IPS_GetParent($_IPS[\'SELF\']));
include IPS_GetKernelDir().\'scripts/\'.$tv_ip_ID.\'.ips.php\';

$addr = "255.255.255.255"; // Broadcast adresse für WOL

$_befehl = "";
if($_IPS["SENDER"] == "WebFront")
{
    SetValue($_IPS["VARIABLE"], $_IPS["VALUE"]);
//	 print($_IPS["Value"]);
}
$_control = ($_IPS["VALUE"]);

  if ($_control === 0){
   WakeOnLan($mac, $addr);
  } else
  {
  if ($_control === 1) ($_befehl="PowerOff");
  if ($_control === 2) ($_befehl="Red" );
  if ($_control === 3) ($_befehl="Green" );
  if ($_control === 4) ($_befehl="Yellow" );
  if ($_control === 5) ($_befehl="Blue" );
  if ($_control === 6) ($_befehl="Up" );
  if ($_control === 7) ($_befehl="Left" );
  if ($_control === 8) ($_befehl="Right" );
  if ($_control === 9) ($_befehl="Down" );
  if ($_control === 10)($_befehl="Confirm" );
  if ($_control === 11)($_befehl="" );
  if ($_control === 12)($_befehl="VolumeDown" );
  if ($_control === 13)($_befehl="VolumeUp" );
  if ($_control === 14)($_befehl="Mute" );
  if ($_control === 15)($_befehl="Num1" );
  if ($_control === 16)($_befehl="Num2" );
  if ($_control === 17)($_befehl="Num3" );
  if ($_control === 18)($_befehl="Num4" );
  if ($_control === 19)($_befehl="Num5" );
  if ($_control === 20)($_befehl="Num6" );
  if ($_control === 21)($_befehl="Num7" );
  if ($_control === 22)($_befehl="Num8" );
  if ($_control === 23)($_befehl="Num9" );
  if ($_control === 24)($_befehl="Num0" );
  if ($_control === 25)($_befehl="Exit" );
  if ($_control === 26)($_befehl="" );
  sendCommand($_befehl);
  }
?>';
CreateScriptByName('Sony FB',IPS_GetParent($_IPS['SELF']),$Sony_text);
IPS_SetHidden($ScriptID, true);
$aktion_FB=$ScriptID;


$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_device_ID    				= IPS_GetObjectIDByName(\'my_device\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_nick_ID    				= IPS_GetObjectIDByName(\'my_nick\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_uuid_ID    				= IPS_GetObjectIDByName(\'my_uuid\', IPS_GetParent($_IPS[\'SELF\']));
	   $TVCode_ID    				= IPS_GetObjectIDByName(\'TVCode\', IPS_GetParent($_IPS[\'SELF\']));
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	// IPS Werte auslesen


	// IPS Werte auslesen
		$tv_ip=getValueString($tv_ip_ID);
		$my_device=GetValueString ($my_device_ID);
		$my_nick=GetValueString ($my_nick_ID );
		$my_uuid=GetValueString ($my_uuid_ID );
		$TVCode=GetValueString ($TVCode_ID );
		$cookie= getValueString($Cookie_ID);

# use only A-Z a-z 0-9 for device. Probably. Havent checked.
// Start anlernen
$url =\'/sony/accessControl\';
$data=\'{"method":"actRegister","params":[{"clientid":"\'.$my_nick.\':\'.$my_uuid.\'","nickname":"\'.$my_nick.\' (\'.$my_device.\')","level":"private"},[{"value":"yes","function":"WOL"}]],"id":8,"version":"1.0"}\';
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
curl_close($ch);
//echo $ausgabe.chr(10);
// Hier auf Eingabe vom Code warten (WebFront)
$tv_key =\'Neu\';
SetValueString ($TVCode_ID , $tv_key);
$i = 0;
while( $tv_key === \'Neu\')
{
	$tv_key=GetValueString ($TVCode_ID);
//	echo $tv_key;
	IPS_sleep(1000);
   $i++;
   if( $i == 40 )break;
}

// Key senden
	$tv_key=GetValueString ($TVCode_ID);
//echo $tv_key;
$tv_key=\':\'.$tv_key;
$tv_challenge = base64_encode($tv_key);
$tv_auth_header=\'Authorization: Basic \'.$tv_challenge;
//echo $tv_auth_header.chr(10);
$headers = array();
$headers[]=$tv_auth_header;
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
list($headers, $response) = explode("

", $ausgabe, 2);
$headers = explode("
", $headers);
foreach($headers as $header) {
    if (stripos($header, \'Set-Cookie:\') !== false) {
//        echo $header.chr(10);
        $header = substr($header,0,strpos($header,";"));
        $auth = strstr($header, "a");
//		  echo $auth;
        SetValueString ($Cookie_ID , $auth );
    }
}
?>';
CreateScriptByName('Anmeldung',IPS_GetParent($_IPS['SELF']),$Sony_text);
//$aktion_FB=$ScriptID;

$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $mac_ID    				= IPS_GetObjectIDByName(\'Tv-MAC fur WOL\', IPS_GetParent($_IPS[\'SELF\']));

	   $KanalNr_ID    				= IPS_GetObjectIDByName(\'KanalNr\', IPS_GetParent($_IPS[\'SELF\']));
	   $Kanal_ID    				= IPS_GetObjectIDByName(\'Kanal\', IPS_GetParent($_IPS[\'SELF\']));
	   $Sendung_ID    				= IPS_GetObjectIDByName(\'Sendung\', IPS_GetParent($_IPS[\'SELF\']));

	// IPS Werte auslesen
		$cookie=getValueString($Cookie_ID);
		$tv_ip=getValueString($tv_ip_ID);
      $mac=getValueString($mac_ID);

$url =\'/sony/avContent\';
$data = \'{"method":"getPlayingContentInfo","params":[""],"id":1,"version":"1.0"}\';
$headers = array();
$headers[] = "Cookie: " . $cookie;
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false); //Header abgeschaltet
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
$error = 0;
$json_a = json_decode($ausgabe,true);

if (isset($json_a["error"])) {
    SetValueString($Kanal_ID ,$json_a["error"][1]);
	 SetValueString($Sendung_ID   ,\' \');
    SetValueString($KanalNr_ID  ,\' \');
}
else
{
//echo $json_a["result"][0]["programTitle"];
//echo $json_a["result"][0]["title"];
SetValueString($Kanal_ID , utf8_decode($json_a["result"][0]["title"]));
SetValueString($Sendung_ID  ,utf8_decode($json_a["result"][0]["programTitle"]));
SetValueString($KanalNr_ID   ,utf8_decode($json_a["result"][0]["dispNum"]));
}
?>';
CreateScriptByName('Kanal anzeigen',IPS_GetParent($_IPS['SELF']),$Sony_text);
//$aktion_FB=$ScriptID;

$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_device_ID    				= IPS_GetObjectIDByName(\'my_device\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_nick_ID    				= IPS_GetObjectIDByName(\'my_nick\', IPS_GetParent($_IPS[\'SELF\']));
	   $my_uuid_ID    				= IPS_GetObjectIDByName(\'my_uuid\', IPS_GetParent($_IPS[\'SELF\']));
	   $TVCode_ID    				= IPS_GetObjectIDByName(\'TVCode\', IPS_GetParent($_IPS[\'SELF\']));
	   $Cookie_ID    				= IPS_GetObjectIDByName(\'Cookie\', IPS_GetParent($_IPS[\'SELF\']));
	// IPS Werte auslesen


	// IPS Werte auslesen
		$tv_ip=getValueString($tv_ip_ID);
		$my_device=GetValueString ($my_device_ID);
		$my_nick=GetValueString ($my_nick_ID );
		$my_uuid=GetValueString ($my_uuid_ID );
		$TVCode=GetValueString ($TVCode_ID );
		$cookie= getValueString($Cookie_ID);

// Start anlernen
$url =\'/sony/accessControl\';
//[["actRegister",["{\"clientid\":\"string\",\"nickname\":\"string\",\"level\":\"string\"}","{\"function\":\"string\",\"value\":\"string\"}*"],[],"1.0"],["getMethodTypes",["string"],["string","string*","string*","string"],"1.0"],["getVersions",[],["string*"],"1.0"]]}

$data=\'{"method":"actRegister","params":[{"clientid":"\'.$my_nick.\':\'.$my_uuid.\'","nickname":"\'.$my_nick.\' (\'.$my_device.\')","level":"private"},[{"value":"yes","function":"WOL"}]],"id":8,"version":"1.0"}\';
$headers = array();
$ch = curl_init(\'http://\'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
$json_a = json_decode($ausgabe,true);
//var_dump ($json_a);
if (isset($json_a["error"])) {

}
else
{

list($headers, $response) = explode("

", $ausgabe, 2);
$headers = explode("
", $headers);
foreach($headers as $header) {
    if (stripos($header, \'Set-Cookie:\') !== false) {
//        echo $header.chr(10);
        $header = substr($header,0,strpos($header,";"));
        $auth = strstr($header, "a");
//		  echo $auth;
        SetValueString ($Cookie_ID , $auth );
    }
}

}
?>';
CreateScriptByName('Cookie holen',IPS_GetParent($_IPS['SELF']),$Sony_text);

$Sony_text='<?
$Parent           						= IPS_GetParent($_IPS[\'SELF\']);
$ParentModul								= IPS_GetObject($Parent);
	// Variablen identifizieren
global $skript_ID;
$skript_ID    				= IPS_GetObjectIDByName(\'Kanal anzeigen\', IPS_GetParent($_IPS[\'SELF\']));
//var_dump($skript_ID);
	// Variablen identifizieren
$tv_ip_ID    				= IPS_GetObjectIDByName(\'Tv-IP\', IPS_GetParent($_IPS[\'SELF\']));
$status_ID    				= IPS_GetObjectIDByName(\'Status\', IPS_GetParent($_IPS[\'SELF\']));
$kanal_ID    				= IPS_GetObjectIDByName(\'Kanal\', IPS_GetParent($_IPS[\'SELF\']));

$tvip=getValueString($tv_ip_ID);

//IPS_RunScript($skript_ID);
function ping($host,$port=80,$timeout=1)
{
        $fsock = @fsockopen($host, $port, $errno, $errstr, $timeout);
        if ( ! $fsock )
        {
              return false;;
        }
        else
        {
              return true;
        }
}
$up=ping($tvip);

if ($up == false) {
    SetValue($status_ID , 0);

}
else {
    IPS_RunScript($skript_ID);
    $inhalt=getValueString($kanal_ID);

//var_dump ($inhalt);
    if ($inhalt == "not power-on") {
   	 SetValue($status_ID , 1);
    }
    else
    {
      SetValue($status_ID , 2);
    }
}
?>';
CreateScriptByName('Ping',IPS_GetParent($_IPS['SELF']),$Sony_text);
IPS_SetHidden($ScriptID, true);
IPS_SetScriptTimer($ScriptID, 5);

///////////////////////////////////////////////////////////////////////////////

		// Variablen anlegen - wenn nicht vorhanden
      // 1. vorhandene Vars auslesen
      $ModulID					= IPS_GetParent($_IPS['SELF']);

		for($i=0;$i<count($VarNames);$i++)
		{
		   if(@IPS_GetObjectIDByName($VarNames[$i]['name'], IPS_GetParent($_IPS['SELF'])) == false)
		   {
		   $VarID = IPS_CreateVariable($VarNames[$i]['type']);
		   IPS_SetName($VarID, $VarNames[$i]['name']);
		   IPS_SetHidden($VarID, $VarNames[$i]['hidden']);
		   IPS_SetPosition($VarID, $VarNames[$i]['position']);
		   IPS_SetParent($VarID, $ModulID);
		   SetValue($VarID, $VarNames[$i]['default_value']);
			}
   // Profile zuweisen
			$VarID = IPS_GetObjectIDByName($VarNames[$i]['name'], IPS_GetParent($_IPS['SELF']));
			IPS_SetVariableCustomProfile($VarID, $VarNames[$i]['profil']);
   // Aktion zuweisen
		   IPS_SetVariableCustomAction($VarID,$aktion_skript);

		}

		$my_device_ID = IPS_GetObjectIDByName($VarNames[6]['name'], IPS_GetParent($_IPS['SELF']));
		$my_nick_ID = IPS_GetObjectIDByName($VarNames[7]['name'], IPS_GetParent($_IPS['SELF']));
		$my_uuid_ID = IPS_GetObjectIDByName($VarNames[8]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_MAC_ID = IPS_GetObjectIDByName($VarNames[9]['name'], IPS_GetParent($_IPS['SELF']));
	   $TV_IP_ID = IPS_GetObjectIDByName($VarNames[10]['name'], IPS_GetParent($_IPS['SELF']));
      SetValueString ($my_device_ID , 'BananaPi2' );
      SetValueString ($my_nick_ID , 'IPS' );
      SetValueString ($my_uuid_ID , '17' );
      SetValueString ($TV_MAC_ID , '192.168.1.61' );
      SetValueString ($TV_IP_ID , 'FC:F1:52:72:7E:A3' );

	   $KanalNr_ID 	= IPS_GetObjectIDByName($VarNames[0]['name'], IPS_GetParent($_IPS['SELF']));
	   $Kanal_ID      = IPS_GetObjectIDByName($VarNames[1]['name'], IPS_GetParent($_IPS['SELF']));
	   $Sendung_ID    = IPS_GetObjectIDByName($VarNames[2]['name'], IPS_GetParent($_IPS['SELF']));
	   $Status_ID 		= IPS_GetObjectIDByName($VarNames[11]['name'], IPS_GetParent($_IPS['SELF']));
      $SonyTv_ID    	= IPS_GetObjectIDByName($VarNames[3]['name'], IPS_GetParent($_IPS['SELF']));
      $Cookie_ID    	= IPS_GetObjectIDByName($VarNames[4]['name'], IPS_GetParent($_IPS['SELF']));

      IPS_SetVariableCustomAction($SonyTv_ID,$aktion_FB);
		IPS_SetVariableCustomAction($KanalNr_ID,0);
		IPS_SetVariableCustomAction($Kanal_ID,0);
		IPS_SetVariableCustomAction($Sendung_ID,0);
		IPS_SetVariableCustomAction($Status_ID,0);
		IPS_SetVariableCustomAction($Cookie_ID,0);

	}
	 echo "#9999 IPS Sony: Install ready (neue Objekte angelegt)
";

}
else
{
	echo "Script #".$_IPS['SELF']." Sony: ohne Ergebnis gelaufen (keine Objekte gefunden/Objekte fehlerhaft
";
}


?>

Bitte verbessern !

Habe im Moment zu viele andere private Baustellen…:mad:

Rest per Mail oder Lifezugrif nach Absprache …

So geht es :


<?
//SonyVolume
// VAR Volume muss noch per Hand angelegt werden, und ein Ereignis bei VAR Änderung.
$Parent           						= IPS_GetParent($_IPS['SELF']);
$ParentModul								= IPS_GetObject($Parent);

	// Variablen identifizieren
	   $Cookie_ID    				= IPS_GetObjectIDByName('Cookie', IPS_GetParent($_IPS['SELF']));
	   $tv_ip_ID    				= IPS_GetObjectIDByName('Tv-IP', IPS_GetParent($_IPS['SELF']));
	   $vol_ID    				   = IPS_GetObjectIDByName('Volume', IPS_GetParent($_IPS['SELF']));

	// IPS Werte auslesen
		$cookie=getValueString($Cookie_ID);
		$tv_ip=getValueString($tv_ip_ID);
      $vol=GetValueInteger($vol_ID);

$url ='/sony/audio';
$data = '{"id":2,"method":"setAudioVolume","version":"1.0","params":[{"target":"speaker","volume":"'.$vol.'"}]}';

$headers = array();
$headers[] = "Cookie: " . $cookie;
$ch = curl_init('http://'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false); 
$ausgabe = curl_exec($ch);
echo $ausgabe.chr(10);
curl_close($ch);
$error = 0;
?>

Super! Danke!

Werd ich mich mal heute ransetzen …

Hi Thomas.

Danke für das Script, läuft super.

Mal ne Frage wie bist du auf „setAudioVolume“ gekommen?
Finde dazu keine Doku.

Grüße

Im Netz gefunden.
aydbe.com , „Übersetzer notwendig …“
Ich habe hier einen KDL-48W585B

Aaah Danke

„getMethodTypes“ ist das Zauberwort … Hab schon Stunden mit Google verbracht :rolleyes:

Nicht nur du…:smiley:
Schön wär es, wenn Ihr es noch verbessern würdet.:rolleyes:

Hmmm verbessern? Komm schon mit der ganzen id und Parameter Geschichte durcheinander. Wichtig war mir erst mal, dass ich mit ips die aktuelle Lautstärke auslesen kann.
Beim klingeln an der Tür wird der Fernseher jetzt leiser und geht nach erfolgter Ansage wieder in die ursprüngliche Lautstärke zurück.

Sent from my D6603 using Forum Fiend v1.3.2.

Moin,

Hab da noch etwas:

HDMI direkt schalten:

function switchHDMI($Input){

		$data = '{"id":2,"method":"setPlayContent","version":"1.0","params":[{"uri":"extInput:hdmi?port='.$Input.'"}]}';

   sendCurlPost('/sony/avContent', $data);
	}

oder etwas einfacher:

		,{"name":"HDMI1","value":"AAAAAgAAABoAAABaAw=="}
		,{"name":"HDMI2","value":"AAAAAgAAABoAAABbAw=="}
		,{"name":"HDMI3","value":"AAAAAgAAABoAAABcAw=="}
		,{"name":"HDMI4","value":"AAAAAgAAABoAAABdAw=="}

AV-Eingänge direkt schalten:

function switchAV($command){
	if($command == "AV1"){
		$Input = "scart?port=1";
		}
	if($command == "AV2"){
		$Input = "composite?port=1";
		}

		$data = '{"id":2,"method":"setPlayContent","version":"1.0","params":[{"uri":"extInput:'.$Input.'"}]}';

   sendCurlPost('/sony/avContent', $data);
	}

Gruß
Manfred

PS.: Bei Interesse, ich habe noch Skripte für Sony AV-Receiver.