GetValue verhält sich unterschiedlich für iFront/WebFront

Hallo,

ich bin neu hier im Forum.
Bisher konnte ich immer durch eifriges Suchen im Forum und eigenes Probieren meine wesentlichen Vorstellungen realisieren.

Jetzt habe ich aber ein Problem, zu dem ich bisher keine passenden Hinweise finden konnte.

Ich hab in einem Variablenprofile mit dem ich die Lautstärke meines Yamaha Receivers steuern und anzeigen möchte ein Aktionsskript zugeordnet.
Im Webfront funktioniert das wunderbar. Nur im IFront leider nicht. Dort wird zwar der Variablenwert entsprechend geändert aber die Aktion selbst (Lautstärkeänderung) wird nicht ausgeführt.

Hat jemand eine Idee, woran das liegen könnte?
Vorab besten Dank.

Aktionsskript:
<?
// Yamaha Volume einstellen

//Variable setzen
SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);

// Variable erneut auslesen und mit 10 multiplizieren für gefordertes Datenformat
$PutVolume = GetValue(20677 /*[EG\Yamaha\Yamaha AV Receiver\Volume]*/ ) *10;

// Lautstärke  an Receiver senden
IPS_RunScriptEx(49650 /*[scripts\YamahaControl]*/ , Array("Control" =&gt; 7, "Volume" =&gt; $PutVolume));

?>

Wir die Variable denn auch korrekt im Objektbaum gesetzt? Wenn ja, dann wird dein Akrionsskript korrekt aufgerufen. Wäre halt die Frage, warum das IPS_RunScript ein Problem haben sollte.

paresy

Hallo,

vielen Dank erst mal für die schnelle Rückmeldung!

Ja, die Variable im Objektbaum wird richtig gesetzt und damit das Aktionsskript ausgeführt.
Also scheint mein Problem in dem IPS_RunScriptEx Aufruf zu liegen.
Da werde ich mal noch etwas Fehleranalyse betreiben.

Falls jemand mal einen Blick darauf werfen möchte, hänge ich es hier mal hinten ran.
Vielleicht sieht der Profi auf die Schnelle etwas, wonach ich Stunden lang suchen muss.
(Kann gut sein, dass mein Code nicht sehr elegant ist)

Das Hochladen von Dateien funktioniert auf meinem Laptop irgendwie nicht, deshalb direkt im Post.
YamahaControl

<?

$host = '192.168.100.71';      //IP des Gerätes

// 0 = Power OFF
// 1 = Power ON
// 2 = Main Zone Mute ON
// 3 = Main Zone Mute Off
// 4 = Main Zone Mute On/Off
// 5 = Main Zone leiser (2 dB)
// 6 = Main Zone lauter (2 dB)
// 7 = Main Zone 55 dB setzten
// 8 = Power ON/OFF

// 11= Scene RADIO
// 12= Scene NET
// 13= Scene Windows
// 14= Scene CD

// 20= TUNER
// 21= TUNER Sunshine Live
// 22= TUNER RTL
// 23= TUNER Energy
// 24= TUNER rs.2

// 30= NetRadio
// 31= NetRadio Load Preset 1
// 32= NetRadio Load Preset 2
// 33= NetRadio Load Preset 3
// 34= NetRadio Load Preset 4
// 35= NetRadio Load Preset 5
// 36= NetRadio Load Preset 6

// 99= Power toggle

// 100= Get Power Status
// 101= Lautstärke abfragen



switch ($_IPS['Control']) {
//switch (101) {
     case 0:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>Standby</Power></Power_Control></Main_Zone></YAMAHA_AV>');
        //$send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><System><Power_Control><Power>Standby</Power></Power_Control></System></YAMAHA_AV>');
        break;
     case 1:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>On</Power></Power_Control></Main_Zone></YAMAHA_AV>');
        break;
     case 2:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Mute>On</Mute></Volume></Main_Zone></YAMAHA_AV>');
        break;
    case 3:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Mute>Off</Mute></Volume></Main_Zone></YAMAHA_AV>');
        break;
    case 4:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Mute>On/Off</Mute></Volume></Main_Zone></YAMAHA_AV>');
        break;
    case 5:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>Down 2 dB</Val><Exp></Exp><Unit></Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
        break;
    case 6:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>Up 2 dB</Val><Exp></Exp><Unit></Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
        break;
    case 7:
//        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>-550</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
         $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>'.$_IPS['Volume'].'</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>');
        break;
     case 8:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>On/Standby</Power></Power_Control></Main_Zone></YAMAHA_AV>');
        break;
    case 11:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 4</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
        break;
    case 12:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 3</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
        break;
    case 13:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 2</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
        break;
    case 14:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Scene><Scene_Sel>Scene 1</Scene_Sel></Scene></Main_Zone></YAMAHA_AV>');
        break;
    case 20:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Input><Input_Sel>TUNER</Input_Sel></Input></Main_Zone></YAMAHA_AV>');
        break;
    case 21:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Tuner><Play_Control><Preset><Preset_Sel>1</Preset_Sel></Preset></Play_Control></Tuner></YAMAHA_AV>');
        break;
    case 22:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Tuner><Play_Control><Preset><Preset_Sel>2</Preset_Sel></Preset></Play_Control></Tuner></YAMAHA_AV>');
        break;
    case 23:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Tuner><Play_Control><Preset><Preset_Sel>3</Preset_Sel></Preset></Play_Control></Tuner></YAMAHA_AV>');
        break;
    case 30:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><Main_Zone><Input><Input_Sel>NET</Input_Sel></Input></Main_Zone></YAMAHA_AV>');
        break;
    case 31:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_1</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
        break;
    case 32:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_2</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
        break;
    case 33:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_3</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
        break;
    case 34:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_4</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
        break;
    case 35:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_5</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
        break;
    case 36:
        $send = send_to_host($host,'<YAMAHA_AV cmd="PUT"><NET_RADIO><List_Control><Direct_Sel>Line_6</Direct_Sel></List_Control></NET_RADIO></YAMAHA_AV>');
        break;
    case 100:
        $send = send_to_host($host,'<YAMAHA_AV cmd="GET"><Main_Zone><Power_Control><Power>GetParam</Power></Power_Control></Main_Zone></YAMAHA_AV>');
//        $send = send_to_host($host,'<YAMAHA_AV cmd="GET"><NET_RADIO><List_Info>GetParam</List_Info></NET_RADIO></YAMAHA_AV>');
//            $send = send_to_host($host,'<YAMAHA_AV cmd="GET"><System><Config>GetParam</Config></System></YAMAHA_AV>');
          if ($send == "On") SetValueBoolean(21468 /*[EG\Yamaha\Yamaha AV Receiver\Power]*/ , TRUE);
          if ($send == "Standby") SetValueBoolean(21468 /*[EG\Yamaha\Yamaha AV Receiver\Power]*/ , FALSE);
        break;
    case 101:
        $send = send_to_host($host,'<YAMAHA_AV cmd="GET"><Main_Zone><Volume><Lvl>GetParam</Lvl></Volume></Main_Zone></YAMAHA_AV>');
            SetValue(20677 /*[EG\Yamaha\Yamaha AV Receiver\Volume]*/ ,substr($send,0,3).",".substr($send,3,1));
//            SetValue(20677 /*[EG\Yamaha\Yamaha AV Receiver\Volume]*/ ,substr($send,0,4));
        break;
}


