Ankündigung

Einklappen
Keine Ankündigung bisher.

Plugin mit PHP

Einklappen
Dieses Thema ist geschlossen.
X
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    #16
    Hallo
    Alles schon gehabt.
    Siehe hier https://knx-user-forum.de/forum/supp...wiregate/17756
    Von Perl aus kann man hinter den Scriptaufruf mit Post oder Get was übergeben.
    Von PHP nach Perl
    Code:
    [COLOR=#000000][COLOR=#007700] [COLOR=#000000][COLOR=#0000BB]my [/COLOR][COLOR=#007700]$[/COLOR][COLOR=#0000BB]response [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]qx[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]usr[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]bin[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]php [/COLOR][COLOR=#007700]../var/[/COLOR][COLOR=#0000BB]www[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]myhouse[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]pv[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]sma_rpc[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]php[/COLOR][COLOR=#007700]); [/COLOR][/COLOR][/COLOR][/COLOR]
    in "$response" steht der Rückgabestring.
    Gruß NetFritz
    KNX & Wago 750-849 ,Wiregate u. Cometvisu, iPad 3G 64GB.
    WP Alpha-Innotec WWC130HX (RS232-Moxa-LAN),Solaranlage für Brauchwasser und Heizung.
    PV-Anlage = SMA Webbox2.0 , SunnyBoy 4000TL, Sharp 4kWP

    Kommentar


      #17
      Zitat von NetFritz Beitrag anzeigen
      Von Perl aus kann man hinter den Scriptaufruf mit Post oder Get was übergeben.
      Wie macht man das?

      /Per

      Kommentar


        #18
        Hallo
        Google ist dein Freund.

        PHP-Scriptaufruf in Perl
        Code:
        [B]script.php?Inhalt=Claudia[/B]
        und im PHP-Script.
        Code:
        <?php echo $_POST["Inhalt"]; ?>
        oder
        Code:
        <?php $inhalt = $_POST["Inhalt"]; ?>
        dann steht in Variable $inhalt = Claudia.
        Gruß NetFritz
        KNX & Wago 750-849 ,Wiregate u. Cometvisu, iPad 3G 64GB.
        WP Alpha-Innotec WWC130HX (RS232-Moxa-LAN),Solaranlage für Brauchwasser und Heizung.
        PV-Anlage = SMA Webbox2.0 , SunnyBoy 4000TL, Sharp 4kWP

        Kommentar


          #19
          Zitat von perf Beitrag anzeigen
          Gelingt es dir dann auch, Parameter zwischen Perl und php zu austauschen?
          Klar,

          Code:
            my @response = qx(/usr/bin/php /opt/misterhouse/code/PHPSonos.php player=$_player command=$_command value=$_value );
            my $line; my $stringA; my $stringB; my $stringC; my %_HoH = ();
             foreach $line (@response) {
                if (index($line,"=> Array") > 0) {
                   $stringA = substr($line,index($line,"[")+1,index($line,"]")-index($line,"[")-1);
                } elsif (index($line,"=> ") > 0) {
                   $line = substr($line,0,index($line,"/n"));
                   $stringB = substr($line,index($line,"[")+1,index($line,"]")-index($line,"[")-1);
                   $stringC = substr($line,index($line,"=> ")+3,);
                   $_HoH{$stringA}{$stringB} = $stringC;
                }
             }
          Wie von NetFritz bereits geschrieben, steht auf @response das was von dem PHP-script zurück gegeben wird, in meinem Fall ein mehrdimensionales Array, dass ich dann in der foreach Schleife auf ein Hash schreibe. Dieses Hash enthält für alle Sonos Player alle Werte (Lautstärke, aktuelles Lied, Status, Playlist, etc.)

          Das aufgerufene PHP script enthält dann z.B.
          PHP-Code:
          //* ***************************** SONOS STATUS UPDATE ****************************************

          if (strcmp($_SONOS["command"], 'SonosStatusUpdate()') == 0) {
              
          $ret $sonos->GetMediaInfo();
                  
          $_SONOS array_merge($_SONOS$ret);
                  if (isset(
          $ret['title'])) {

                  
          $_SONOS array_merge($_SONOS, array("RadioStation" => $ret['title']));
                      } else {
                  
          $_SONOS array_merge($_SONOS, array("RadioStation" => ""));
                  }

              
          $ret $sonos->GetTransportInfo(); 
                  
          $_SONOS array_merge($_SONOS, array("PlayerStatus" => $PlayerStatus[$ret]));
              
          $ret $sonos->GetVolume();

                  
          $_SONOS array_merge($_SONOS, array("Volume" => $ret));
              
          $_SONOS2[$iplayer] = $_SONOS;
          }
          print_r($_SONOS2); 
          Gruß,
          Marc

          Kommentar


            #20
            Toll, vielen Dank, aggie und NetFritz!

            Jetzt wird es mir gelingen, von CometVisu oder von einem KNX-Taster aus meinem Sonos-System zu kontrollieren.

            Der letzte Schritt ist nun, Status-Info ins Cometvisu zu bringen. Ich frage im CometVisu-Forum danach.

            /Per

            Kommentar

            Lädt...
            X