mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
Log -> Log3 change
git-svn-id: https://svn.fhem.de/fhem/trunk@3799 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fe3018aae8
commit
315d47860f
@ -46,31 +46,32 @@ my ($hash) = @_;
|
|||||||
$hash->{GetFn} = "energy_Get";
|
$hash->{GetFn} = "energy_Get";
|
||||||
$hash->{StateFn} = "energy_State";
|
$hash->{StateFn} = "energy_State";
|
||||||
$hash->{SetFn} = "energy_Set";
|
$hash->{SetFn} = "energy_Set";
|
||||||
$hash->{AttrList} = "loglevel:0,1,2,3,4,5";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
energy_State($$$$)
|
energy_State($$$$)
|
||||||
{
|
{
|
||||||
my ($hash, $tim, $vt, $val) = @_;
|
my ($hash, $tim, $vt, $val) = @_;
|
||||||
Log 4, "time: $tim";
|
#Log 4, "time: $tim";
|
||||||
Log 4, "name: $vt";
|
#Log 4, "name: $vt";
|
||||||
Log 4, "value: $val";
|
#Log 4, "value: $val";
|
||||||
$hash->{READINGS}{$vt}{VAL} = $val;
|
$hash->{READINGS}{$vt}{VAL} = $val;
|
||||||
$hash->{READINGS}{$vt}{TIME} = TimeNow();
|
$hash->{READINGS}{$vt}{TIME} = TimeNow();
|
||||||
Log 4, "$hash->{NAME} VAL: $hash->{READINGS}{$vt}{VAL}";
|
#Log 4, "$hash->{NAME} VAL: $hash->{READINGS}{$vt}{VAL}";
|
||||||
|
Log3 $hash, 4, "time: $tim name: $vt value: $val";
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
sub
|
sub
|
||||||
energy_Set($$$$)
|
energy_Set($$$$)
|
||||||
{
|
{
|
||||||
my ($hash, $tim, $vt, $val) = @_;
|
my ($hash, $tim, $vt, $val) = @_;
|
||||||
Log 4, "time: $tim";
|
#Log 4, "time: $tim";
|
||||||
Log 4, "name: $vt";
|
#Log 4, "name: $vt";
|
||||||
Log 4, "value: $val";
|
#Log 4, "value: $val";
|
||||||
$hash->{READINGS}{$vt}{VAL} = $val;
|
$hash->{READINGS}{$vt}{VAL} = $val;
|
||||||
$hash->{READINGS}{$vt}{TIME} = TimeNow();
|
$hash->{READINGS}{$vt}{TIME} = TimeNow();
|
||||||
Log 4, "$hash->{NAME} VAL: $hash->{READINGS}{$vt}{VAL}";
|
#Log 4, "$hash->{NAME} VAL: $hash->{READINGS}{$vt}{VAL}";
|
||||||
|
Log3 $hash, 4, "time: $tim name: $vt value: $val";
|
||||||
if ( $vt eq "?"){
|
if ( $vt eq "?"){
|
||||||
return "Unknown argument ?, choose one of DAYPOWER MONTHPOWER YEARPOWER TOTALPOWER";
|
return "Unknown argument ?, choose one of DAYPOWER MONTHPOWER YEARPOWER TOTALPOWER";
|
||||||
}
|
}
|
||||||
@ -95,7 +96,8 @@ energy_Define($$)
|
|||||||
$hash->{Interval} = int(@args) >= 5 ? int($args[4]) : 300;
|
$hash->{Interval} = int(@args) >= 5 ? int($args[4]) : 300;
|
||||||
$hash->{Timeout} = int(@args) >= 6 ? int($args[5]) : 4;
|
$hash->{Timeout} = int(@args) >= 6 ? int($args[5]) : 4;
|
||||||
|
|
||||||
Log 4, "$hash->{NAME} will read from SML at $hash->{Host}:$hash->{Port} " ;
|
#Log 4, "$hash->{NAME} will read from SML at $hash->{Host}:$hash->{Port} " ;
|
||||||
|
Log3 $hash, 4, "$hash->{NAME} will read from SML at $hash->{Host}:$hash->{Port} " ;
|
||||||
$hash->{Invalid} = -1; # default value for invalid readings
|
$hash->{Invalid} = -1; # default value for invalid readings
|
||||||
$hash->{Rereads} = 2; # number of retries when reading curPwr of 0
|
$hash->{Rereads} = 2; # number of retries when reading curPwr of 0
|
||||||
$hash->{UseSVTime} = ''; # use the SV time as timestamp (else: TimeNow())
|
$hash->{UseSVTime} = ''; # use the SV time as timestamp (else: TimeNow())
|
||||||
@ -112,9 +114,9 @@ energy_Define($$)
|
|||||||
|
|
||||||
energy_Update($hash);
|
energy_Update($hash);
|
||||||
|
|
||||||
Log 3, "$hash->{NAME} will read from SML at $hash->{Host}:$hash->{Port} " .
|
#Log 3, "$hash->{NAME} will read from SML at $hash->{Host}:$hash->{Port} " .
|
||||||
($hash->{Interval} ? "every $hash->{Interval} seconds" : "for every 'get $hash->{NAME} <key>' request");
|
# ($hash->{Interval} ? "every $hash->{Interval} seconds" : "for every 'get $hash->{NAME} <key>' request");
|
||||||
|
Log3 $hash, 3, "$hash->{NAME} will read from SML at $hash->{Host}:$hash->{Port} " ;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +129,9 @@ energy_Update($)
|
|||||||
InternalTimer(gettimeofday() + $hash->{Interval}, "energy_Update", $hash, 0);
|
InternalTimer(gettimeofday() + $hash->{Interval}, "energy_Update", $hash, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log 4, "$hash->{NAME} tries to contact SML at $hash->{Host}:$hash->{Port}";
|
#Log 4, "$hash->{NAME} tries to contact SML at $hash->{Host}:$hash->{Port}";
|
||||||
|
Log3 $hash, 4, "$hash->{NAME} tries to contact SML at $hash->{Host}:$hash->{Port}";
|
||||||
|
|
||||||
my $success = 0;
|
my $success = 0;
|
||||||
my %readings = ();
|
my %readings = ();
|
||||||
my $timenow = TimeNow();
|
my $timenow = TimeNow();
|
||||||
@ -150,8 +153,8 @@ energy_Update($)
|
|||||||
my $max = 0;
|
my $max = 0;
|
||||||
my $log = "";
|
my $log = "";
|
||||||
|
|
||||||
Log 4, "$hash->{NAME} $url";
|
#Log 4, "$hash->{NAME} $url";
|
||||||
|
Log3 $hash, 4, "$hash->{NAME} $url";
|
||||||
$socket = new IO::Socket::INET (
|
$socket = new IO::Socket::INET (
|
||||||
PeerAddr => $ip,
|
PeerAddr => $ip,
|
||||||
PeerPort => $port,
|
PeerPort => $port,
|
||||||
@ -160,10 +163,10 @@ $socket = new IO::Socket::INET (
|
|||||||
Timeout => $timeout
|
Timeout => $timeout
|
||||||
);
|
);
|
||||||
|
|
||||||
Log 4, "$hash->{NAME} socket new";
|
Log3 $hash, 4, "$hash->{NAME} socket new";
|
||||||
if (defined ($socket) and $socket and $socket->connected())
|
if (defined ($socket) and $socket and $socket->connected())
|
||||||
{
|
{
|
||||||
Log 4, "$hash->{NAME} Connected ...";
|
Log3 $hash, 4, "$hash->{NAME} Connected ...";
|
||||||
print $socket "GET $url HTTP/1.0\r\n\r\n";
|
print $socket "GET $url HTTP/1.0\r\n\r\n";
|
||||||
$socket->autoflush(1);
|
$socket->autoflush(1);
|
||||||
while ((read $socket, $buf, 1024) > 0)
|
while ((read $socket, $buf, 1024) > 0)
|
||||||
@ -172,14 +175,14 @@ if (defined ($socket) and $socket and $socket->connected())
|
|||||||
$message .= $buf;
|
$message .= $buf;
|
||||||
}
|
}
|
||||||
$socket->close();
|
$socket->close();
|
||||||
Log 4, "$hash->{NAME} Socket closed";
|
Log3 $hash, 4, "$hash->{NAME} Socket closed";
|
||||||
|
|
||||||
@array = split(/\n/,$message);
|
@array = split(/\n/,$message);
|
||||||
foreach (@array){
|
foreach (@array){
|
||||||
if ( $_ =~ /<v>(.*)<\/v>/ ){
|
if ( $_ =~ /<v>(.*)<\/v>/ ){
|
||||||
Log 5, "$hash->{NAME} got fresh values from $ip ($1)";
|
Log3 $hash, 5, "$hash->{NAME} got fresh values from $ip ($1)";
|
||||||
if ( $1 eq "NaN" ){
|
if ( $1 eq "NaN" ){
|
||||||
Log 5, "$hash->{NAME} NaN fehler ($1) summary: $summary";
|
Log3 $hash, 5, "$hash->{NAME} NaN fehler ($1) summary: $summary";
|
||||||
}else{
|
}else{
|
||||||
$last = $1;
|
$last = $1;
|
||||||
$counts++ ;
|
$counts++ ;
|
||||||
@ -193,17 +196,17 @@ if (defined ($socket) and $socket and $socket->connected())
|
|||||||
if ( $1 eq "true" )
|
if ( $1 eq "true" )
|
||||||
{
|
{
|
||||||
$success = 1;
|
$success = 1;
|
||||||
Log 4, "$hash->{NAME} error from the $ip ($1)";
|
Log3 $hash, 4, "$hash->{NAME} error from the $ip ($1)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Log 3, "$hash->{NAME} Cannot open socket ...";
|
Log3 $hash, 3, "$hash->{NAME} Cannot open socket ...";
|
||||||
$success = 1;
|
$success = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log 5, "reading done.";
|
Log3 $hash, 5, "reading done.";
|
||||||
if ( $success == 0 and $summary > 0 and $counts > 0)
|
if ( $success == 0 and $summary > 0 and $counts > 0)
|
||||||
{
|
{
|
||||||
$avg = $summary/$counts;
|
$avg = $summary/$counts;
|
||||||
@ -228,16 +231,16 @@ if ( $success == 0 and $summary > 0 and $counts > 0)
|
|||||||
}else{
|
}else{
|
||||||
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{DAYPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{DAYPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
||||||
my ($powLast) = $hash->{READINGS}{DAYPOWER}{VAL} =~ /^(.*)$/;
|
my ($powLast) = $hash->{READINGS}{DAYPOWER}{VAL} =~ /^(.*)$/;
|
||||||
Log 4, "$hash->{NAME} myhour: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} myhour: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
||||||
$hash->{READINGS}{DAYPOWER}{TIME} = $timenow;
|
$hash->{READINGS}{DAYPOWER}{TIME} = $timenow;
|
||||||
if ( $dayLast eq $day ){ # es ist der gleiche Tag
|
if ( $dayLast eq $day ){ # es ist der gleiche Tag
|
||||||
$powLast += $newpower ;
|
$powLast += $newpower ;
|
||||||
$hash->{READINGS}{DAYPOWER}{VAL} = $powLast;
|
$hash->{READINGS}{DAYPOWER}{VAL} = $powLast;
|
||||||
Log 4, "$hash->{NAME} same day timenow: $timenow newpower $newpower powlast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} same day timenow: $timenow newpower $newpower powlast $powLast";
|
||||||
$log .= " day: $powLast";
|
$log .= " day: $powLast";
|
||||||
}else{ # es ist eine Tag vergangen
|
}else{ # es ist eine Tag vergangen
|
||||||
$hash->{READINGS}{DAYPOWER}{VAL} = $newpower;
|
$hash->{READINGS}{DAYPOWER}{VAL} = $newpower;
|
||||||
Log 4, "$hash->{NAME} new day timenow: $timenow newpower $newpower powlast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} new day timenow: $timenow newpower $newpower powlast $powLast";
|
||||||
$log .= " day: $newpower";
|
$log .= " day: $newpower";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,16 +250,16 @@ if ( $success == 0 and $summary > 0 and $counts > 0)
|
|||||||
}else{
|
}else{
|
||||||
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{MONTHPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{MONTHPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
||||||
my ($powLast) = $hash->{READINGS}{MONTHPOWER}{VAL} =~ /^(.*)$/;
|
my ($powLast) = $hash->{READINGS}{MONTHPOWER}{VAL} =~ /^(.*)$/;
|
||||||
Log 4, "$hash->{NAME} myhour: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} myhour: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
||||||
$hash->{READINGS}{MONTHPOWER}{TIME} = $timenow;
|
$hash->{READINGS}{MONTHPOWER}{TIME} = $timenow;
|
||||||
if ( $monthLast eq $month ){ # es ist der gleiche Monat
|
if ( $monthLast eq $month ){ # es ist der gleiche Monat
|
||||||
$powLast += $newpower ;
|
$powLast += $newpower ;
|
||||||
$hash->{READINGS}{MONTHPOWER}{VAL} = $powLast;
|
$hash->{READINGS}{MONTHPOWER}{VAL} = $powLast;
|
||||||
Log 4, "$hash->{NAME} Gleicher Monat timenow: $timenow newpower $newpower powlast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} Gleicher Monat timenow: $timenow newpower $newpower powlast $powLast";
|
||||||
$log .= " month: $powLast";
|
$log .= " month: $powLast";
|
||||||
}else{ # es ist eine Monat vergangen
|
}else{ # es ist eine Monat vergangen
|
||||||
$hash->{READINGS}{MONTHPOWER}{VAL} = $newpower;
|
$hash->{READINGS}{MONTHPOWER}{VAL} = $newpower;
|
||||||
Log 4, "$hash->{NAME} Neuer Monat timenow: $timenow newpower $newpower powlast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} Neuer Monat timenow: $timenow newpower $newpower powlast $powLast";
|
||||||
$log .= " month: $newpower";
|
$log .= " month: $newpower";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,16 +269,16 @@ if ( $success == 0 and $summary > 0 and $counts > 0)
|
|||||||
}else{
|
}else{
|
||||||
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{YEARPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{YEARPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
||||||
my ($powLast) = $hash->{READINGS}{YEARPOWER}{VAL} =~ /^(.*)$/;
|
my ($powLast) = $hash->{READINGS}{YEARPOWER}{VAL} =~ /^(.*)$/;
|
||||||
Log 4, "$hash->{NAME} myhour: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} myhour: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
||||||
$hash->{READINGS}{YEARPOWER}{TIME} = $timenow;
|
$hash->{READINGS}{YEARPOWER}{TIME} = $timenow;
|
||||||
if ( $yearhLast eq $year ){ # es ist das gleiche Jahr
|
if ( $yearhLast eq $year ){ # es ist das gleiche Jahr
|
||||||
$powLast += $newpower ;
|
$powLast += $newpower ;
|
||||||
$hash->{READINGS}{YEARPOWER}{VAL} = $powLast;
|
$hash->{READINGS}{YEARPOWER}{VAL} = $powLast;
|
||||||
Log 4, "$hash->{NAME} Gleiches Jahr timenow: $timenow newpower $newpower powlast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} Gleiches Jahr timenow: $timenow newpower $newpower powlast $powLast";
|
||||||
$log .= " year: $powLast";
|
$log .= " year: $powLast";
|
||||||
}else{ # es ist eine Jahr vergangen
|
}else{ # es ist eine Jahr vergangen
|
||||||
$hash->{READINGS}{YEARPOWER}{VAL} = $newpower;
|
$hash->{READINGS}{YEARPOWER}{VAL} = $newpower;
|
||||||
Log 4, "$hash->{NAME} Neues Jahr timenow: $timenow newpower $newpower powlast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} Neues Jahr timenow: $timenow newpower $newpower powlast $powLast";
|
||||||
$log .= " year: $newpower";
|
$log .= " year: $newpower";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,16 +289,16 @@ if ( $success == 0 and $summary > 0 and $counts > 0)
|
|||||||
}else{
|
}else{
|
||||||
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{TOTALPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
my ($dateLast, $monthLast, $dayLast, $hourLast, $minLast, $secLast) = $hash->{READINGS}{TOTALPOWER}{TIME} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
|
||||||
my ($powLast) = $hash->{READINGS}{TOTALPOWER}{VAL} =~ /^(.*)$/;
|
my ($powLast) = $hash->{READINGS}{TOTALPOWER}{VAL} =~ /^(.*)$/;
|
||||||
Log 4, "$hash->{NAME} total: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
Log3 $hash, 4, "$hash->{NAME} total: $dateLast $monthLast $dayLast $hourLast $minLast $secLast $powLast";
|
||||||
$powLast += $newpower ;
|
$powLast += $newpower ;
|
||||||
$hash->{READINGS}{TOTALPOWER}{VAL} = $powLast;
|
$hash->{READINGS}{TOTALPOWER}{VAL} = $powLast;
|
||||||
$log .= " total: $powLast";
|
$log .= " total: $powLast";
|
||||||
}
|
}
|
||||||
push @{$hash->{CHANGED}}, $log;
|
push @{$hash->{CHANGED}}, $log;
|
||||||
DoTrigger($hash->{NAME}, undef) if ($init_done);
|
DoTrigger($hash->{NAME}, undef) if ($init_done);
|
||||||
Log 4, "$hash->{NAME} write log file: $log";
|
Log3 $hash, 4, "$hash->{NAME} write log file: $log";
|
||||||
}else{
|
}else{
|
||||||
Log 3, "$hash->{NAME} can't update - device send a error";
|
Log3 $hash, 3, "$hash->{NAME} can't update - device send a error";
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -322,7 +325,7 @@ energy_Update($hash) unless $hash->{Interval};
|
|||||||
if ( $get eq "?"){
|
if ( $get eq "?"){
|
||||||
return "Unknown argument ?, choose one of minPower maxPower lastPower avgPower DAYPOWER MONTHPOWER YEARPOWER TOTALPOWER";
|
return "Unknown argument ?, choose one of minPower maxPower lastPower avgPower DAYPOWER MONTHPOWER YEARPOWER TOTALPOWER";
|
||||||
}
|
}
|
||||||
Log 3, "$args[0] $get => $val";
|
Log3 $hash, 3, "$args[0] $get => $val";
|
||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ my ($hash) = @_;
|
|||||||
$hash->{StateFn} = "STV_SetState";
|
$hash->{StateFn} = "STV_SetState";
|
||||||
$hash->{SetFn} = "STV_Set";
|
$hash->{SetFn} = "STV_Set";
|
||||||
$hash->{AttrFn} = "STV_Attr";
|
$hash->{AttrFn} = "STV_Attr";
|
||||||
$hash->{AttrList} = "MAC loglevel:0,1,2,3,4,5";
|
$hash->{AttrList} = "MAC";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@ -133,8 +133,7 @@ if ( $hash->{Port} != 55000 && $hash->{Port} != 52235 ){
|
|||||||
return "[STV] Port is not supported";
|
return "[STV] Port is not supported";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log3 undef, 3, "[STV] defined with host: $hash->{Host} port: $hash->{Port} MAC: $hash->{MAC}";
|
||||||
Log 3, "[STV] defined with host: $hash->{Host} port: $hash->{Port} MAC: $hash->{MAC}";
|
|
||||||
$hash->{STATE} = 'Initialized';
|
$hash->{STATE} = 'Initialized';
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -142,7 +141,7 @@ if ( $hash->{Port} != 55000 && $hash->{Port} != 52235 ){
|
|||||||
sub connection($$)
|
sub connection($$)
|
||||||
{
|
{
|
||||||
my $tmp = shift ;
|
my $tmp = shift ;
|
||||||
Log 4, "[STV] connection message: $tmp";
|
Log3 undef, 4, "[STV] connection message: $tmp";
|
||||||
my $TV = shift;
|
my $TV = shift;
|
||||||
my $buffer = "";
|
my $buffer = "";
|
||||||
my $tmp2 = "";
|
my $tmp2 = "";
|
||||||
@ -160,12 +159,11 @@ sub connection($$)
|
|||||||
$buffer .= $buff;
|
$buffer .= $buff;
|
||||||
}
|
}
|
||||||
@tmp2 = split (/\n/,$buffer);
|
@tmp2 = split (/\n/,$buffer);
|
||||||
Log 3, "[STV] $TV response: $tmp2[0]";
|
|
||||||
Log 4, "[STV] $TV buffer response: $buffer";
|
|
||||||
$sock->close();
|
$sock->close();
|
||||||
Log 4, "[STV] $TV: socket closed";
|
Log3 undef, 4, "[STV] $TV: socket closed";
|
||||||
}else{
|
}else{
|
||||||
Log 4, "[STV] $TV: not able to close socket";
|
Log3 undef, 4, "[STV] $TV: not able to close socket";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,13 +186,13 @@ sub STV_55000($$$)
|
|||||||
|
|
||||||
#### MAC überprüfen wenn nicht gültig vom attribute übernehmen.
|
#### MAC überprüfen wenn nicht gültig vom attribute übernehmen.
|
||||||
if ($mymac !~ /^\w\w:\w\w:\w\w:\w\w|\w\w:\w\w:\w\w:\w\w$/) {
|
if ($mymac !~ /^\w\w:\w\w:\w\w:\w\w|\w\w:\w\w:\w\w:\w\w$/) {
|
||||||
Log 3, "[STV] mymac: $mymac invalid format";
|
Log3 $name, 3, "[STV] mymac: $mymac invalid format";
|
||||||
}else{
|
}else{
|
||||||
# command-line help
|
# command-line help
|
||||||
if (!$tv|!$tvip|!$myip|!$mymac) {
|
if (!$tv|!$tvip|!$myip|!$mymac) {
|
||||||
return "[STV] Error - Parameter missing:\nmodel, tvip, myip, mymac.";
|
return "[STV] Error - Parameter missing:\nmodel, tvip, myip, mymac.";
|
||||||
}
|
}
|
||||||
Log GetLogLevel($name,5), "[STV] opening socket with tvip: $tvip, cmd: $cmd";
|
Log3 $name, 5, "[STV] opening socket with tvip: $tvip, cmd: $cmd";
|
||||||
my $sock = new IO::Socket::INET (
|
my $sock = new IO::Socket::INET (
|
||||||
PeerAddr => $tvip,
|
PeerAddr => $tvip,
|
||||||
PeerPort => $port,
|
PeerPort => $port,
|
||||||
@ -202,10 +200,6 @@ sub STV_55000($$$)
|
|||||||
Timout => 5
|
Timout => 5
|
||||||
);
|
);
|
||||||
if (defined ($sock)){
|
if (defined ($sock)){
|
||||||
# Log GetLogLevel($name,3), "[STV] Could not create socket. Aborting." unless $sock;
|
|
||||||
# die "Could not create socket: $!\n" unless $sock;
|
|
||||||
# return "Could not create socket: $!\n" unless $sock;
|
|
||||||
# Log GetLogLevel($name,3), "[STV] Could not create socket. Aborting.";
|
|
||||||
my $messagepart1 = chr(0x64) . chr(0x00) . chr(length(encode_base64($myip, ""))) . chr(0x00) . encode_base64($myip, "") . chr(length(encode_base64($mymac, ""))) . chr(0x00) . encode_base64($mymac, "") . chr(length(encode_base64($remotename, ""))) . chr(0x00) . encode_base64($remotename, "");
|
my $messagepart1 = chr(0x64) . chr(0x00) . chr(length(encode_base64($myip, ""))) . chr(0x00) . encode_base64($myip, "") . chr(length(encode_base64($mymac, ""))) . chr(0x00) . encode_base64($mymac, "") . chr(length(encode_base64($remotename, ""))) . chr(0x00) . encode_base64($remotename, "");
|
||||||
my $part1 = chr(0x00) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart1)) . chr(0x00) . $messagepart1;
|
my $part1 = chr(0x00) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart1)) . chr(0x00) . $messagepart1;
|
||||||
print $sock $part1;
|
print $sock $part1;
|
||||||
@ -225,7 +219,7 @@ sub STV_55000($$$)
|
|||||||
else {
|
else {
|
||||||
foreach my $argnum (0 .. $#ARGV) {
|
foreach my $argnum (0 .. $#ARGV) {
|
||||||
# Send remote key(s)
|
# Send remote key(s)
|
||||||
Log GetLogLevel($name,4), "[STV] sending ".uc($ARGV[$argnum]);
|
#Log4 $name, 4, "[STV] sending ".uc($ARGV[$argnum]);
|
||||||
my $key = "KEY_" . uc($ARGV[$argnum]);
|
my $key = "KEY_" . uc($ARGV[$argnum]);
|
||||||
my $messagepart3 = chr(0x00) . chr(0x00) . chr(0x00) . chr(length(encode_base64($key, ""))) . chr(0x00) . encode_base64($key, "");
|
my $messagepart3 = chr(0x00) . chr(0x00) . chr(0x00) . chr(length(encode_base64($key, ""))) . chr(0x00) . encode_base64($key, "");
|
||||||
my $part3 = chr(0x00) . chr(length($tvappstring)) . chr(0x00) . $tvappstring . chr(length($messagepart3)) . chr(0x00) . $messagepart3;
|
my $part3 = chr(0x00) . chr(length($tvappstring)) . chr(0x00) . $tvappstring . chr(length($messagepart3)) . chr(0x00) . $messagepart3;
|
||||||
@ -237,7 +231,7 @@ sub STV_55000($$$)
|
|||||||
|
|
||||||
close($sock);
|
close($sock);
|
||||||
}else{
|
}else{
|
||||||
Log GetLogLevel($name,3), "[STV] Could not create socket. Aborting." unless $sock;
|
#Log5 $name, 3, "[STV] Could not create socket. Aborting." unless $sock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +245,6 @@ sub STV_52235($@$@)
|
|||||||
my $TV = $hash->{Host};
|
my $TV = $hash->{Host};
|
||||||
my $count = @a;
|
my $count = @a;
|
||||||
my $arg = lc($a[2]); # mute volume
|
my $arg = lc($a[2]); # mute volume
|
||||||
#Log 1, "name: $name host: $TV count: $count 0 $a[0] 1 $a[1] 2 $a[2]";
|
|
||||||
my $cont1 = ucfirst($arg); # Mute
|
my $cont1 = ucfirst($arg); # Mute
|
||||||
my $cont2 = "";
|
my $cont2 = "";
|
||||||
my $cont3 = "";
|
my $cont3 = "";
|
||||||
@ -291,7 +284,7 @@ if ( $arg eq "volume")
|
|||||||
if ( $cont2 > 0 and $cont2 < 100 ){
|
if ( $cont2 > 0 and $cont2 < 100 ){
|
||||||
$kind = 1;
|
$kind = 1;
|
||||||
}else {
|
}else {
|
||||||
Log 3, "[STV] $name Volume: not correct";
|
Log3 $name, 3, "[STV] $name Volume: not correct";
|
||||||
$kind = 0;
|
$kind = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user