Modul für aktuelle LG-TVs?

Begonnen von oxident, 09 September 2013, 21:38:33

Vorheriges Thema - Nächstes Thema

HolyMoly

Also die IP darf auf jeden fall nicht wechseln, sonst müsste man neu definen.
Fritzbox immer die gleiche Ip verwenden hat bei mir gereicht.
Wirf mal noch das verbose attribut raus (das loglevel drinlassen)
und probiers mal mit diesem commando
set myTV power_off

FHEM auf Raspi2 & Radxa Rock

Franz Tenbrock

#76
Hallo
alles so gemacht. TV hängt jetzt sauber im Netz.
attr verbose inaktiviert
dann das Kommando
dann leider wieder tschüss

hab telnet parallel laufen daher geht das starten dann wenistens ganz leicht

Hier Auszug auf logfile
2014.03.18 18:39:12 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.32:8080/hdcp/api/auth

2014.03.18 18:39:12 0: LGTV2011: Authorization successful

2014.03.18 18:39:12 0: LGTV2011: TV Response :
cubi3, Cul 868, ESA2000WZ, EM1000GZ,  FS20, dashboard, 1-Wire, Max Thermos, Max Wandthermo, Max Lan, Fritzbox callmonitor, , nanocul, HM Led16, HM Bewegungsmelder, HM Schalter, RPi, banana, ESP8266, DoorPi

der-Lolo

und auf der telnet konsole? bekommst du da keine fehler angezeigt?

Franz Tenbrock

da hab ich was, lief zum Glück nebenher

185, <$fh> line 3.
"my" variable $name masks earlier declaration in same scope at ./FHEM/82_LGTV201                                                      1.pm line 217, <$fh> line 1088.
Use of uninitialized value $data{"raw_total"} in concatenation (.) or string at                                                       (eval 49) line 1.
Use of uninitialized value $data{"raw_total"} in concatenation (.) or string at                                                       (eval 52) line 1.
Use of uninitialized value $data{"raw_total"} in concatenation (.) or string at                                                       (eval 75) line 1.
Use of uninitialized value $data{"raw_total"} in concatenation (.) or string at                                                       (eval 78) line 1.
cubi3, Cul 868, ESA2000WZ, EM1000GZ,  FS20, dashboard, 1-Wire, Max Thermos, Max Wandthermo, Max Lan, Fritzbox callmonitor, , nanocul, HM Led16, HM Bewegungsmelder, HM Schalter, RPi, banana, ESP8266, DoorPi

HolyMoly

Kannst du bitte mal alle logs seit dem define posten?
FHEM auf Raspi2 & Radxa Rock

Franz Tenbrock

Hier sind die Logs

zwischendurch hatte ich auch mal die 2012 ...pm   versucht

g
2014.03.17 21:49:31 2: LGTV2011: Please pair your tv
2014.03.17 21:49:31 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 22:04:02 2: LGTV2011: Please pair your tv
2014.03.17 22:04:02 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 22:10:48 2: LGTV2011: Please pair your tv
2014.03.17 22:10:48 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 22:38:29 2: LGTV2011: Please pair your tv
2014.03.17 22:38:29 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 22:51:20 2: LGTV2011: Please pair your tv
2014.03.17 22:51:20 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 22:52:32 2: LGTV2011: Please pair your tv
2014.03.17 22:52:32 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 22:57:08 2: LGTV2011: Please pair your tv
2014.03.17 22:57:08 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 23:05:42 2: LGTV2011: Please pair your tv
2014.03.17 23:05:42 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.17 23:13:12 2: LGTV2011: Please pair your tv
2014.03.17 23:13:12 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.18 12:42:17 2: LGTV2011: Please pair your tv
2014.03.18 12:42:17 2: LGTV2011: Created new device myTV 192.168.178.80:8080
22014.03.18 12:56:29 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.80:8080/hdcp/api/auth

2014.03.18 12:56:29 0: LGTV2011: Authorization successful

