mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-18 05:56:03 +00:00
my modules: remove unneccessary whitespaces at the end of the line
git-svn-id: https://svn.fhem.de/fhem/trunk@15140 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9391b7e3a8
commit
5caa5fd5fb
@ -5,8 +5,8 @@
|
||||
# Sents messages to your Pushsafer accout which will be delivered to
|
||||
# any configured device (e.g. iOS, Andriod, Windows).
|
||||
#
|
||||
# This module is based on the Pushsafer API description
|
||||
# which is available at https://www.pushsafer.com/en/pushapi:
|
||||
# This module is based on the Pushsafer API description
|
||||
# which is available at https://www.pushsafer.com/en/pushapi:
|
||||
#
|
||||
# Copyright by Markus Bloch
|
||||
# e-mail: Notausstieg0309@googlemail.com
|
||||
@ -71,23 +71,23 @@ sub Pushsafer_Define($$)
|
||||
my ($hash, $def) = @_;
|
||||
|
||||
my @args = split("[ \t]+", $def);
|
||||
|
||||
|
||||
if(!@args == 3)
|
||||
{
|
||||
return "wrong define syntax: define <name> Pushsafer <privatekey>";
|
||||
}
|
||||
|
||||
|
||||
my $privatekey = @args[2];
|
||||
|
||||
return "invalid private key: ".$privatekey if ($privatekey !~ /^[a-z\d]{20}$/i);
|
||||
|
||||
|
||||
$hash->{PrivateKey} = $privatekey;
|
||||
$hash->{helper}{URL} = "https://www.pushsafer.com/api";
|
||||
|
||||
Log3 $hash, 4, "Pushsafer ($name) - defined with private key: ".$privatekey;
|
||||
|
||||
$hash->{STATE} = "Initialized";
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -129,11 +129,11 @@ sub Pushsafer_Set($$$@)
|
||||
my ($err, $data) = Pushsafer_createBody($hash, $h);
|
||||
|
||||
return $err if(defined($err));
|
||||
|
||||
|
||||
my $data_scrambled = $data;
|
||||
|
||||
|
||||
$data_scrambled =~ s/k=[^&]+/k=HIDDEN/g; # remove private key from log output
|
||||
|
||||
|
||||
Log3 $name, 5, "Pushsafer ($name) - sending data: $data_scrambled";
|
||||
|
||||
Pushsafer_Send($hash, $data);
|
||||
@ -158,7 +158,7 @@ sub Pushsafer_createBody($$)
|
||||
{
|
||||
my ($hash, $args) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
|
||||
my @urlParts;
|
||||
my @errs;
|
||||
|
||||
@ -168,7 +168,7 @@ sub Pushsafer_createBody($$)
|
||||
{
|
||||
my $key;
|
||||
my $val;
|
||||
|
||||
|
||||
if(exists($Pushsaver_Params{$item}))
|
||||
{
|
||||
if(exists($Pushsaver_Params{$item}{check}) and $args->{$item} !~ $Pushsaver_Params{$item}{check})
|
||||
@ -200,23 +200,23 @@ sub Pushsafer_createBody($$)
|
||||
push @errs, "unsupported parameter: $item";
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if($key =~/^p\d?$/)
|
||||
{
|
||||
if($val =~ /^IPCAM:(\S+)$/)
|
||||
{
|
||||
my $ipcam = $1;
|
||||
|
||||
|
||||
if(!exists($defs{$ipcam}) or !exists($defs{$ipcam}{TYPE}) or $defs{$ipcam}{TYPE} ne "IPCAM")
|
||||
{
|
||||
Log3 $name, 3, "Pushsafer ($name) - no such IPCAM device: $ipcam. sending message without a picture...";
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
my $path = AttrVal($ipcam, "storage",AttrVal("global", "modpath", ".")."/www/snapshots");
|
||||
$path .= "/" unless($path =~ m,/$,);
|
||||
$path .= ReadingsVal($ipcam, "last", "");
|
||||
|
||||
|
||||
$val = Pushsafer_createDataUrl($hash, $path);
|
||||
next unless(defined($val));
|
||||
}
|
||||
@ -231,7 +231,7 @@ sub Pushsafer_createBody($$)
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
push @urlParts, $key."=".urlEncode($val);
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ sub Pushsafer_createBody($$)
|
||||
|
||||
#####################################
|
||||
# determine the image file format (reused from IPCAM module by Martin Fischer)
|
||||
sub Pushsafer_guessFileFormat($)
|
||||
sub Pushsafer_guessFileFormat($)
|
||||
{
|
||||
my ($src) = shift;
|
||||
my $header;
|
||||
@ -255,7 +255,7 @@ sub Pushsafer_guessFileFormat($)
|
||||
return undef if(!$reading);
|
||||
|
||||
local($_) = $srcHeader;
|
||||
|
||||
|
||||
return "image/jpeg" if /^\xFF\xD8/;
|
||||
return "image/png" if /^\x89PNG\x0d\x0a\x1a\x0a/;
|
||||
return "image/gif" if /^GIF8[79]a/;
|
||||
@ -267,7 +267,7 @@ sub Pushsafer_createDataUrl($$)
|
||||
{
|
||||
my ($hash, $file) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
|
||||
Log3 $name, 4, "Pushsafer ($name) - open image file: $file";
|
||||
|
||||
my ($err, @content) = FileRead({FileName => $file, ForceType => "file"});
|
||||
@ -281,21 +281,21 @@ sub Pushsafer_createDataUrl($$)
|
||||
{
|
||||
my $image = join($/, @content);
|
||||
my $mime_type = Pushsafer_guessFileFormat(\$image);
|
||||
|
||||
|
||||
if(defined($mime_type))
|
||||
{
|
||||
Log3 $name, 5, "Pushsafer ($name) - found image of type: $mime_type";
|
||||
|
||||
|
||||
my $base_64 = encode_base64($image);
|
||||
|
||||
|
||||
return "data:$mime_type;base64,".$base_64;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log3 $name, 3, "Pushsafer ($name) - unsupported image type for $file - see commandref for supported image formats";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ sub Pushsafer_createDataUrl($$)
|
||||
sub Pushsafer_Send($$)
|
||||
{
|
||||
my ($hash, $body) = @_;
|
||||
|
||||
|
||||
my $params = {
|
||||
url => $hash->{helper}{URL},
|
||||
timeout => 10,
|
||||
@ -363,7 +363,7 @@ sub Pushsafer_Callback($$$)
|
||||
{
|
||||
readingsBulkUpdate($hash, "lastSuccess", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /available"?\s*:\s*{(.+)\s*}\s*}\s*$/gcs)
|
||||
{
|
||||
my %devices = grep { defined($_) } map { /^"?(\d+)"?:({.+})$/ ? ($1 => $2) : undef } split(",", $1);
|
||||
@ -373,28 +373,28 @@ sub Pushsafer_Callback($$$)
|
||||
if(defined($devices{$dev}) and $devices{$dev} =~ /^{\s*"?([^":]+)"?\s*:\s*"?([^":]+)"?\s*}$/)
|
||||
{
|
||||
my ($devname, $available) = ($1, $2);
|
||||
|
||||
|
||||
$devname =~ s/\s+//g;
|
||||
|
||||
|
||||
readingsBulkUpdate($hash, "availableMessages-$dev-$devname", $available);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readingsEndUpdate($hash, 1);
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
=pod
|
||||
=item device
|
||||
=item summary sents text message notifications via pushsafer.com
|
||||
=item summary_DE verschickt Texnachrichten zur Benachrichtigung via Pushsafer
|
||||
=item summary sents text message notifications via pushsafer.com
|
||||
=item summary_DE verschickt Texnachrichten zur Benachrichtigung via Pushsafer
|
||||
=begin html
|
||||
|
||||
<a name="Pushsafer"></a>
|
||||
@ -540,12 +540,12 @@ sub Pushsafer_Callback($$$)
|
||||
<code><b>vibration</b></code> - Kurzform: <code>v </code> - Typ: Ganzzahl - Die Anzahl, wie oft das Zielgerät vibrieren soll beim Empfang der Nachricht (maximal 3 mal; nur für iOS-/Android-Geräte nutzbar). Falls nicht benutzt, wird die geräteinterne Einstellung verwendet.<br>
|
||||
<code><b>url</b> </code> - Kurzform: <code>u </code> - Typ: Text - Eine URL, welche der Nachricht angehangen werden soll. Dies kann eine normale http:// bzw. https:// URL sein, es sind jedoch auch weitere spezielle Schemas möglich. Eine Liste aller möglichen URL-Schemas gibt es unter <a href="https://www.pushsafer.com/de/url_schemes" target="_new">pushsafer.com</a> .<br>
|
||||
<code><b>urlText</b> </code> - Kurzform: <code>ut</code> - Typ: Text - Der Text, welcher zum Anzeigen der URL benutzt werden soll anstatt der Zieladresse.<br>
|
||||
<code><b>key</b> </code> - Kurzform: <code>k </code> - Typ: Text - Übersteuert den zu nutzenden Schlüssel zur Identifikation aus dem define-Kommando. Es kann hierbei auch ein Email-Alias-Schlüssel benutzt werden.<br>
|
||||
<code><b>ttl</b> </code> - Kurzform: <code>l </code> - Typ: Ganzzahl - Die Lebensdauer der Nachricht in Minuten. Sobald die Lebensdauer erreicht ist, wird die Nachricht selbstständig auf allen Geräten gelöscht. Der mögliche Wertebereich liegt zwischen 1 - 43200 Minuten (entspricht 30 Tagen).<br>
|
||||
<code><b>key</b> </code> - Kurzform: <code>k </code> - Typ: Text - Übersteuert den zu nutzenden Schlüssel zur Identifikation aus dem define-Kommando. Es kann hierbei auch ein Email-Alias-Schlüssel benutzt werden.<br>
|
||||
<code><b>ttl</b> </code> - Kurzform: <code>l </code> - Typ: Ganzzahl - Die Lebensdauer der Nachricht in Minuten. Sobald die Lebensdauer erreicht ist, wird die Nachricht selbstständig auf allen Geräten gelöscht. Der mögliche Wertebereich liegt zwischen 1 - 43200 Minuten (entspricht 30 Tagen).<br>
|
||||
<code><b>picture</b> </code> - Kurzform: <code>p </code> - Typ: Text - Anhängen eines Bildes zur Nachricht. Dies kann ein Dateipfad zu einer Bilddatei sein (z.B. <code>picture=/home/user/Bild.jpg</code>) oder der Name einer IPCAM-Instanz (im Format: <code>picture=IPCAM:<i><Name></i></code>) um die letzte Aufnahme zu senden (Bsp. <code>picture=IPCAM:IpKamera_Einganstuer</code>). Es werden die Dateiformate JPG, PNG und GIF unterstüzt.<br>
|
||||
<code><b>picture2</b> </code> - Kurzform: <code>p2</code> - Typ: Text - Gleiche Syntax wie die Option <code>"picture"</code>.<br>
|
||||
<code><b>picture3</b> </code> - Kurzform: <code>p3</code> - Typ: Text - Gleiche Syntax wie die Option <code>"picture"</code>.<br>
|
||||
|
||||
|
||||
<br>
|
||||
Beispiele:<br>
|
||||
<br>
|
||||
|
@ -33,7 +33,7 @@ use strict;
|
||||
use warnings;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
use HttpUtils;
|
||||
|
||||
|
||||
sub YAMAHA_BD_Get($@);
|
||||
sub YAMAHA_BD_Define($$);
|
||||
sub YAMAHA_BD_GetStatus($;$);
|
||||
@ -54,7 +54,7 @@ YAMAHA_BD_Initialize($)
|
||||
$hash->{UndefFn} = "YAMAHA_BD_Undefine";
|
||||
$hash->{AttrList} = "do_not_notify:0,1 disable:0,1 request-timeout:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 model ".
|
||||
$readingFnAttributes;
|
||||
|
||||
|
||||
$data{RC_layout}{YAMAHA_BluRay} = "YAMAHA_BD_RClayout";
|
||||
$data{RC_makenotify}{YAMAHA_BD} = "YAMAHA_BD_RCmakenotify";
|
||||
}
|
||||
@ -66,7 +66,7 @@ YAMAHA_BD_Define($$)
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
|
||||
if(! @a >= 3)
|
||||
{
|
||||
my $msg = "wrong syntax: define <name> YAMAHA_BD <ip-or-hostname> [<statusinterval>] [<presenceinterval>]";
|
||||
@ -75,9 +75,9 @@ YAMAHA_BD_Define($$)
|
||||
}
|
||||
|
||||
my $address = $a[2];
|
||||
|
||||
|
||||
$hash->{helper}{ADDRESS} = $address;
|
||||
|
||||
|
||||
# if an update interval was given which is greater than zero, use it.
|
||||
if(defined($a[3]) and $a[3] > 0)
|
||||
{
|
||||
@ -87,7 +87,7 @@ YAMAHA_BD_Define($$)
|
||||
{
|
||||
$hash->{helper}{OFF_INTERVAL}=30;
|
||||
}
|
||||
|
||||
|
||||
# if a second update interval is given, use this as ON_INTERVAL, otherwise use OFF_INTERVAL instead.
|
||||
if(defined($a[4]) and $a[4] > 0)
|
||||
{
|
||||
@ -96,15 +96,15 @@ YAMAHA_BD_Define($$)
|
||||
else
|
||||
{
|
||||
$hash->{helper}{ON_INTERVAL}=$hash->{helper}{OFF_INTERVAL};
|
||||
}
|
||||
}
|
||||
|
||||
$hash->{helper}{CMD_QUEUE} = ();
|
||||
delete($hash->{helper}{HTTP_CONNECTION}) if(exists($hash->{helper}{HTTP_CONNECTION}));
|
||||
|
||||
|
||||
# start the status update timer
|
||||
$hash->{helper}{DISABLED} = 0 unless(exists($hash->{helper}{DISABLED}));
|
||||
YAMAHA_BD_ResetTimer($hash, 2);
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -115,11 +115,11 @@ YAMAHA_BD_Get($@)
|
||||
my ($hash, @a) = @_;
|
||||
my $what;
|
||||
my $return;
|
||||
|
||||
|
||||
return "argument is missing" if(int(@a) != 2);
|
||||
|
||||
|
||||
$what = $a[1];
|
||||
|
||||
|
||||
if(exists($hash->{READINGS}{$what}))
|
||||
{
|
||||
YAMAHA_BD_GetStatus($hash, 1);
|
||||
@ -136,12 +136,12 @@ YAMAHA_BD_Get($@)
|
||||
else
|
||||
{
|
||||
$return = "unknown argument $what, choose one of";
|
||||
|
||||
|
||||
foreach my $reading (keys %{$hash->{READINGS}})
|
||||
{
|
||||
$return .= " $reading:noArg";
|
||||
}
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@ -154,9 +154,9 @@ YAMAHA_BD_Set($@)
|
||||
my $name = $hash->{NAME};
|
||||
my $address = $hash->{helper}{ADDRESS};
|
||||
my $result = "";
|
||||
|
||||
return "No Argument given" if(!defined($a[1]));
|
||||
|
||||
|
||||
return "No Argument given" if(!defined($a[1]));
|
||||
|
||||
my $what = $a[1];
|
||||
my $usage = "Unknown argument $what, choose one of on:noArg ".
|
||||
"off:noArg ".
|
||||
@ -171,7 +171,7 @@ YAMAHA_BD_Set($@)
|
||||
"trickPlay:normal,repeatChapter,repeatTitle,repeatFolder,repeat-AB,randomChapter,randomTitle,randomAll,shuffleChapter,shuffleTitle,shuffleAll,setApoint";
|
||||
|
||||
if($what eq "on")
|
||||
{
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Power_Control><Power>On</Power></Power_Control></Main_Zone></YAMAHA_AV>","on",undef);
|
||||
}
|
||||
elsif($what eq "off")
|
||||
@ -279,11 +279,11 @@ YAMAHA_BD_Set($@)
|
||||
elsif($a[2] eq "setup")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Remote_Control><Function>SETUP</Function></Remote_Control></Main_Zone></YAMAHA_AV>","remoteControl","setup");
|
||||
}
|
||||
}
|
||||
elsif($a[2] eq "home")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Remote_Control><Function>HOME</Function></Remote_Control></Main_Zone></YAMAHA_AV>","remoteControl","home");
|
||||
}
|
||||
}
|
||||
elsif($a[2] eq "clear")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Remote_Control><Function>CLEAR</Function></Remote_Control></Main_Zone></YAMAHA_AV>","remoteControl","clear");
|
||||
@ -409,7 +409,7 @@ YAMAHA_BD_Set($@)
|
||||
elsif($a[2] eq "close")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Tray_Control><Tray>Close</Tray></Tray_Control></Main_Zone></YAMAHA_AV>","tray","close");
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($what eq "skip")
|
||||
{
|
||||
@ -420,7 +420,7 @@ YAMAHA_BD_Set($@)
|
||||
elsif($a[2] eq "reverse")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Play_Control><Skip>Rev</Skip></Play_Control></Main_Zone></YAMAHA_AV>","skip","reverse");
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($what eq "fast")
|
||||
{
|
||||
@ -431,7 +431,7 @@ YAMAHA_BD_Set($@)
|
||||
elsif($a[2] eq "reverse")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Play_Control><Fast>Rev</Fast></Play_Control></Main_Zone></YAMAHA_AV>","fast","reverse");
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($what eq "slow")
|
||||
{
|
||||
@ -442,7 +442,7 @@ YAMAHA_BD_Set($@)
|
||||
elsif($a[2] eq "reverse")
|
||||
{
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Play_Control><Slow>Rev</Slow></Play_Control></Main_Zone></YAMAHA_AV>","slow","reverse");
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($what eq "play")
|
||||
{
|
||||
@ -464,7 +464,7 @@ YAMAHA_BD_Set($@)
|
||||
{
|
||||
return $usage;
|
||||
}
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ YAMAHA_BD_Attr(@)
|
||||
|
||||
# Start/Stop Timer according to new disabled-Value
|
||||
YAMAHA_BD_ResetTimer($hash);
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -504,7 +504,7 @@ sub
|
||||
YAMAHA_BD_Undefine($$)
|
||||
{
|
||||
my($hash, $name) = @_;
|
||||
|
||||
|
||||
# Stop the internal GetStatus-Loop and exit
|
||||
RemoveInternalTimer($hash);
|
||||
return undef;
|
||||
@ -527,7 +527,7 @@ YAMAHA_BD_GetStatus($;$)
|
||||
my $name = $hash->{NAME};
|
||||
my $power;
|
||||
my $return;
|
||||
|
||||
|
||||
$local = 0 unless(defined($local));
|
||||
|
||||
return "" if(!defined($hash->{helper}{ADDRESS}) or !defined($hash->{helper}{ON_INTERVAL}) or !defined($hash->{helper}{OFF_INTERVAL}));
|
||||
@ -540,16 +540,16 @@ YAMAHA_BD_GetStatus($;$)
|
||||
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - Requesting system status";
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><System><Service_Info>GetParam</Service_Info></System></YAMAHA_AV>", "statusRequest","systemStatus");
|
||||
|
||||
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - Requesting input info";
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><Main_Zone><Input_Info>GetParam</Input_Info></Main_Zone></YAMAHA_AV>", "statusRequest","inputInfo");
|
||||
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - Requesting power state";
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><Main_Zone><Power_Control><Power>GetParam</Power></Power_Control></Main_Zone></YAMAHA_AV>", "statusRequest","powerStatus");
|
||||
|
||||
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - Requesting playing info";
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><Main_Zone><Play_Info>GetParam</Play_Info></Main_Zone></YAMAHA_AV>", "statusRequest","playInfo");
|
||||
|
||||
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - Requesting trickPlay info";
|
||||
YAMAHA_BD_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><Main_Zone><Play_Control>GetParam</Play_Control></Main_Zone></YAMAHA_AV>", "statusRequest","trickPlayInfo");
|
||||
|
||||
@ -564,21 +564,21 @@ YAMAHA_BD_SendCommand($$$$)
|
||||
{
|
||||
my ($hash, $data,$cmd,$arg) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
|
||||
my $response;
|
||||
|
||||
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - append to queue \"$cmd".(defined($arg) ? " ".$arg : "")."\": $data";
|
||||
|
||||
|
||||
# In case any URL changes must be made, this part is separated in this function".
|
||||
|
||||
|
||||
my $param = {
|
||||
data => "<?xml version=\"1.0\" encoding=\"utf-8\"?>".$data,
|
||||
cmd => $cmd,
|
||||
arg => $arg,
|
||||
};
|
||||
|
||||
push @{$hash->{helper}{CMD_QUEUE}}, $param;
|
||||
|
||||
|
||||
push @{$hash->{helper}{CMD_QUEUE}}, $param;
|
||||
|
||||
YAMAHA_BD_HandleCmdQueue($hash);
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ YAMAHA_BD_HandleCmdQueue($)
|
||||
my ($hash) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $address = $hash->{helper}{ADDRESS};
|
||||
|
||||
|
||||
if(not($hash->{helper}{RUNNING_REQUEST}) and @{$hash->{helper}{CMD_QUEUE}})
|
||||
{
|
||||
my $params = {
|
||||
@ -603,12 +603,12 @@ YAMAHA_BD_HandleCmdQueue($)
|
||||
hash => $hash,
|
||||
callback => \&YAMAHA_BD_ParseResponse
|
||||
};
|
||||
|
||||
|
||||
my $request = pop @{$hash->{helper}{CMD_QUEUE}};
|
||||
|
||||
map {$hash->{helper}{HTTP_CONNECTION}{$_} = $params->{$_}} keys %{$params};
|
||||
map {$hash->{helper}{HTTP_CONNECTION}{$_} = $request->{$_}} keys %{$request};
|
||||
|
||||
|
||||
$hash->{helper}{RUNNING_REQUEST} = 1;
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - send command \"$request->{cmd}".(defined($request->{arg}) ? " ".$request->{arg} : "")."\": $request->{data}";
|
||||
HttpUtils_NonblockingGet($hash->{helper}{HTTP_CONNECTION});
|
||||
@ -621,25 +621,25 @@ sub
|
||||
YAMAHA_BD_ParseResponse($$$)
|
||||
{
|
||||
|
||||
my ( $param, $err, $data ) = @_;
|
||||
|
||||
my ( $param, $err, $data ) = @_;
|
||||
|
||||
my $hash = $param->{hash};
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
|
||||
my $cmd = $param->{cmd};
|
||||
my $arg = $param->{arg};
|
||||
|
||||
|
||||
$data = "" unless(defined($data));
|
||||
$err = "" unless(defined($err));
|
||||
|
||||
|
||||
$hash->{helper}{RUNNING_REQUEST} = 0;
|
||||
|
||||
|
||||
delete($hash->{helper}{HTTP_CONNECTION}) unless($param->{keepalive});
|
||||
|
||||
|
||||
if($err ne "")
|
||||
{
|
||||
Log3 $name, 4, "YAMAHA_BD ($name) - error while executing \"$cmd".(defined($arg) ? " ".$arg : "")."\": $err";
|
||||
|
||||
|
||||
if((not exists($hash->{helper}{AVAILABLE})) or (exists($hash->{helper}{AVAILABLE}) and $hash->{helper}{AVAILABLE} eq 1))
|
||||
{
|
||||
Log3 $name, 3, "YAMAHA_BD ($name) - could not execute command on device $name. Please turn on your device in case of deactivated network standby or check for correct hostaddress: $err";
|
||||
@ -650,21 +650,21 @@ YAMAHA_BD_ParseResponse($$$)
|
||||
elsif($data ne "")
|
||||
{
|
||||
Log3 $name, 5, "YAMAHA_BD ($name) - got HTTP response for \"$cmd".(defined($arg) ? " ".$arg : "")."\": $data";
|
||||
|
||||
|
||||
if (defined($hash->{helper}{AVAILABLE}) and $hash->{helper}{AVAILABLE} == 0)
|
||||
{
|
||||
Log3 $name, 3, "YAMAHA_BD: device $name reappeared";
|
||||
readingsSingleUpdate($hash, "presence", "present", 1);
|
||||
readingsSingleUpdate($hash, "presence", "present", 1);
|
||||
}
|
||||
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
|
||||
if(not $data =~ /RC="0"/)
|
||||
{
|
||||
# if the returncode isn't 0, than the command was not successful
|
||||
Log3 $name, 3, "YAMAHA_BD ($name) - Could not execute \"$cmd".(defined($arg) ? " ".$arg : "")."\"";
|
||||
}
|
||||
|
||||
|
||||
if($cmd eq "statusRequest" and $arg eq "systemStatus")
|
||||
{
|
||||
if($data =~ /<Error_Info>(.+?)<\/Error_Info>/)
|
||||
@ -678,34 +678,34 @@ YAMAHA_BD_ParseResponse($$$)
|
||||
{
|
||||
$hash->{MODEL} = $1;
|
||||
$hash->{FIRMWARE} = $2;
|
||||
|
||||
|
||||
$hash->{MODEL} =~ s/\s*YAMAHA\s*//g;
|
||||
|
||||
$attr{$name}{"model"} = $hash->{MODEL};
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($cmd eq "statusRequest" and $arg eq "powerStatus")
|
||||
{
|
||||
if($data =~ /<Power>(.+?)<\/Power>/)
|
||||
{
|
||||
{
|
||||
my $power = $1;
|
||||
|
||||
|
||||
if($power eq "Standby" or $power eq "Network Standby")
|
||||
{
|
||||
{
|
||||
$power = "off";
|
||||
}
|
||||
|
||||
|
||||
readingsBulkUpdate($hash, "power", lc($power));
|
||||
readingsBulkUpdate($hash, "state", lc($power));
|
||||
}
|
||||
}
|
||||
elsif($cmd eq "on")
|
||||
{
|
||||
if($data =~ /RC="0"/ and $data =~ /<Power><\/Power>/)
|
||||
if($data =~ /RC="0"/ and $data =~ /<Power><\/Power>/)
|
||||
{
|
||||
# As the player startup takes about 5 seconds, the status will be already set, if the return code of the command is 0.
|
||||
readingsBulkUpdate($hash, "power", "on");
|
||||
readingsBulkUpdate($hash, "state","on");
|
||||
readingsBulkUpdate($hash, "state","on");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -716,14 +716,14 @@ YAMAHA_BD_ParseResponse($$$)
|
||||
{
|
||||
if($data =~ /<Trick_Play>(.+?)<\/Trick_Play>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "trickPlay", $1);
|
||||
}
|
||||
readingsBulkUpdate($hash, "trickPlay", $1);
|
||||
}
|
||||
}
|
||||
elsif($cmd eq "statusRequest" and $arg eq "inputInfo")
|
||||
{
|
||||
if($data =~ /<Input_Info><Status>(.+?)<\/Status><\/Input_Info/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "input", $1);
|
||||
readingsBulkUpdate($hash, "input", $1);
|
||||
}
|
||||
elsif($data =~ /<Input_Info>(.+?)<\/Input_Info/)
|
||||
{
|
||||
@ -736,67 +736,67 @@ YAMAHA_BD_ParseResponse($$$)
|
||||
{
|
||||
readingsBulkUpdate($hash, "playStatus", lc($1));
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Contents>.*?<Chapter>(.+?)<\/Chapter>.*?<\/Contents>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "currentChapter", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Contents>.*?<Track>(.+?)<\/Track>.*?<\/Contents>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "currentTrack", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Contents>.*?<Title>(.+?)<\/Title>.*?<\/Contents>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "currentTitle", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Disc_Info>.*?<Track_Num>(.+?)<\/Track_Num>.*?<\/Disc_Info>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "totalTracks", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Contents>.*?<Type>(.+?)<\/Type>.*?<\/Contents>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "contentType", lc($1));
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<File_Name>(.+?)<\/File_Name>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "currentMedia", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Disc_Type>(.+?)<\/Disc_Type>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "discType", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Tray>(.+?)<\/Tray>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "trayStatus", lc($1));
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<Current_PlayTime>(.+?)<\/Current_PlayTime>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "playTimeCurrent", YAMAHA_BD_formatTimestamp($1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($data =~ /<Total_Time>(.+?)<\/Total_Time>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "playTimeTotal", YAMAHA_BD_formatTimestamp($1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readingsEndUpdate($hash, 1);
|
||||
|
||||
|
||||
YAMAHA_BD_GetStatus($hash, 1) if($cmd ne "statusRequest" and $cmd ne "on");
|
||||
YAMAHA_BD_ResetTimer($hash, 10) if($cmd eq "on");
|
||||
}
|
||||
|
||||
|
||||
$hash->{helper}{AVAILABLE} = ($err ne "" ? 0 : 1);
|
||||
|
||||
YAMAHA_BD_HandleCmdQueue($hash);
|
||||
YAMAHA_BD_HandleCmdQueue($hash);
|
||||
}
|
||||
|
||||
#############################
|
||||
@ -805,9 +805,9 @@ sub
|
||||
YAMAHA_BD_ResetTimer($;$)
|
||||
{
|
||||
my ($hash, $interval) = @_;
|
||||
|
||||
|
||||
RemoveInternalTimer($hash);
|
||||
|
||||
|
||||
if($hash->{helper}{DISABLED} == 0)
|
||||
{
|
||||
if(defined($interval))
|
||||
@ -827,7 +827,7 @@ YAMAHA_BD_ResetTimer($;$)
|
||||
|
||||
#############################
|
||||
# define the layout for module 95_remotecontrol.pm
|
||||
sub YAMAHA_BD_RClayout()
|
||||
sub YAMAHA_BD_RClayout()
|
||||
{
|
||||
my @row;
|
||||
|
||||
@ -857,11 +857,11 @@ sub YAMAHA_BD_RClayout()
|
||||
|
||||
#####################################
|
||||
# Callback from 95_remotecontrol for command makenotify.
|
||||
sub YAMAHA_BD_RCmakenotify($$)
|
||||
sub YAMAHA_BD_RCmakenotify($$)
|
||||
{
|
||||
my ($name, $dev) = @_;
|
||||
my $new_name="notify_$name";
|
||||
|
||||
|
||||
fhem("define $new_name notify $name set $dev ".'$EVENT',1);
|
||||
Log3 undef, 2, "[remotecontrol:YAMAHA_BD] Notify created: $new_name";
|
||||
return "Notify created by YAMAHA_BD: $new_name";
|
||||
@ -869,14 +869,14 @@ sub YAMAHA_BD_RCmakenotify($$)
|
||||
|
||||
#############################
|
||||
# formats a 3 byte Hex Value into human readable time duration
|
||||
sub YAMAHA_BD_formatTimestamp($)
|
||||
sub YAMAHA_BD_formatTimestamp($)
|
||||
{
|
||||
my ($hex) = @_;
|
||||
|
||||
|
||||
my ($hour) = sprintf("%02d", unpack("s", pack "s", hex(substr($hex, 0, 2))));
|
||||
my ($min) = sprintf("%02d", unpack("s", pack "s", hex(substr($hex, 2, 2))));
|
||||
my ($sec) = sprintf("%02d", unpack("s", pack "s", hex(substr($hex, 4, 2))));
|
||||
|
||||
|
||||
return "$hour:$min:$sec";
|
||||
}
|
||||
|
||||
@ -911,22 +911,22 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
seconds), which periodically reads the status of the player (power state, current disc, tray status,...)
|
||||
and triggers notify/filelog commands.
|
||||
<br><br>
|
||||
Different status update intervals depending on the power state can be given also.
|
||||
If two intervals are given to the define statement, the first interval statement represents the status update
|
||||
interval in seconds in case the device is off, absent or any other non-normal state. The second
|
||||
Different status update intervals depending on the power state can be given also.
|
||||
If two intervals are given to the define statement, the first interval statement represents the status update
|
||||
interval in seconds in case the device is off, absent or any other non-normal state. The second
|
||||
interval statement is used when the device is on.
|
||||
|
||||
|
||||
Example:<br><br>
|
||||
<ul><code>
|
||||
define BD_Player YAMAHA_BD 192.168.0.10
|
||||
<br><br>
|
||||
# With custom status interval of 60 seconds<br>
|
||||
define BD_Player YAMAHA_BD 192.168.0.10 60
|
||||
define BD_Player YAMAHA_BD 192.168.0.10 60
|
||||
<br><br>
|
||||
# With custom "off"-interval of 60 seconds and "on"-interval of 10 seconds<br>
|
||||
define BD_Player YAMAHA_BD 192.168.0.10 60 10
|
||||
</code></ul>
|
||||
|
||||
|
||||
</ul>
|
||||
<br><br>
|
||||
<a name="YAMAHA_BDset"></a>
|
||||
@ -968,7 +968,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
...<br>
|
||||
remoteControl 9<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
<u>Cursor Selection:</u><br><br>
|
||||
<ul><code>
|
||||
remoteControl up<br>
|
||||
@ -989,7 +989,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
remoteControl home<br>
|
||||
remoteControl clear<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
<u>Color Buttons:</u><br><br>
|
||||
<ul><code>
|
||||
remoteControl red<br>
|
||||
@ -997,7 +997,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
remoteControl yellow<br>
|
||||
remoteControl blue<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
<u>Play Control Buttons:</u><br><br>
|
||||
<ul><code>
|
||||
remoteControl program<br>
|
||||
@ -1012,7 +1012,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
remoteControl secondVideo<br>
|
||||
</code></ul><br><br>
|
||||
The button names are the same as on your remote control.<br><br>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="YAMAHA_BDget"></a>
|
||||
@ -1061,7 +1061,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
<br>
|
||||
<b>Implementator's note</b><br>
|
||||
<ul>
|
||||
<li>Some older models (e.g. BD-S671) cannot be controlled over networked by delivery. A <u><b>firmware update is neccessary</b></u> to control these models via FHEM. In general it is always recommended to use the latest firmware.</li>
|
||||
<li>Some older models (e.g. BD-S671) cannot be controlled over networked by delivery. A <u><b>firmware update is neccessary</b></u> to control these models via FHEM. In general it is always recommended to use the latest firmware.</li>
|
||||
<li>The module is only usable if you activate "Network Control" on your player. Otherwise it is not possible to communicate with the player.</li>
|
||||
</ul>
|
||||
<br>
|
||||
@ -1088,13 +1088,13 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
Es bietet die Möglichkeit den Player an-/auszuschalten, die Schublade zu öffnen und schließen,
|
||||
die Wiedergabe beeinflussen, sämtliche Fernbedieungs-Befehle zu senden, sowie den aktuellen Status abzufragen.
|
||||
<br><br>
|
||||
Bei der Definition eines YAMAHA_BD-Moduls wird eine interne Routine in Gang gesetzt, welche regelmäßig
|
||||
Bei der Definition eines YAMAHA_BD-Moduls wird eine interne Routine in Gang gesetzt, welche regelmäßig
|
||||
(einstellbar durch den optionalen Parameter <code><Status_Interval></code>; falls nicht gesetzt ist der Standardwert 30 Sekunden)
|
||||
den Status des Players abfragt und entsprechende Notify-/FileLog-Definitionen triggert.
|
||||
<br><br>
|
||||
Sofern 2 Interval-Argumente übergeben werden, wird der erste Parameter <code><Off_Interval></code> genutzt
|
||||
sofern der Player ausgeschaltet oder nicht erreichbar ist. Der zweiter Parameter <code><On_Interval></code>
|
||||
wird verwendet, sofern der Player eingeschaltet ist.
|
||||
sofern der Player ausgeschaltet oder nicht erreichbar ist. Der zweiter Parameter <code><On_Interval></code>
|
||||
wird verwendet, sofern der Player eingeschaltet ist.
|
||||
<br><br>
|
||||
Beispiel:<br><br>
|
||||
<ul><code>
|
||||
@ -1147,7 +1147,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
...<br>
|
||||
remoteControl 9<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
<u>Cursor Steuerung:</u><br><br>
|
||||
<ul><code>
|
||||
remoteControl up<br>
|
||||
@ -1168,7 +1168,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
remoteControl home<br>
|
||||
remoteControl clear<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
<u>Farbtasten:</u><br><br>
|
||||
<ul><code>
|
||||
remoteControl red<br>
|
||||
@ -1176,7 +1176,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
remoteControl yellow<br>
|
||||
remoteControl blue<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
<u>Wiedergabetasten:</u><br><br>
|
||||
<ul><code>
|
||||
remoteControl program<br>
|
||||
@ -1190,7 +1190,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
remoteControl secondAudio<br>
|
||||
remoteControl secondVideo<br>
|
||||
</code></ul><br><br>
|
||||
|
||||
|
||||
Die Befehlsnamen entsprechen den Tasten auf der Fernbedienung.<br><br>
|
||||
</ul>
|
||||
|
||||
@ -1205,7 +1205,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
<a name="YAMAHA_BDattr"></a>
|
||||
<b>Attribute</b>
|
||||
<ul>
|
||||
|
||||
|
||||
<li><a href="#do_not_notify">do_not_notify</a></li>
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
|
||||
<li><a name="disable">disable</a></li>
|
||||
@ -1241,7 +1241,7 @@ sub YAMAHA_BD_formatTimestamp($)
|
||||
<br>
|
||||
<b>Hinweise des Autors</b>
|
||||
<ul>
|
||||
<li>Einige ältere Player-Modelle (z.B. BD-S671) können im Auslieferungszustand nicht via Netzwerk gesteuert werden. Um eine Steuerung via FHEM zu ermöglichen ist ein <u><b>Firmware-Update notwending</b></u>!</li>
|
||||
<li>Einige ältere Player-Modelle (z.B. BD-S671) können im Auslieferungszustand nicht via Netzwerk gesteuert werden. Um eine Steuerung via FHEM zu ermöglichen ist ein <u><b>Firmware-Update notwending</b></u>!</li>
|
||||
<li>Dieses Modul ist nur nutzbar, wenn die Option "Netzwerksteuerung" am Player aktiviert ist. Ansonsten ist die Steuerung nicht möglich.</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -114,7 +114,7 @@ sub
|
||||
LGTV_IP12_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
|
||||
$hash->{DefFn} = "LGTV_IP12_Define";
|
||||
$hash->{DeleteFn} = "LGTV_IP12_Delete";
|
||||
$hash->{UndefFn} = "LGTV_IP12_Undef";
|
||||
@ -137,10 +137,10 @@ LGTV_IP12_Define($$)
|
||||
return "LGTV_IP12: not enough arguments. Usage: " .
|
||||
"define <name> LGTV_IP12 <HOST>";
|
||||
}
|
||||
|
||||
|
||||
$hash->{HOST} = $args[2];
|
||||
$hash->{PORT} = "8080";
|
||||
|
||||
|
||||
# if an update interval was given which is greater than zero, use it.
|
||||
if(defined($args[3]) and $args[3] > 0)
|
||||
{
|
||||
@ -150,7 +150,7 @@ LGTV_IP12_Define($$)
|
||||
{
|
||||
$hash->{helper}{OFF_INTERVAL} = 30;
|
||||
}
|
||||
|
||||
|
||||
if(defined($args[4]) and $args[4] > 0)
|
||||
{
|
||||
$hash->{ON_INTERVAL} = $args[4];
|
||||
@ -161,11 +161,11 @@ LGTV_IP12_Define($$)
|
||||
{
|
||||
$hash->{INTERVAL} = $hash->{helper}{OFF_INTERVAL};
|
||||
$hash->{helper}{ON_INTERVAL} = $hash->{helper}{OFF_INTERVAL};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$hash->{STATE} = 'defined';
|
||||
$hash->{NOTIFYDEV} = "global";
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -176,22 +176,22 @@ LGTV_IP12_Get($@)
|
||||
my ($hash, @a) = @_;
|
||||
my $what;
|
||||
my $return;
|
||||
|
||||
|
||||
return "argument is missing" if(int(@a) != 2);
|
||||
|
||||
|
||||
$what = $a[1];
|
||||
|
||||
|
||||
return ReadingsVal($hash->{NAME}, $what, "") if(defined(ReadingsVal($hash->{NAME}, $what, undef)));
|
||||
|
||||
|
||||
$return = "unknown argument $what, choose one of";
|
||||
|
||||
|
||||
foreach my $reading (keys %{$hash->{READINGS}})
|
||||
{
|
||||
$return .= " $reading:noArg";
|
||||
}
|
||||
|
||||
|
||||
return $return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#################################
|
||||
@ -200,9 +200,9 @@ LGTV_IP12_Notify($$)
|
||||
{
|
||||
my ($hash,$dev) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
|
||||
return unless(exists($dev->{NAME}) and $dev->{NAME} eq "global");
|
||||
|
||||
|
||||
if(grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}))
|
||||
{
|
||||
if(defined(AttrVal($name, "pairingcode", undef)) and AttrVal($name, "pairingcode", undef) =~/^\d{6}$/)
|
||||
@ -210,7 +210,7 @@ LGTV_IP12_Notify($$)
|
||||
Log3 $name, 3, "LGTV_IP12 ($name) - try pairing with pairingcode ".AttrVal($name, "pairingcode", undef);
|
||||
LGTV_IP12_Pair($hash, AttrVal($name, "pairingcode", undef));
|
||||
}
|
||||
|
||||
|
||||
LGTV_IP12_ResetTimer($hash, 0);
|
||||
}
|
||||
elsif(grep(m/^(?:ATTR $name disable.*|DELETEATTR $name disable.*)$/, @{$dev->{CHANGED}}))
|
||||
@ -251,19 +251,19 @@ LGTV_IP12_Set($@)
|
||||
{
|
||||
LGTV_IP12_ResetTimer($hash, 0);
|
||||
}
|
||||
|
||||
|
||||
my $new_channel;
|
||||
|
||||
|
||||
if($what eq "channelUp" or $what eq "channelDown")
|
||||
{
|
||||
my $current_channel = ReadingsVal($name, "channel", undef);
|
||||
|
||||
|
||||
if(defined($current_channel) and $current_channel =~ /^\d+$/ and $current_channel > 0)
|
||||
{
|
||||
my $found = 0;
|
||||
|
||||
$new_channel = (grep { $found++ < 1; } grep { ($what eq "channelUp" ? $_ > $current_channel : $_ < $current_channel ) } sort { ($what eq "channelUp" ? $a <=> $b : $b <=> $a) } grep { defined($_) and /^\d+$/ } keys %{$hash->{helper}{CHANNEL_LIST}})[0];
|
||||
|
||||
|
||||
$new_channel = (grep { $found++ < 1; } grep { ($what eq "channelUp" ? $_ > $current_channel : $_ < $current_channel ) } sort { ($what eq "channelUp" ? $a <=> $b : $b <=> $a) } grep { defined($_) and /^\d+$/ } keys %{$hash->{helper}{CHANNEL_LIST}})[0];
|
||||
|
||||
}
|
||||
}
|
||||
elsif($what eq "channel" and exists($hash->{helper}{CHANNEL_LIST}) and exists($hash->{helper}{CHANNEL_LIST}{$arg}))
|
||||
@ -274,18 +274,18 @@ LGTV_IP12_Set($@)
|
||||
{
|
||||
return $usage;
|
||||
}
|
||||
|
||||
|
||||
if(defined($new_channel))
|
||||
{
|
||||
Log3 $hash->{NAME}, 5 , "LGTV_IP12 (".$hash->{NAME}.") - set new channel: $new_channel";
|
||||
|
||||
Log3 $hash->{NAME}, 5 , "LGTV_IP12 (".$hash->{NAME}.") - set new channel: $new_channel";
|
||||
|
||||
my $xml = "<api type=\"command\"><name>HandleChannelChange</name>";
|
||||
$xml .= "<major>".$hash->{helper}{CHANNEL_LIST}{$new_channel}{major}."</major>";
|
||||
$xml .= "<minor>".$hash->{helper}{CHANNEL_LIST}{$new_channel}{minor}."</minor>";
|
||||
$xml .= "<sourceIndex>".$hash->{helper}{CHANNEL_LIST}{$new_channel}{sourceIndex}."</sourceIndex>";
|
||||
$xml .= "<physicalNum>".$hash->{helper}{CHANNEL_LIST}{$new_channel}{physicalNum}."</physicalNum>";
|
||||
$xml .= "<physicalNum>".$hash->{helper}{CHANNEL_LIST}{$new_channel}{physicalNum}."</physicalNum>";
|
||||
$xml .= "</api>";
|
||||
|
||||
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/command", "channel", $new_channel, $xml);
|
||||
}
|
||||
}
|
||||
@ -340,7 +340,7 @@ LGTV_IP12_Attr(@)
|
||||
elsif($a[0] eq "del" && $a[2] eq "disable")
|
||||
{
|
||||
LGTV_IP12_ResetTimer($hash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
@ -350,7 +350,7 @@ sub
|
||||
LGTV_IP12_Delete($$)
|
||||
{
|
||||
my ($hash, $name) = @_;
|
||||
# unpairing
|
||||
# unpairing
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/pairing", "removePairing", undef, "<api type=\"pairing\"><name>byebye</name><port>8080</port></api>") if(exists($hash->{helper}{PAIRED}) and $hash->{helper}{PAIRED} == 1);
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ LGTV_IP12_Undef($$)
|
||||
|
||||
#################################
|
||||
# start a status request by starting the neccessary requests
|
||||
sub
|
||||
sub
|
||||
LGTV_IP12_GetStatus($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
@ -382,12 +382,12 @@ LGTV_IP12_GetStatus($)
|
||||
{
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/data?target=channel_list", "statusRequest", "channelList", undef);
|
||||
}
|
||||
|
||||
|
||||
unless(exists($hash->{helper}{APP_LIST}) and ReadingsVal($hash->{NAME}, "state", "off") eq "on")
|
||||
{
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/data?target=applist_get&type=1&index=0&number=0", "statusRequest", "appList", undef);
|
||||
}
|
||||
|
||||
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/data?target=cur_channel", "statusRequest", "currentChannel");
|
||||
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/data?target=volume_info", "statusRequest", "volumeInfo");
|
||||
@ -403,16 +403,16 @@ sub
|
||||
LGTV_IP12_ParseHttpResponse($$$)
|
||||
{
|
||||
|
||||
my ( $param, $err, $data ) = @_;
|
||||
|
||||
my ( $param, $err, $data ) = @_;
|
||||
|
||||
my $hash = $param->{hash};
|
||||
my $name = $hash->{NAME};
|
||||
my $cmd = $param->{cmd};
|
||||
my $arg = $param->{arg};
|
||||
|
||||
|
||||
$err = "" unless(defined($err));
|
||||
$data = "" unless(defined($data));
|
||||
|
||||
|
||||
# we successfully received a HTTP status code in the response
|
||||
if($data eq "" and exists($param->{code}))
|
||||
{
|
||||
@ -420,7 +420,7 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
if($param->{code} eq 401)
|
||||
{
|
||||
Log3 $name, 3, "LGTV_IP12 ($name) - failed to execute \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\": Device is not paired";
|
||||
|
||||
|
||||
if(exists($hash->{helper}{PAIRED}))
|
||||
{
|
||||
if($hash->{helper}{PAIRED} == 1)
|
||||
@ -428,7 +428,7 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
$hash->{helper}{PAIRED} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# If a pairing code is set as attribute, try one repair (when $hash->{helper}{PAIRED} == -1)
|
||||
if(defined(AttrVal($name, "pairingcode", undef)) and AttrVal($name, "pairingcode", undef) =~/^\d{6}$/)
|
||||
{
|
||||
@ -437,7 +437,7 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($cmd eq "channel" and $param->{code} == 200)
|
||||
{
|
||||
readingsSingleUpdate($hash, $cmd, $arg, 1);
|
||||
@ -445,18 +445,18 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
|
||||
# if an error was occured, raise a log entry
|
||||
if($err ne "")
|
||||
{
|
||||
Log3 $name, 5, "LGTV_IP12 ($name) - could not execute command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\" - $err";
|
||||
|
||||
|
||||
readingsBulkUpdate($hash, "state", "off");
|
||||
readingsBulkUpdate($hash, "power", "off");
|
||||
}
|
||||
|
||||
|
||||
# if the response contains data, examine it.
|
||||
if($data ne "")
|
||||
{
|
||||
@ -464,7 +464,7 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
|
||||
readingsBulkUpdate($hash, "state", "on");
|
||||
readingsBulkUpdate($hash, "power", "on");
|
||||
|
||||
|
||||
if($cmd eq "statusRequest")
|
||||
{
|
||||
if($arg eq "volumeInfo")
|
||||
@ -473,41 +473,41 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
{
|
||||
readingsBulkUpdate($hash, "volume", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<mute>(.+?)<\/mute>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "mute", ($1 eq "true" ? "on" : "off"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($arg eq "currentChannel")
|
||||
{
|
||||
if($data =~ /<inputSourceName>(.+?)<\/inputSourceName>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "input", LGTV_IP12_html2txt($1));
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<labelName>(.+?)<\/labelName>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "inputLabel", LGTV_IP12_html2txt($1));
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<chname>(.+?)<\/chname>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "channelName", LGTV_IP12_html2txt($1));
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<major>(.+?)<\/major>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "channel", $1);
|
||||
}
|
||||
|
||||
|
||||
if($data =~ /<progName>(.+?)<\/progName>/)
|
||||
{
|
||||
readingsBulkUpdate($hash, "currentProgram", LGTV_IP12_html2txt($1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($arg eq "is3d")
|
||||
{
|
||||
if($data =~ /<is3D>(.+?)<\/is3D>/)
|
||||
@ -515,7 +515,7 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
readingsBulkUpdate($hash, "3D", $1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($arg eq "appList")
|
||||
{
|
||||
while($data =~ /<data><auid>([0-9a-f]+)<\/auid><name>\s*([^<]+?)\s*<\/name><type>(\d+)<\/type><cpid>([\w\d_-]*)<\/cpid>.*?<\/data>/gci)
|
||||
@ -530,11 +530,11 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
$hash->{helper}{APP_LIST}{$index}{cpid} = $fields[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($arg eq "channelList")
|
||||
{
|
||||
delete($hash->{helper}{CHANNEL_LIST}) if(exists($hash->{helper}{CHANNEL_LIST}));
|
||||
|
||||
|
||||
while($data =~ /<data>(.+?)<\/data>/gc)
|
||||
{
|
||||
my $channel = $1;
|
||||
@ -542,22 +542,22 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
{
|
||||
my $channel_major = $1;
|
||||
$hash->{helper}{CHANNEL_LIST}{$channel_major}{major} = $channel_major;
|
||||
|
||||
|
||||
if($channel =~ /<minor>(\d+?)<\/minor>/)
|
||||
{
|
||||
$hash->{helper}{CHANNEL_LIST}{$channel_major}{minor} = $1;
|
||||
}
|
||||
|
||||
|
||||
if($channel =~ /<sourceIndex>(\d+?)<\/sourceIndex>/)
|
||||
{
|
||||
$hash->{helper}{CHANNEL_LIST}{$channel_major}{sourceIndex} = $1;
|
||||
}
|
||||
|
||||
|
||||
if($channel =~ /<physicalNum>(\d+?)<\/physicalNum>/)
|
||||
{
|
||||
$hash->{helper}{CHANNEL_LIST}{$channel_major}{physicalNum} = $1;
|
||||
}
|
||||
|
||||
|
||||
if($channel =~ /<chname>(.+?)<\/chname>/)
|
||||
{
|
||||
Log3 $name, 5 , "LGTV_IP12 ($name) - adding channel ".LGTV_IP12_html2txt($1);
|
||||
@ -568,7 +568,7 @@ LGTV_IP12_ParseHttpResponse($$$)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readingsEndUpdate($hash, 1);
|
||||
}
|
||||
|
||||
@ -581,7 +581,7 @@ LGTV_IP12_HttpGet($$$$;$)
|
||||
|
||||
if(defined($data))
|
||||
{
|
||||
Log3 $hash->{NAME}, 5 , "LGTV_IP12 (".$hash->{NAME}.") - sending POST request for command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\" to url $path: $data";
|
||||
Log3 $hash->{NAME}, 5 , "LGTV_IP12 (".$hash->{NAME}.") - sending POST request for command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\" to url $path: $data";
|
||||
# start a HTTP POST on the given url with content data
|
||||
HttpUtils_NonblockingGet({
|
||||
url => "http://".$hash->{HOST}.":8080".$path,
|
||||
@ -599,8 +599,8 @@ LGTV_IP12_HttpGet($$$$;$)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log3 $hash->{NAME}, 5 , "LGTV_IP12 (".$hash->{NAME}.") - sending GET request for command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\" to url $path";
|
||||
|
||||
Log3 $hash->{NAME}, 5 , "LGTV_IP12 (".$hash->{NAME}.") - sending GET request for command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\" to url $path";
|
||||
|
||||
# start a HTTP GET on the given url
|
||||
HttpUtils_NonblockingGet({
|
||||
url => "http://".$hash->{HOST}.":8080".$path,
|
||||
@ -623,8 +623,8 @@ sub
|
||||
LGTV_IP12_Pair($$)
|
||||
{
|
||||
my ($hash, $code) = @_;
|
||||
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/pairing", "pairing", $code, "<api type=\"pairing\"><name>hello</name><value>$code</value><port>8080</port></api>");
|
||||
|
||||
LGTV_IP12_HttpGet($hash, "/udap/api/pairing", "pairing", $code, "<api type=\"pairing\"><name>hello</name><value>$code</value><port>8080</port></api>");
|
||||
}
|
||||
|
||||
|
||||
@ -633,9 +633,9 @@ LGTV_IP12_Pair($$)
|
||||
sub LGTV_IP12_ResetTimer($;$)
|
||||
{
|
||||
my ($hash, $interval) = @_;
|
||||
|
||||
|
||||
RemoveInternalTimer($hash);
|
||||
|
||||
|
||||
unless(IsDisabled($hash->{NAME}))
|
||||
{
|
||||
if(defined($interval))
|
||||
@ -651,7 +651,7 @@ sub LGTV_IP12_ResetTimer($;$)
|
||||
InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "LGTV_IP12_GetStatus", $hash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return undef;
|
||||
}
|
||||
#############################
|
||||
@ -671,7 +671,7 @@ sub LGTV_IP12_html2txt($)
|
||||
$string =~ s/(\xfc|ü)/ü/g;
|
||||
$string =~ s/(\xdc|Ü)/Ü/g;
|
||||
$string =~ s/(\xdf|ß)/ß/g;
|
||||
|
||||
|
||||
$string =~ s/<.+?>//g;
|
||||
$string =~ s/(^\s+|\s+$)//g;
|
||||
|
||||
@ -683,7 +683,7 @@ sub LGTV_IP12_html2txt($)
|
||||
=pod
|
||||
=item device
|
||||
=item summary controls LG SmartTV's build between 2012-2014 via LAN connection
|
||||
=item summary_DE steuert LG SmartTV's, welche zwischen 2012-2014 hergestellt wurden, via LAN-Verbindung
|
||||
=item summary_DE steuert LG SmartTV's via LAN, welche zwischen 2012-2014 hergestellt wurden
|
||||
=begin html
|
||||
|
||||
<a name="LGTV_IP12"></a>
|
||||
@ -703,31 +703,31 @@ sub LGTV_IP12_html2txt($)
|
||||
define <name> LGTV_IP12 <ip-address> [<off_status_interval>] [<on_status_interval>]
|
||||
</code>
|
||||
<br><br>
|
||||
|
||||
|
||||
Defining a LGTV_IP12 device will schedule an internal task (interval can be set
|
||||
with optional parameter <status_interval> in seconds, if not set, the value is 30
|
||||
seconds), which periodically reads the status of the TV (power state, current channel, input, ...)
|
||||
and triggers notify/FileLog commands.
|
||||
<br><br>
|
||||
Different status update intervals depending on the power state can be given also.
|
||||
If two intervals are given to the define statement, the first interval statement represents the status update
|
||||
interval in seconds in case the device is off. The second
|
||||
Different status update intervals depending on the power state can be given also.
|
||||
If two intervals are given to the define statement, the first interval statement represents the status update
|
||||
interval in seconds in case the device is off. The second
|
||||
interval statement is used when the device is on.
|
||||
|
||||
|
||||
Example:<br><br>
|
||||
<ul><code>
|
||||
define TV LGTV_IP12 192.168.0.10
|
||||
<br><br>
|
||||
# With custom status interval of 60 seconds<br>
|
||||
define TV LGTV_IP12 192.168.0.10 60
|
||||
define TV LGTV_IP12 192.168.0.10 60
|
||||
<br><br>
|
||||
# With custom "off"-interval of 60 seconds and "on"-interval of 10 seconds<br>
|
||||
define TV LGTV_IP12 192.168.0.10 60 10
|
||||
</code></ul>
|
||||
|
||||
|
||||
</ul>
|
||||
<br><br>
|
||||
|
||||
|
||||
<a name="LGTV_IP12_set"></a>
|
||||
<b>Set </b>
|
||||
<ul>
|
||||
@ -769,7 +769,7 @@ sub LGTV_IP12_html2txt($)
|
||||
<li><a name="LGTV_IP12_disabledForIntervals">disabledForIntervals</a> HH:MM-HH:MM HH:MM-HH-MM...</li>
|
||||
Optional attribute to disable the internal cyclic status update of the TV during a specific time interval. The attribute contains a space separated list of HH:MM tupels.
|
||||
If the current time is between any of these time specifications, the cyclic update will be disabled.
|
||||
Instead of HH:MM you can also specify HH or HH:MM:SS.
|
||||
Instead of HH:MM you can also specify HH or HH:MM:SS.
|
||||
<br><br>To specify an interval spawning midnight, you have to specify two intervals, e.g.:
|
||||
<pre>23:00-24:00 00:00-01:00</pre>
|
||||
Default Value is <i>empty</i> (no intervals defined, cyclic update is always active)<br><br>
|
||||
@ -815,13 +815,13 @@ sub LGTV_IP12_html2txt($)
|
||||
define <name> LGTV_IP12 <IP-Addresse> [<Off_Interval>] [<On_Interval>]
|
||||
</code>
|
||||
<br><br>
|
||||
Bei der Definition eines LGTV_IP12-Moduls wird eine interne Routine in Gang gesetzt, welche regelmäßig
|
||||
Bei der Definition eines LGTV_IP12-Moduls wird eine interne Routine in Gang gesetzt, welche regelmäßig
|
||||
(einstellbar durch den optionalen Parameter <code><Status_Interval></code>; falls nicht gesetzt ist der Standardwert 30 Sekunden)
|
||||
den Status des TV abfragt und entsprechende Notify-/FileLog-Definitionen triggert.
|
||||
<br><br>
|
||||
Sofern 2 Interval-Argumente übergeben werden, wird der erste Parameter <code><Off_Interval></code> genutzt
|
||||
sofern der TV ausgeschaltet ist. Der zweiter Parameter <code><On_Interval></code>
|
||||
wird verwendet, sofern der TV eingeschaltet ist.
|
||||
sofern der TV ausgeschaltet ist. Der zweiter Parameter <code><On_Interval></code>
|
||||
wird verwendet, sofern der TV eingeschaltet ist.
|
||||
<br><br>
|
||||
Beispiel:<br><br>
|
||||
<ul><code>
|
||||
@ -847,9 +847,9 @@ sub LGTV_IP12_html2txt($)
|
||||
<li><b>channelUp</b> - schaltet auf den nächsten Kanal um </li>
|
||||
<li><b>channelDown</b> - schaltet auf den vorherigen Kanal um </li>
|
||||
<li><b>removePairing</b> - löscht das Pairing zwischen FHEM und dem TV</li>
|
||||
<li><b>showPairCode</b> - zeigt den Pair-Code auf dem TV-Bildschirm an. Dieser Code muss im Attribut <a href="#LGTV_IP12_pairingcode">pairingcode</a> gesetzt werden, damit FHEM mit dem TV kommunizieren kann.</li>
|
||||
<li><b>startApp</b> <Name> - startet eine installierte App</li>
|
||||
<li><b>stopApp</b> <Name> - stoppt eine laufende App</li>
|
||||
<li><b>showPairCode</b> - zeigt den Pair-Code auf dem TV-Bildschirm an. Dieser Code muss im Attribut <a href="#LGTV_IP12_pairingcode">pairingcode</a> gesetzt werden, damit FHEM mit dem TV kommunizieren kann.</li>
|
||||
<li><b>startApp</b> <Name> - startet eine installierte App</li>
|
||||
<li><b>stopApp</b> <Name> - stoppt eine laufende App</li>
|
||||
<li><b>statusRequest</b> - fragt den aktuellen Status ab</li>
|
||||
<li><b>remoteControl</b> up,down,... - sendet Fernbedienungsbefehle</li>
|
||||
</ul>
|
||||
@ -866,7 +866,7 @@ sub LGTV_IP12_html2txt($)
|
||||
<a name="LGTV_IP12_attr"></a>
|
||||
<b>Attribute</b>
|
||||
<ul>
|
||||
|
||||
|
||||
<li><a href="#do_not_notify">do_not_notify</a></li>
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
|
||||
<li><a name="LGTV_IP12_disable">disable</a></li>
|
||||
|
@ -15,14 +15,14 @@ sub
|
||||
CommandVersion($$)
|
||||
{
|
||||
my ($cl, $param) = @_;
|
||||
|
||||
|
||||
my $noheader = ($param =~ s/(?:^\s*|\s+)noheader\s*$//);
|
||||
|
||||
eval { "test" =~ /$param/ };
|
||||
return "invalid filter regexp" if($@);
|
||||
|
||||
|
||||
my @ret;
|
||||
my $max = 0;
|
||||
my $max = 0;
|
||||
my $modpath = (exists($attr{global}{modpath}) ? $attr{global}{modpath} : "");
|
||||
my @files = map {$INC{$_}} keys %INC;
|
||||
push @files, $0; # path to fhem.pl
|
||||
@ -30,7 +30,7 @@ CommandVersion($$)
|
||||
@files = () if($param && $param eq "revision");
|
||||
foreach my $fn (@files) {
|
||||
next unless($fn);
|
||||
next unless($fn =~ /^(?:$modpath.?)?FHEM/ or $fn =~ /fhem.pl$/); # configDB
|
||||
next unless($fn =~ /^(?:$modpath.?)?FHEM/ or $fn =~ /fhem.pl$/); # configDB
|
||||
my $mod_name = ($fn=~ /[\/\\]([^\/\\]+)$/ ? $1 : $fn);
|
||||
next if($param ne "" && $mod_name !~ /$param/);
|
||||
next if(grep(/$mod_name/, @ret));
|
||||
@ -39,7 +39,7 @@ CommandVersion($$)
|
||||
$max = length($mod_name) if($max < length($mod_name));
|
||||
|
||||
my $line;
|
||||
|
||||
|
||||
if(!open(FH, $fn)) {
|
||||
$line = "$fn: $!";
|
||||
if(configDBUsed()){
|
||||
@ -59,12 +59,12 @@ CommandVersion($$)
|
||||
$line = "No Id found for $mod_name" unless($line);
|
||||
push @ret, $line;
|
||||
}
|
||||
|
||||
|
||||
my $fhem_revision = version_getRevFromControls();
|
||||
|
||||
|
||||
$fhem_revision = "Latest Revision: $fhem_revision\n\n" if(defined($fhem_revision) && !$noheader);
|
||||
|
||||
@ret = map {/\$Id\: (\S+?) (\d+?) (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}Z \S+?) \$/ ? sprintf("%-".$max."s %5d %s",$1,$2,$3) : $_} @ret;
|
||||
|
||||
@ret = map {/\$Id\: (\S+?) (\d+?) (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}Z \S+?) \$/ ? sprintf("%-".$max."s %5d %s",$1,$2,$3) : $_} @ret;
|
||||
@ret = sort {version_sortModules($a, $b)} grep {($param ne "" ? /$param/ : 1)} @ret;
|
||||
return "no loaded modules found that match: $param" if($param ne "" && $param ne "revision" && !@ret);
|
||||
return (((!$param && !$noheader) || $param eq "revision") ? $fhem_revision : "").
|
||||
@ -81,14 +81,14 @@ sub version_sortModules($$)
|
||||
|
||||
$a =~ s/^(?:No Id found for |#\s*\$Id\: )//;
|
||||
$b =~ s/^(?:No Id found for |#\s*\$Id\: )//;
|
||||
|
||||
|
||||
my @a_vals = split(' ', $a);
|
||||
my @b_vals = split(' ', $b);
|
||||
|
||||
# fhem.pl always at top
|
||||
return -1 if($a_vals[0] eq "fhem.pl");
|
||||
return -1 if($a_vals[0] eq "fhem.pl");
|
||||
return 1 if($b_vals[0] eq "fhem.pl");
|
||||
|
||||
|
||||
$a_vals[0] =~ s/^\d\d_//;
|
||||
$b_vals[0] =~ s/^\d\d_//;
|
||||
|
||||
@ -130,7 +130,7 @@ sub version_getRevFromControls(;$)
|
||||
<code>version [<filter>|revision] [noheader]</code>
|
||||
<br><br>
|
||||
List the version of fhem.pl and all loaded modules. The optional parameter
|
||||
can be used to filter the ouput. The special filter value "revision" shows
|
||||
can be used to filter the ouput. The special filter value "revision" shows
|
||||
only the latest revision number since the last update.<br><br>
|
||||
The optional flag <code>noheader</code> disables the output of the header lines (Latest Revision, File, Rev, Last Change).
|
||||
<br><br>
|
||||
@ -152,16 +152,16 @@ sub version_getRevFromControls(;$)
|
||||
<br>
|
||||
Example output of <code>version fhem.pl</code>:
|
||||
<ul>
|
||||
<code><br>
|
||||
<code><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
</code>
|
||||
</ul>
|
||||
<br>
|
||||
Example output of <code>version fhem.pl noheader</code>:
|
||||
<ul>
|
||||
<code><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
<code><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
</code>
|
||||
</ul>
|
||||
</ul>
|
||||
@ -185,7 +185,7 @@ sub version_getRevFromControls(;$)
|
||||
<br><br>
|
||||
Beispiel der Ausgabe von <code>version</code>:
|
||||
<ul>
|
||||
<code><br>
|
||||
<code><br>
|
||||
Latest Revision: 10814<br><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10769 2016-02-08 12:11:51Z rudolfkoenig<br>
|
||||
@ -199,16 +199,16 @@ sub version_getRevFromControls(;$)
|
||||
<br>
|
||||
Beispiel der Ausgabe von <code>version fhem</code>:
|
||||
<ul>
|
||||
<code><br>
|
||||
<code><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10769 2016-02-08 12:11:51Z rudolfkoenig<br>
|
||||
fhem.pl 10769 2016-02-08 12:11:51Z rudolfkoenig<br>
|
||||
</code>
|
||||
</ul>
|
||||
<br>
|
||||
Beispiel der Ausgabe von <code>version fhem.pl noheader</code>:
|
||||
<ul>
|
||||
<code><br>
|
||||
fhem.pl 10769 2016-02-08 12:11:51Z rudolfkoenig<br>
|
||||
<code><br>
|
||||
fhem.pl 10769 2016-02-08 12:11:51Z rudolfkoenig<br>
|
||||
</code>
|
||||
</ul>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user