Fhem -> Onkyo

Begonnen von mcbain2k, 03 Juni 2013, 22:40:05

Vorheriges Thema - Nächstes Thema

mcbain2k

So hier wieder mal was neues.

einmal das pearscript onkyo.pl
IP bitte anpassen.

#!/usr/bin/perl -w
#
use IO::Socket;
my ($host, $port);
$host =  '192.168.xx.xx';
$port = '60128';

# command-line help
#
if ($ARGV[0] eq "--help") {
   print "Usage: onkyoremote KEY [KEYS]\n";
   print "Normal remote keys:
   PWR01 = ON   | PWR00 = OFF
   SLI02 = GAME | SLI05 = PC | SLI10 = BD-DVD
   SLI23 = TV
   MVLUP = MainVolUp   | MVLDOWN = MainVolDown
   MVL30 = MainVol30 00-50 (max)
   \n";
   exit;
}

my($cmd,$line,$length,$code,$in);
$in = join(' ', @ARGV);
$cmd="!1".$in;
$length=length($cmd)+1;
$code =chr($length);

# setup the string we are sending ...
$line  = "ISCP\x00\x00\x00\x10\x00\x00\x00$code\x01\x00\x00\x00".$cmd."\x0D";

my $sock = new IO::Socket::INET(
                   PeerAddr => $host,
                   PeerPort => $port,
                   Proto    => 'tcp',
                   );
die "Could not create socket: $!\n" unless $sock;
        # send it !
        print $sock $line;
close($sock);


Hier der Aufruf in fhem


define PWR01_Onkyo dummy
attr PWR01_Onkyo room Onkyo_System
attr PWR01_Onkyo setList on off
attr PWR01_Onkyo webCmd on:off

define PWR01_Onkyo_notify notify (PWR01_Onkyo:on) {\
{fhem("set PWR01_Onkyo off")}\
{system('/usr/share/fhem/FHEM/script/onkyo.pl PWR01&');;}\
}
attr PWR01_Onkyo_notify room Onkyo_System


Es gibt sehr viele mögliche Kommandos, muss noch überlegen wie die hier poste.

mcbain2k

Komplette Übersicht befindet sich im Anhang

Hier mal das wichtigste:


Code Means
"PWR" - System Power Command  
"00" sets System Standby
"01" sets System On
"QSTN" gets the System Power Status
"AMT" - Audio Muting Command
"00" sets Audio Muting Off
"01" sets Audio Muting On
"TG" sets Audio Muting Wrap-Around
"QSTN" gets the Audio Muting State
"SPA"/"SPB" - Speaker A/B Command
"00" sets Speaker Off
"01" sets Speaker On
"UP" sets Speaker Switch Wrap-Around
"QSTN" gets the Speaker State
*1:SPA=MAIN A/SPB=MAIN B
*2:SPA=Front A/SPB=Front B(Exclucive use)
"SPL" - Speaker Layout Command
"SB" sets SurrBack Speaker
"FH" sets Front High Speaker / SurrBack+Front High Speakers
"FW" sets Front Wide Speaker / SurrBack+Front Wide Speakers
"HW" sets                                   Front High+Front Wide Speakers
"UP" sets Speaker Switch Wrap-Around
"QSTN" gets the Speaker State
"MVL" - Master Volume Command
"00"-"64" Volume Level 0  100 ( In hexadecimal representation)
"00"-"50" Volume Level 0  80 ( In hexadecimal representation)
"UP" sets Volume Level Up
"DOWN" sets Volume Level Down
"UP1" sets Volume Level Up 1dB Step
"DOWN1" sets Volume Level Down 1dB Step
"QSTN" gets the Volume Level
"TFR" - Tone(Front) Command
"Bxx" Front Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"Txx" Front Treble (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Front Bass up(2 step)
"BDOWN" sets Front Bass down(2 step)
"TUP" sets Front Treble up(2 step)
"TDOWN" sets Front Treble down(2 step)
"QSTN" gets Front Tone ("BxxTxx")
"TFW" - Tone(Front Wide) Command
"Bxx" Front Wide Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"Txx" Front Wide Treble (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Front Wide Bass up(2 step)
"BDOWN" sets Front Wide Bass down(2 step)
"TUP" sets Front Wide Treble up(2 step)
"TDOWN" sets Front Wide Treble down(2 step)
"QSTN" gets Front Wide Tone ("BxxTxx")
"TFH" - Tone(Front High) Command
"Bxx" Front High Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"Txx" Front High Treble (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Front High Bass up(2 step)
"BDOWN" sets Front High Bass down(2 step)
"TUP" sets Front High Treble up(2 step)
"TDOWN" sets Front High Treble down(2 step)
"QSTN" gets Front High Tone ("BxxTxx")
"TCT" - Tone(Center) Command
"Bxx" Center Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"Txx" Center Treble (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Center Bass up(2 step)
"BDOWN" sets Center Bass down(2 step)
"TUP" sets Center Treble up(2 step)
"TDOWN" sets Center Treble down(2 step)
"QSTN" gets Cetner Tone ("BxxTxx")
"TSR" - Tone(Surround) Command
"Bxx" Surround Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"Txx" Surround Treble (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Surround Bass up(2 step)
"BDOWN" sets Surround Bass down(2 step)
"TUP" sets Surround Treble up(2 step)
"TDOWN" sets Surround Treble down(2 step)
"QSTN" gets Surround Tone ("BxxTxx")
"TSB" - Tone(Surround Back) Command
"Bxx" Surround Back Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"Txx" Surround Back Treble (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Surround Back Bass up(2 step)
"BDOWN" sets Surround Back Bass down(2 step)
"TUP" sets Surround Back Treble up(2 step)
"TDOWN" sets Surround Back Treble down(2 step)
"QSTN" gets Surround Back Tone ("BxxTxx")
"TSW" - Tone(Subwoofer) Command
"Bxx" Subwoofer Bass (xx is "-A"..."00"..."+A"[-10...0...+10 2 step]
"BUP" sets Subwoofer Bass up(2 step)
"BDOWN" sets Subwoofer Bass down(2 step)
"QSTN" gets Subwoofer Tone ("BxxTxx")

"SLP" - Sleep Set Command
"01"-"5A" sets Sleep Time 1 - 90min ( In hexadecimal representation)
"OFF" sets Sleep Time Off
"UP" sets Sleep Time Wrap-Around UP
"QSTN" gets The Sleep Time
"SLC" - Speaker Level Calibration Command
"TEST" TEST Key
"CHSEL" CH SEL Key
"UP" LEVEL + Key
"DOWN" LEVEL  KEY
"SWL" - Subwoofer (temporary) Level Command
"-F"-"00"-"+C" sets Subwoofer Level -15dB - 0dB - +12dB
"UP" LEVEL + Key
"DOWN" LEVEL  KEY
"QSTN" gets the Subwoofer Level
"CTL" - Center (temporary) Level Command
"-C"-"00"-"+C" sets Center Level -12dB - 0dB - +12dB
"UP" LEVEL + Key
"DOWN" LEVEL  KEY
"QSTN" gets the Subwoofer Level
"DIF" - Display Information Command
"00" Display Program Format
"01" Display Digital Input Position
"02" Display Digital Format Position
"03" Display Bass Level
"04" Display Treble Level
"DIF" - Display Mode Command
"00" sets Selector + Volume Display Mode
"01" sets Selector + Listening Mode Display Mode
"02" Display Digital Format(temporary display)
"03" Display Video Format(temporary display)
"TG" sets Display Mode Wrap-Around Up
"QSTN" gets The Display Mode
*1: Parameter Character is "UP"
"DIM" - Dimmer Level Command
"00" sets Dimmer Level "Bright"
"01" sets Dimmer Level "Dim"
"02" sets Dimmer Level "Dark"
"03" sets Dimmer Level "Shut-Off"
"08" sets Dimmer Level "Bright & LED OFF"
"DIM" sets Dimmer Level Wrap-Around Up
"QSTN" gets The Dimmer Level
"OSD" - Setup Operation Command
"MENU" Menu Key
"UP" Up Key
"DOWN" Down Key
"RIGHT" Right Key
"LEFT" Left Key
"ENTER" Enter Key
"EXIT" Exit Key
"AUDIO" Audio Adjust Key
"VIDEO" Video Adjust Key
"HOME" Home Key
"MEM" - Memory Setup Command
"STR" stores memory
"RCL" recalls memory
"LOCK" locks memory
"UNLK" unlocks memory
"IFA" - Audio Infomation Command
"nnnnn:nnnnn" Infomation of Audio(Same Immediate Display ',' is separator of infomations)
"QSTN" gets Infomation of Audio
when you send "DIF02", receiver will return this response.
"IFV" - Video Infomation Command
"nnnnn:nnnnn" infomation of Video(Same Immediate Display ',' is separator of infomations)
"QSTN" gets Infomation of Video
when you send "DIF03", receiver will return this response.
"SLI" - Input Selector Command
"00" sets VIDEO1    VCR/DVR
"01" sets VIDEO2    CBL/SAT
"02" sets VIDEO3    GAME/TV    GAME
"03" sets VIDEO4    AUX1(AUX)
"04" sets VIDEO5    AUX2
"05" sets VIDEO6    PC
"06" sets VIDEO7
"07" Hidden1
"08" Hidden2
"09" Hidden3
"10" sets DVD          BD/DVD
"20" sets TAPE(1)    TV/TAPE
"21" sets TAPE2
"22" sets PHONO
"23" sets CD    TV/CD
"24" sets FM
"25" sets AM
"26" sets TUNER
"27" sets MUSIC SERVER    P4S   DLNA*2
"28" sets INTERNET RADIO           iRadio Favorite*3
"29" sets USB/USB(Front)
"2A" sets USB(Rear)
"2B" sets NETWORK                      NET
"2C" sets USB(toggle)
"40" sets Universal PORT
"30" sets MULTI CH
"31" sets XM*1
"32" sets SIRIUS*1
"UP" sets Selector Position Wrap-Around Up
"DOWN" sets Selector Position Wrap-Around Down
"QSTN" gets The Selector Position
*1:Only available XM/SIRIUS Model


mcbain2k

Natürlich lässt sich das ganze in die 99_Utils integrieren,

wie Uli das mit dem SamsungTV-Script so super umgesetzt hat.

Gute Nacht
 McBain
 


BenWend

Hallo McBain,

das ist genau das, was ich gesucht habe. Perfekt! FHEM spricht TCP/IP jetzt also auch mit Onkyos :o)

Könntest Du für einen Neuling wie mich bitte noch posten, wie ich das Script in die 99_Utils.pm einbinde und wie in diesem Fall der entsprechende Schnipsel in der fhem.cfg aussehen würde?

Vielen Dank, für diesen super Codeschnipsel und Deine tolle Arbeit!!!

UliM

Zitat von: mcbain2k schrieb am Mo, 03 Juni 2013 22:51Natürlich lässt sich das ganze in die 99_Utils integrieren,
hi,
jepp, das geht natürlich.

mir kommt grad der Gedanke, das man ja auch die 'grafische' remote entsprechend verwenden könnte.
Dazu müsste man nur den Routinen-Namen, der aufgerufen wird, entsprechend anpassen. und die Buttons entsprechend konfigurieren - dazu bräuchte man dann wiederum die poassenden icon-Dateien.

Sollen wir sowas mal angehen?

=8-)
RPi4/Raspbian, CUL V3 (ca. 30 HomeMatic-devices), LAN (HarmonyHub, alexa etc.).  Fördermitglied des FHEM e.V.

Puschel74

Hallo,

ich würde das ganze aber nicht in 99_myUtils.pm integrieren sondern eine 99_Onkyo.pm draus machen.
Nur mal so als Gedankenstoss.

Grüße
Zotac BI323 als Server mit DBLog
CUNO für FHT80B, 3 HM-Lan per vCCU, RasPi mit CUL433 für Somfy-Rollo (F2F), RasPi mit I2C(LM75) (F2F), RasPi für Panstamp+Vegetronix +SONOS(F2F)
Ich beantworte keine Supportanfragen per PM! Bitte im Forum suchen oder einen Beitrag erstellen.

BenWend

Hallo McBain,

das Perl-Script läuft wunderbar.

Mit dem Aufruf aus fhem hat es bei mir jedoch nicht auf Anhieb geklappt. Hiermit ging es dann aber:

define PWR01_Onkyo dummy
attr PWR01_Onkyo room Onkyo_System
attr PWR01_Onkyo setList on off
attr PWR01_Onkyo webCmd on:off

define Onkyo_on notify PWR01_Onkyo:on.* {system("perl /opt/fhem/FHEM/onkyo.pl PWR01");;}

define Onkyo_off notify PWR01_Onkyo:off.* {system("perl /opt/fhem/FHEM/onkyo.pl PWR00");;}


Nochmal vielen Dank und schöne Grüße

Ben


Predictor

Zitat von: UliM schrieb am Di, 04 Juni 2013 13:31
Zitat von: mcbain2k schrieb am Mo, 03 Juni 2013 22:51Natürlich lässt sich das ganze in die 99_Utils integrieren,
hi,
jepp, das geht natürlich.

mir kommt grad der Gedanke, das man ja auch die 'grafische' remote entsprechend verwenden könnte.
Dazu müsste man nur den Routinen-Namen, der aufgerufen wird, entsprechend anpassen. und die Buttons entsprechend konfigurieren - dazu bräuchte man dann wiederum die poassenden icon-Dateien.

Sollen wir sowas mal angehen?

=8-)


Ich habe mal für die Grafische Umsetzung einer FB einen neuen Thread aufgemacht

Universal Fernbedienung in FHEM


Ich würde mich freuen wenn das was werden würde!!!
FHEM auf Fritz!Box 7390
FS20 per CUL

Patrik

Hallo BenWend,

mit dem define Onkyo_on notify PWR01_Onkyo:on.* {system("perl /opt/fhem/FHEM/onkyo.pl PWR01");;}
habe ich ein Problem. Bei mir läuft FHEM auf einer Synlogy, und das recht gut. Ich habe die
Befehle wie beschrieben in eine cfg-Datei eingefügt, aber die Ausführung funktioniert nicht.

Den Befehl perl /opt/fhem/FHEM/onkyo.pl PWR01 in telnet der Synology eingegeben funktioniert einwandfrei. Onkyo wird eingeschaltet.

Den Befehl {system("perl /opt/fhem/FHEM/onkyo.pl PWR01");;}in telnet von FHEM eingegeben liefert -1 zurück.

Mache ich etwas falsch oder liegt es evtl. an der Synology bzw. deren Rechtvergabe?
Über eine kleine Hilfe würde ich mich sehr freuen.

Gruß
Patrik





BenWend

Hallo Patrik,

leider kenne ich mich mit perl, linux & co. so gut wie gar nicht aus.

Hast Du den kompletten Schnipsel in die fhem.cfg geschrieben? Schalten kannst Du dann mit "set PWR01_Onkyo on" oder über einen entsprechenden Klick auf der FHEM-Oberfläche.

Schöne Grüße

Ben

Icebear

Hi,

hört sich für mich nach nem rechteproblem an ...

ein chmod 755 /opt/fhem/FHEM/onkyo.pl sollte reichen.

falls fhem als benutzer fhem läuft kannste auch ein chown fhem /opt/fhem/FHEM/onkyo.pl machen.

Grüsse aus Wesel
Icebear
Raspberry PI mod B (Wheezy), Fhem 5.4, CUL868, CUL433 , RfxTrx, HM-USB-CFG2, Wlan, HomeEasy, IT, FS20, TFA, HomeMatic, Oregon Scientific, HMLand auf Fritzbox
Raspberry PI mod B (RaspBMC)

Patrik

Sorry für die späte Antwort und Danke für die Hilfe.
Alle Zugriffsrechte sind wie auch bei den anderen Perl-Modulen eingestellt - und es funktioniert doch nicht.
Leider habe ich keine Zeit dem nachzugehen, daher werde ich wohl drauf verzichten müssen.

Danke und Gruß
Patrik

UliM

Hi,
hat schon jemand ein layout für remotecontrol gebaut? Dann bitte hier posten. Ich könnt's dann als Standardlayout ins remotecontrol-Modul aufnehmen.
=8-)


PS: Und man könnte natürlich recht leicht ien Modul draus machen - hab aber keinen Onkyo = keine Motivation
RPi4/Raspbian, CUL V3 (ca. 30 HomeMatic-devices), LAN (HarmonyHub, alexa etc.).  Fördermitglied des FHEM e.V.

Sid-L

Ich hab ein Modul draus gebastelt welches auch die Aktionen mit der Fernbedienung instantan in Fhem verarbeitet, ist aber noch etwas wackelig. Wenn Bedarf besteht setz ich mich nochmal ran und poste es.

bjoernhoefer

Hi,

vielen Dank das Ihr eine Steuerung für Onkyo inkludiert habt...

Ich betreib meinen FHEM Server auf dem RaspberryPi und hab einen kleinen Schönheitsfehler, den ich mir nicht ganz erklären kann.

ich habe die Steuerung wie ganz am Anfang bei mir unter /opt/fhem/FHEM/onkyo.pl am laufen.
#!/usr/bin/perl -w
#
use IO::Socket;
my ($host, $port);
$host =  '192.168.voll.geheim';
$port = '60128';

# command-line help
#
if ($ARGV[0] eq "--help") {
   print "Usage: onkyoremote KEY [KEYS]\n";
   print "Normal remote keys:
   PWR01 = ON   | PWR00 = OFF
   SLI02 = GAME | SLI05 = PC | SLI10 = BD-DVD
   SLI23 = TV
   MVLUP = MainVolUp   | MVLDOWN = MainVolDown
   MVL30 = MainVol30 00-50 (max)
   \n";
   exit;
}

my($cmd,$line,$length,$code,$in);
$in = join(' ', @ARGV);
$cmd="!1".$in;
$length=length($cmd)+1;
$code =chr($length);

# setup the string we are sending ...
$line  = "ISCP\x00\x00\x00\x10\x00\x00\x00$code\x01\x00\x00\x00".$cmd."\x0D";

my $sock = new IO::Socket::INET(
                   PeerAddr => $host,
                   PeerPort => $port,
                   Proto    => 'tcp',
                   );
die "Could not create socket: $!\n" unless $sock;
        # send it !
        print $sock $line;
close($sock);


Aufrufen tu ich es testhalber wie folgt:
define onkyo dummy
attr onkyo room test
attr onkyo setList on off tuner tv bd vol_morning
attr onkyo webCmd on:off:tuner:tv:bd:vol_morning

define onkyo_on notify onkyo:on.* {system("perl /opt/fhem/FHEM/onkyo.pl PWR01");;}
attr onkyo_on room test
define onkyo_off notify onkyo:off.* {system("perl /opt/fhem/FHEM/onkyo.pl PWR00");;}
attr onkyo_off room test
define onkyo_tuner notify onkyo:tuner.* {system("perl /opt/fhem/FHEM/onkyo.pl SLI26");;}
attr onkyo_tuner room test
define onkyo_tv notify onkyo:tv.* {system("perl /opt/fhem/FHEM/onkyo.pl SLI23");;}
attr onkyo_tv room test
define onkyo_bd notify onkyo:bd.* {system("perl /opt/fhem/FHEM/onkyo.pl SLI10");;}
attr onkyo_bd room test
define onkyo_vol_19 notify onkyo:vol_morning.* {system('perl /opt/fhem/FHEM/onkyo.pl MLV19');;}
attr onkyo_vol_19 room test


Leider bekomm ich wie vorher schon erwähnt folgende Fehlermeldungen für jeden notify ins log geschrieben:
onkyo_vol_morning return value: -1
onkyo_bd return value: -1


Komischerweise funktionieren die Befehle auf dem Onkyo Receiver alle (ausser dem vol_morning) - werden also akzeptiert.

Ich habe schon folgendes versucht:
perl /opt/fhem/FHEM/onkyo.pl als root auszuführen - funktioniert ohne Meldung
perl /opt/fhem/FHEM/onkyo.pl als fhem-User auszuführen - funktioniert ohne Meldung
Die Recht und den Besitzer von /opt/fhem/FHEM/onkyo.pl überprüft (-rwxr-xr-x 1 fhem root 930 Jul 17 22:10 FHEM/onkyo.pl) - passt auch
/usr/bin/perl (statt nur perl) /opt/fhem/FHEM/onkyo.pl - funktionert - liefert trotzdem in FHEM "Feedback" ins log

Jetzt bin ich ein wenig ratlos...

Hat irgendwer noch eine Idee, was ich noch probieren könnte?