2014.03.18 12:56:29 0: LGTV2011: TV Response :

2014.03.18 12:56:52 2: LGTV2011: Please pair your tv
2014.03.18 12:56:52 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.18 15:14:52 2: LGTV2011: Please pair your tv
2014.03.18 15:14:52 2: LGTV2011: Created new device myTV 192.168.178.80:8080
2014.03.18 15:21:16 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.80:8080/hdcp/api/auth

2014.03.18 15:21:19 0: LGTV2011: Authorization not successful

2014.03.18 15:21:19 0: LGTV2011: TV Response :Can't connect to 192.168.178.80:8080 (No route to host)

LWP::Protocol::http::Socket: connect: No route to host at /var/InternerSpeicher/fhem/lib/perl5/site_perl/5.12.2/LWP/Protocol/http.pm line 51.


2014.03.18 15:21:19 0: LGTV2011: Now sending command 1

2014.03.18 15:21:19 0: LGTV2011: HandleInput <?xml version="1.0" encoding="utf-8"?><command><session></session><type>HandleKeyInput</type><value>1</value></command>

2014.03.18 15:21:22 0: LGTV2011: Could not send command

2014.03.18 15:21:22 0: LGTV2011: TV Response :Can't connect to 192.168.178.80:8080 (No route to host)

LWP::Protocol::http::Socket: connect: No route to host at /var/InternerSpeicher/fhem/lib/perl5/site_perl/5.12.2/LWP/Protocol/http.pm line 51.


2014.03.18 15:21:33 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.80:8080/hdcp/api/auth

2014.03.18 15:21:36 0: LGTV2011: Authorization not successful

2014.03.18 15:21:36 0: LGTV2011: TV Response :Can't connect to 192.168.178.80:8080 (No route to host)

LWP::Protocol::http::Socket: connect: No route to host at /var/InternerSpeicher/fhem/lib/perl5/site_perl/5.12.2/LWP/Protocol/http.pm line 51.


2014.03.18 15:21:36 0: LGTV2011: Now sending command 1

2014.03.18 15:21:36 0: LGTV2011: HandleInput <?xml version="1.0" encoding="utf-8"?><command><session></session><type>HandleKeyInput</type><value>1</value></command>

2014.03.18 15:21:39 0: LGTV2011: Could not send command

2014.03.18 15:21:39 0: LGTV2011: TV Response :Can't connect to 192.168.178.80:8080 (No route to host)

LWP::Protocol::http::Socket: connect: No route to host at /var/InternerSpeicher/fhem/lib/perl5/site_perl/5.12.2/LWP/Protocol/http.pm line 51.


2014.03.18 15:22:03 0: LGTV2011: Created new device myTV 192.168.178.32:8080
2014.03.18 15:22:12 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.32:8080/hdcp/api/auth

2014.03.18 15:22:12 0: LGTV2011: Authorization successful

2014.03.18 15:22:13 0: LGTV2011: TV Response :

2014.03.18 15:22:26 1: Including fhem.cfg
20142014.03.18 15:22:39 2: LGTV2011: Please pair your tv
2014.03.18 15:22:39 2: LGTV2011: Created new device myTV 192.168.178.80:8080
20142014.03.18 15:26:56 2: LGTV2011: Please pair your tv
2014.03.18 15:26:56 2: LGTV2011: Created new device myTV 192.168.178.32:8080

2014.03.18 15:29:29 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.32:8080/hdcp/api/auth

2014.03.18 15:29:29 0: LGTV2011: Authorization successful

2014.03.18 15:29:29 0: LGTV2011: TV Response :


2014.03.18 15:30:04 2: LGTV2011: Please pair your tv
2014.03.18 15:30:04 2: LGTV2011: Created new device myTV 192.168.178.32:8080

2014.03.18 15:39:30 2: LGTV2012: Created new device myTV 192.168.178.32:8080
2014.03.18 15:40:09 2: LGTV2012: Created new device myTV 192.168.178.32:8080
2014.03.18 15:40:57 2: LGTV2012: Created new device myTV 192.168.178.32:8080
2014.03.18 15:41:40 0: LGTV2012: Pairing request with key SMPUNA at http://192.168.178.32:8080/udap/api/pairing