//echo "
send: ".$send;  //Wenn Ok dann wird true (1) zurückgegeben



function send_to_host($host, $data){

    //echo $data;  //zum prüfen

    $command_lenght = strlen($data);

    //echo $command_lenght;    //zum prüfen

    $head = "";
    $head .= "POST /YamahaRemoteControl/ctrl HTTP/1.1
";
    $head .= "Host: ".$host."
";
    $head .= "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
";
    $head .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
";
    $head .= "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
";
    $head .= "Accept-Encoding: gzip, deflate
";
    $head .= "Connection: keep-alive
";
    $head .= "Content-Type: text/xml; charset=UTF-8
";
    $head .= "Referer: http://".$host."/
";
    $head .= "Content-Length: ".$command_lenght."
";
    $head .= "Pragma: no-cache
";
    $head .= "Cache-Control: no-cache

";
    $head .= $data;
    // echo $head; //zum prüfen

    $fp = fsockopen($host, 80) or die("Unable to open socket");
    fputs($fp, $head);

    $buf='';
    $buf2='';
   $buf = fgets($fp,128);
   

        while(!feof($fp)) {
        // receive the results of the request
        $buf2 = fgets($fp,192);
        }
   
    fclose($fp);

     $buf2 = strip_tags($buf2);

//    echo "buf:
".$buf;   //zum prüfen
//    echo "buf2:
".$buf2."
";   //zum prüfen

    $return = substr($buf,13,2);
    if ($buf2 <> "") $return = $buf2;

    return $return;
}


?>

einen Hinweis habe ich noch.
Der Aufruf des YamahControl Skripts mit anderen Optionen funktioniert mit dem iFront ohne Probleme.
Auf den ersten Blick ist ein Unterschied zu erkennen. Bei dem Problemaufruf übergebe ich 2 Parameter.
Mache ich da eventuell etwas falsch?

Volume +
<?

// Yamaha Volume +

IPS_RunScriptEx(49650 /*[scripts\YamahaControl]*/ , Array("Control" =&gt; 6));
IPS_RunScriptEx(49650 /*[scripts\YamahaControl]*/ , Array("Control" =&gt; 101));

?>

Aufruf aus Aktionsskript
// Lautstärke an Receiver senden
IPS_RunScriptEx(49650 /[scripts\YamahaControl]/ , Array(„Control“ => 7, „Volume“ => $PutVolume));

So, ich habe ein wenig herumprobiert und habe dabei herausgefunden, warum sich das IFront anders verhält als das Webfront.

Bei der Abfrage der Variablen $PutVolume = GetValue(20677 /[EG\Yamaha\Yamaha AV Receiver\Volume]/ );
berücksichtigt das Webfront das Variablenprofil und verwendet bei mir nur Werte zwischen -80,0 und -20,0 mit einer Schrittweite von 1,0. (Variablenbeispiele: -33, -54, -62)

Beim IFront wird das Variablenprofil scheinbar nicht berücksichtigt. Dort erhalte ich richtige Float-Werte (Beispiele: -33,5467, -54,2411, -62,1934). Wenn ich diese Werte an meinen Yamaha Receiver sende, kann er damit nichts anfangen und tut gar nichts.

Ich habe nun ein $PutVolume = intval($PutVolume); dazwischen gehangen und jetzt verhalten sich Webfront und IFront identisch :slight_smile:

Nun hat sich ja in diesem Fall herausgestellt, dass das ursprüngliche Thema nichts mit meinem eigentlichen Problem zu tun hat. Kann man ein Thema nachträglich ändern?

Gerry

Habe das Thema korrekt umbenannt. Prinziell ist das sogar ein Bug der mobilen Apps, vermutlich jedoch nur in iOS.

paresy

Besten Dank
Gerry