2014.03.18 15:41:40 0: LGTV2012: HTTP/1.1 400 Bad Request, the command format is not valid or it has an incorrect value.

2014.03.18 15:41:40 0: LGTV2012: Could not send pairing request

2014.03.18 15:41:41 0: LGTV2012: TV Response :

2014.03.18 15:41:41 0: LGTV2012: Now sending command 410

2014.03.18 15:41:41 0: LGTV2012: HandleInput <?xml version="1.0" encoding="utf-8"?><envelope><api type="command"><name>HandleKeyInput</name><value>410</value></api></envelope>

2014.03.18 15:41:41 0: LGTV2012: HTTP/1.1 400 Bad Request, the command format is not valid or it has an incorrect value.

2014.03.18 15:41:41 0: LGTV2012: Could not send command

2014.03.18 15:41:41 0: LGTV2012: TV Response :

2014.03.18 15:43:27 2: LGTV2011: Please pair your tv
2014.03.18 15:43:27 2: LGTV2011: Created new device myTV 192.168.178.32:8080
2014.03.18 15:45:10 0: LGTV2011: Displaying pairing code at http://192.168.178.32:8080/hdcp/api/auth

2014.03.18 15:45:10 0: LGTV2011: Displaying pairing code successful

2014.03.18 15:46:20 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.32:8080/hdcp/api/auth

2014.03.18 15:46:20 0: LGTV2011: Authorization successful

2014.03.18 15:46:20 0: LGTV2011: TV Response :
2014.03.18 15:46:53 2: LGTV2011: Please pair your tv
2014.03.18 15:46:53 2: LGTV2011: Created new device myTV 192.168.178.32:8080
2014.03.18 18:38:42 2: LGTV2011: Please pair your tv
2014.03.18 18:38:42 2: LGTV2011: Created new device myTV 192.168.178.32:8080
2014.03.18 18:39:12 0: LGTV2011: Session request with key SMPUNA at http://192.168.178.32:8080/hdcp/api/auth

2014.03.18 18:39:12 0: LGTV2011: Authorization successful

2014.03.18 18:39:12 0: LGTV2011: TV Response :

2014.03.18 18:39:52 1: Including fhem.cfg
2014.03.18 18:40:01 2: LGTV2011: Please pair your tv
2014.03.18 18:40:01 2: LGTV2011: Created new device myTV 192.168.178.32:8080
cubi3, Cul 868, ESA2000WZ, EM1000GZ,  FS20, dashboard, 1-Wire, Max Thermos, Max Wandthermo, Max Lan, Fritzbox callmonitor, , nanocul, HM Led16, HM Bewegungsmelder, HM Schalter, RPi, banana, ESP8266, DoorPi

rainer1962

vielleicht kan ich mich mal kurz einklinken in die diskussion ...
ich habe auch das 2011er probiert und muss sagen dass irgendwie ein perl-modul warscheinlich nicht richtig funktioniert.
Ich bekomme es aber auf meiner synology 412+ nicht gebacken ... :-(
Irgendwie werden die daten vergessen welche in ($hash) stehen ...

Vielleicht kann holy den fehler noch finden ...
ein PHP-Mudul funktioniert hervorragend:

-------- php-modul ------------
<html>
<body>
<?php
global $paringkey;

$lgip = "192.168.25.20"; // LG Netzwerk IP
if ($paringkey == "") {$paringkey = $_POST["paring"];}
?>

<table border="0">

  <tr>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="3">
<input type="submit" value="Leise">
</form></td>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="2">
<input type="submit" value="Laut">
</form></td>

  </tr>
  <tr>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="1">
<input type="submit" value="Kanal -">
</form></td>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="0">
<input type="submit" value="Kanal +">
</form></td>
<tr>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="9">
<input type="submit" value="Stumm">
</form></td>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="23">
<input type="submit" value="Exit">
</form></td>
  </tr>
<tr>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="22">
<input type="submit" value="Settings">
</form></td>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="21">
<input type="submit" value="Home">
</form></td>
  </tr>
 
   <tr>
    <td><form action="" method="post">
<input type="hidden"  name="cmd" value="1">
<input type="submit" value="Aus">
</form></td>
    <td></td>
  </tr>
 
</table>

<p>Login2LG!:</p>
<form action="" method="post">
<input type="password"  name="paring" value="<?php echo $_COOKIE["paring"];?>">
<input type="submit" value="Paringkey">

<input type="hidden"  name="session" value="session">

</form>

<?php
if (isset($_POST["paring"]) and $_POST["paring"] == "")
//if ($paringkey=="")
{
    auth("<auth><type>AuthKeyReq</type></auth>",$lgip); //paring
echo "test";
/*auth ('<?xml version="1.0" encoding="utf-8" ?><envelope><api type="pairing"><name>showKey</name></api></envelope>',$lgip);
*/
}
if (isset($_POST["paring"]) and $_POST["paring"] != "")
{
echo "hier gesetzt $paringkey";
    $sess=auth("<auth><type>AuthReq</type><value>".$paringkey."</value></auth>",$lgip);


/*auth('<?xml version="1.0" encoding="utf-8"?><envelope><api type="pairing"><name>hello</name><value>'.$paringkey.'</value><port>8080</port></api></envelope>',$lgip);
*/
echo "Session: $sess";
        setcookie("paring", $_POST["paring"]);
        setcookie("sess", $sess);
   
    }
if (isset($_POST["cmd"]) )
{
    lgcommand("<?xml version='1.0' encoding='utf-8'?><command><session>".$_COOKIE["sess"]."</session><type>HandleKeyInput</type><value>".$_POST["cmd"]."</value></command>",$lgip);
    }   


function auth($data,$lgip)
{
$sock = fsockopen($lgip, 8080);
fputs($sock, "POST /hdcp/api/auth HTTP/1.1\r\n");

fputs($sock, "Host: ".$lgip."\r\n");
fputs($sock, "Content-type: application/atom+xml\r\n");
fputs($sock, "Content-length: ". strlen($data) ."\r\n");
fputs($sock, "Connection: close\r\n\r\n");
fputs($sock, $data);

while(!feof($sock))
$bla = fgets($sock, 4096);
fclose($sock);
preg_match('/(<session>)(.*?)(<\/session>)/i',  $bla , $match);
if (strlen($match[2]) > 4){
echo "Paring OK - ".$match[2];}
else
{ echo "Paring Not OK";}

echo "RET:".$match[2];
return $match[2];
}

function lgcommand($data,$lgip)

{
$sock = fsockopen($lgip, 8080);
fputs($sock, "POST /hdcp/api/dtv_wifirc HTTP/1.1\r\n");
fputs($sock, "Host: ".$lgip."\r\n");
fputs($sock, "Content-type: application/atom+xml\r\n");
fputs($sock, "Content-length: ". strlen($data) ."\r\n");
fputs($sock, "Connection: close\r\n\r\n");
fputs($sock, $data);


while(!feof($sock))
$bla = fgets($sock, 4096);
fclose($sock);

echo $bla;
}


?>

</body>
</html>

----------------------------------

viele grüsse rainer
2xFHEM auf Raspi3,MAXLAN,HMLAN,KeyMatic,MAX Heizung,2x HM-WDS10_TH-O,3xHM-SEC-SD,3xHM Wandtaster 2-Kanal, 2xWandtaster 6-Kanal,1xHM Bewegungsmelder,4xHM EinbauActor,4x Jalousien Actor,2xEGPM2LAN,2xHM DimAktor,2xFritzbox 6840/6490,4-20ma Levelsensor-Ina219,PIP5048,Raspi2 als Floorplan,4xJeeLink

Franz Tenbrock

#82
es klappt dank der Hilfe  8) :)
denke die Erklärung kommt noch, habe gerade gehört morgen eine geänderte 2011 pm

das hier hilft wohl weiter

http://www.fhemwiki.de/wiki/Unicode_FritzBox

zumindest auf der Fritz

Die Datei Heavy.pl muss im Ordner unicore kopiert werden
bei mir fehlte der Ganze Ordner..
oder im zip der gesamte Ordner

im Link oben auch alles erklärt
wer also ein LG 2011 hat kann nun alles auch über fhem und fritz steuern.....
cubi3, Cul 868, ESA2000WZ, EM1000GZ,  FS20, dashboard, 1-Wire, Max Thermos, Max Wandthermo, Max Lan, Fritzbox callmonitor, , nanocul, HM Led16, HM Bewegungsmelder, HM Schalter, RPi, banana, ESP8266, DoorPi

Franz Tenbrock

#83
das hab ich auf die schnelle schon mal hinbekommen,
für das schnelle schalten aus dem Dashboard  ;D

der code:
define myTV LGTV2011 192.168.178.32
attr myTV loglevel 0
attr myTV pairingcode SMPUNA
attr myTV room 1Test
attr myTV webCmd channel_up:channel_down:channel_back


die letzte Zeile ermöglicht mir das hier was sicher schnell ausbaubar ist
wenn man die wichtigste Kommandos ins Dashboard packt kann man schnell mal schalten wenn man was in fhem macht..

so siehts aus:


so weiter gehts:
so sollte es aussehen:


hier der code , leider nochmit fehler drin, irgenwie muss ich das mit myTV verbinden....
define myTV LGTV2011 192.168.178.32
attr myTV loglevel 0
attr myTV pairingcode SMPUNA
attr myTV room 1Test


define TV_Menue dummy
attr TV_Menue room 1Test
attr TV_Menue webCmd channel_up:channel_down:channel_back:volume_up:volume_down:mute:exit_cmd

define TV_Programm dummy
attr TV_Programm room 1Test
attr TV_Programm webCmd one:two:three:four:fiv:six:seven:eight:nine:one zero

cubi3, Cul 868, ESA2000WZ, EM1000GZ,  FS20, dashboard, 1-Wire, Max Thermos, Max Wandthermo, Max Lan, Fritzbox callmonitor, , nanocul, HM Led16, HM Bewegungsmelder, HM Schalter, RPi, banana, ESP8266, DoorPi

HolyMoly

Hallo Rainer,

sind bei dir auf der Synology die Perl Bibliotheken

use LWP::UserAgent;
use HTTP::Request::Common;
use XML::Simple;

installiert?
FHEM auf Raspi2 & Radxa Rock

siggi85

@Franz Tenbrock:
Statt der WebCmds wäre das remotecontrol Modul sicher was für dich.

FHEM Wiki remotecontrol

Sobald mein TV eingebunden ist, werde ich mir auch eine kleine Fernbedienung bauen. Für meine XBMC Instanzen nutze ich das schon und funktioniert super! :)

rainer1962

ja Holy, sonst würde ja perl wegen fehlender Bibliotheken meckern ...
Aber ich habe einen Erfolg zu verzeichnen:
Habe mal mit dem LG2012 Modul experimentiert und die entsprechenden Pfade und XML-Texte abgeändert . Und siehe da - es funktioniert mit dem 2012er Modul.
Zudem habe ich noch die Befehle (%sets) angepasst an meinen 42LW470S.
Es funzt hervorragend ...
Irgendetwas funzt da in dem 2011er Modul nicht richtig ....

Zudem musste ich noch bei dem 2012 die Session mitschicken wenn ich einen Befehl absende.
Im Anhang die geänderte Datei....

Einen Effekt habe ich noch ...
Ich trage ja den Pairingcode in die FHEM.cfg ein. Dieser wird aber nicht abgearbeitet (Zeitproblem?) Ich muss extra nach dem Anlegen des Devices den Pairingbefehl senden, dann wird auch gepaired ..

Gruss Rainer und danke fürs geile Modul...
2xFHEM auf Raspi3,MAXLAN,HMLAN,KeyMatic,MAX Heizung,2x HM-WDS10_TH-O,3xHM-SEC-SD,3xHM Wandtaster 2-Kanal, 2xWandtaster 6-Kanal,1xHM Bewegungsmelder,4xHM EinbauActor,4x Jalousien Actor,2xEGPM2LAN,2xHM DimAktor,2xFritzbox 6840/6490,4-20ma Levelsensor-Ina219,PIP5048,Raspi2 als Floorplan,4xJeeLink

rainer1962

Hallo Siggi,
Fernbedienung ist ja ok, aber ich möchte gern den Fernseher zB. so steuern , dass bei Anrufen Stumm geschaltet wird.
Und da brauche ich ja ersteinmal die Connection zum Fernseher ...

Gruss Rainer
2xFHEM auf Raspi3,MAXLAN,HMLAN,KeyMatic,MAX Heizung,2x HM-WDS10_TH-O,3xHM-SEC-SD,3xHM Wandtaster 2-Kanal, 2xWandtaster 6-Kanal,1xHM Bewegungsmelder,4xHM EinbauActor,4x Jalousien Actor,2xEGPM2LAN,2xHM DimAktor,2xFritzbox 6840/6490,4-20ma Levelsensor-Ina219,PIP5048,Raspi2 als Floorplan,4xJeeLink

siggi85

Zitat von: rainer1962 am 19 März 2014, 08:08:09
Fernbedienung ist ja ok, aber ich möchte gern den Fernseher zB. so steuern , dass bei Anrufen Stumm geschaltet wird.
Und da brauche ich ja ersteinmal die Connection zum Fernseher ...

Diverse Automationen kommen natürlich dazu! ;) Ich zum Beispiel möchte anhand von Readings gerne den aktiven HDMI Port ermitteln. Dann kann ich darüber bestimmen, welche meiner Harmony Activities gerade aktiv ist und auf welches Gerät (HTPC, Coolstream, BR PLayer, etc) ich Nachrichten oder TTS Output senden kann.
Oder auf welchem Gerät jetzt der nächte Befehl (Stop, Kanal 2, Stumm,...) gesendet werden soll. In Kombination mit meiner geplanten Raumerkennung über das PRESENCE Modul, brauche ich dann nur noch einen STOP Knopf, und je nach Raum in dem ich mich befinde, und je nach Gerät welches gerade auf dem Fernseher aktiv ist, wird die aktuelle Wiedergabe gestoppt. Die Möglichkeiten hierbei gehen dann natürlich immer weiter... ;)
Ich wollte nur Franz das Modul remotecontrol näher bringen, weil ich WebCmds relativ unpraktisch für den "täglichen Betrieb" finde. Ich nutze sie nur zum Testen und in eigenen Betaphasen bevor ich eine remotecontrol baue.  :)

Franz Tenbrock

#89
@siggi85

genau das hatte ich auch gesucht, aber nciht gefunden ,
FHEM wird ja jeden Tag umfangreicher und es ist manchmal schwierig das passende zu finden.
Dank der Hilfe hier im Forum geht es einfach viel schneller.

Aber mittlerweile finde ich ja auch selbst Möglcihkeiten das eine oder andere zu machen, wenn auch nicht so elegant, aber auch das wird immer besser :-)

werde heute Abend? mal versuchen das zu realisieren und dann den Code posten.

Hat einer Erfahrung ob man das dann auch ins Dashboard packen kann ?
Gerade das Wiki gelesen, na das wird ja wieder ein größeres Projekt >:(
cubi3, Cul 868, ESA2000WZ, EM1000GZ,  FS20, dashboard, 1-Wire, Max Thermos, Max Wandthermo, Max Lan, Fritzbox callmonitor, , nanocul, HM Led16, HM Bewegungsmelder, HM Schalter, RPi, banana, ESP8266, DoorPi