2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 01:06:04 +00:00

vbs did some changes

git-svn-id: https://svn.fhem.de/fhem/trunk@6079 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
bentele 2014-06-07 08:54:16 +00:00
parent 5481b9e76b
commit 56faf322bf

View File

@ -29,21 +29,34 @@
############################################################################## ##############################################################################
package main; package main;
use strict;
use warnings;
use IO::Socket::INET; use IO::Socket::INET;
use Sys::Hostname; use Sys::Hostname;
use MIME::Base64; use MIME::Base64;
use DevIo;
my @gets = ('dummy'); my @gets = ('dummy');
sub sub
STV_Initialize($) STV_Initialize($)
{ {
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "STV_Define"; $hash->{DefFn} = "STV_Define";
$hash->{StateFn} = "STV_SetState"; $hash->{UndefFn} = "STV_Undefine";
$hash->{SetFn} = "STV_Set"; $hash->{StateFn} = "STV_SetState";
$hash->{AttrFn} = "STV_Attr"; $hash->{SetFn} = "STV_Set";
$hash->{AttrList} = "MAC"; $hash->{AttrFn} = "STV_Attr";
$hash->{ReadFn} = "STV_Read";
$hash->{ReadyFn} = "STV_Ready";
$hash->{AttrList} = "MAC fork:enable,disable setWhenOffline:execute,ignore " . $readingFnAttributes;;
}
sub STV_Undefine($$)
{
my ($hash,$arg) = @_;
DevIo_CloseDev($hash);
return undef;
} }
sub sub
@ -61,37 +74,93 @@ STV_SetState($$$$)
{ {
my ($hash, $tim, $vt, $val) = @_; my ($hash, $tim, $vt, $val) = @_;
$val = $1 if($val =~ m/^(.*) \d+$/); $val = $1 if($val =~ m/^(.*) \d+$/);
return "Undefined value $val" if(!defined($it_c2b{$val})); # return "Undefined value $val" if(!defined($it_c2b{$val}));
return undef; return undef;
} }
sub getIP() sub getIP()
{ {
my $host = hostname(); my $host = hostname();
my $address = inet_ntoa(scalar gethostbyname(hostname() || 'localhost')); my $address = inet_ntoa(scalar gethostbyname(hostname() || 'localhost'));
return "$address"; return "$address";
}
sub STV_Ready($)
{
my ($hash) = @_;
if(AttrVal($hash->{NAME},'fork','disable') eq 'enable') {
if($hash->{CHILDPID} && !(kill 0, $hash->{CHILDPID})) {
$hash->{CHILDPID} = undef;
return DevIo_OpenDev($hash, 1, "STV_Init");
}
elsif(!$hash->{CHILDPID}) {
return if($hash->{CHILDPID} = fork);
my $ppid = getppid();
### Copied from Blocking.pm
foreach my $d (sort keys %defs) { # Close all kind of FD
my $h = $defs{$d};
TcpServer_Close($h) if($h->{SERVERSOCKET});
if($h->{DeviceName}) {
require "$attr{global}{modpath}/FHEM/DevIo.pm";
DevIo_CloseDev($h,1);
}
}
### End of copied from Blocking.pm
while(kill 0, $ppid) {
DevIo_OpenDev($hash, 1, "STV_ChildExit");
sleep(5);
}
exit(0);
}
} else {
return DevIo_OpenDev($hash, 1, "STV_Init");
}
return undef;
}
sub STV_Read($)
{
my ($hash) = @_;
my $name = $hash->{NAME};
#we dont really expect data here. Its just to gracefully close the device if the connection was closed
my $buf = DevIo_SimpleRead($hash);
}
sub STV_Init($)
{
my ($hash) = @_;
return undef;
}
sub STV_ChildExit($)
{
exit(0);
} }
sub STV_Define($$) sub STV_Define($$)
{ {
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @args = split("[ \t]+", $def); DevIo_CloseDev($hash);
my @args = split("[ \t]+", $def);
if (int(@args) < 3) if (int(@args) < 3)
{ {
return "Define: not enough arguments. Usage:\n" . return "Define: not enough arguments. Usage:\n" .
"define <name> STV <host> <port>"; "define <name> STV <host> <port>";
} }
$hash->{Host} = $args[2]; $hash->{Host} = $args[2];
if (defined $args[3]) { if (defined $args[3]) {
$hash->{Port} = $args[3] $hash->{Port} = $args[3]
} else { } else {
$hash->{Port} = 52235; $hash->{Port} = 52235;
$hash->{".validcommands"} = "mute volume call sms date"; $hash->{".validcommands"} = "mute volume call sms date";
} }
if ( $hash->{Port} eq 55000 ){ if ( $hash->{Port} eq 55000 ){
$hash->{".validcommands"} = "0 1 2 3 4 5 6 7 8 9 UP DOWN LEFT RIGHT ENTER ". $hash->{".validcommands"} = "0 1 2 3 4 5 6 7 8 9 UP DOWN LEFT RIGHT ENTER ".
"MENU PRECH GUIDE INFO RETURN CH_LIST EXIT ". "MENU PRECH GUIDE INFO RETURN CH_LIST EXIT ".
"SOURCE AD PICTURE_SIZE VOLUP VOLDOWN MUTE ". "SOURCE AD PICTURE_SIZE VOLUP VOLDOWN MUTE ".
@ -99,72 +168,77 @@ sub STV_Define($$)
"RSS MTS SRS CAPTION TOPMENU SLEEP ESAVING ". "RSS MTS SRS CAPTION TOPMENU SLEEP ESAVING ".
"PLAY PAUSE REWIND FF REC STOP ". "PLAY PAUSE REWIND FF REC STOP ".
"TV HDMI PIP_ONOFF ASPECT EXT20"; "TV HDMI PIP_ONOFF ASPECT EXT20";
my $system = $^O; my $system = $^O;
if($system =~ m/Win/) { my $result;
$result = `ipconfig /all`; if($system =~ m/Win/) {
my @myarp=split(/\n/,$result); $result = `ipconfig /all`;
foreach (@myarp){ my @myarp=split(/\n/,$result);
if ( /([0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2})$/i ) foreach (@myarp){
{ if ( /([0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2})$/i )
$result = $1; {
$result =~ s/-/:/g; $result = $1;
} $result =~ s/-/:/g;
} }
}
}
if($system eq "linux") {
$result = `ifconfig -a`;
my @myarp=split(/\n/,$result);
foreach (@myarp){
if ( /^(lan|eth0) .*(..:..:..:..:..:..) .*$/ )
{
$result = $2;
}
}
}
# Fritzbox "? (192.168.0.1) at 00:0b:5d:91:fc:bb [ether] on lan"
# debian "192.168.0.1 ether c0:25:06:1f:3c:14 C eth0"
#$result = "? (192.168.0.1) at 00:0b:5d:91:fc:bb [ether] on lan";
$hash->{MAC} = $result;
$hash->{MyIP} = getIP();
$hash->{DeviceName} = $hash->{Host} . ":" . $hash->{Port};
my $dev = $hash->{DeviceName};
$readyfnlist{"$args[0].$dev"} = $hash;
}
if ( $hash->{Port} != 55000 && $hash->{Port} != 52235 ){
return "[STV] Port is not supported";
} }
if($system eq "linux") {
$result = `ifconfig -a`;
my @myarp=split(/\n/,$result);
foreach (@myarp){
if ( /^(lan|eth0) .*(..:..:..:..:..:..) .*$/ )
{
$result = $2;
}
}
}
# Fritzbox "? (192.168.0.1) at 00:0b:5d:91:fc:bb [ether] on lan"
# debian "192.168.0.1 ether c0:25:06:1f:3c:14 C eth0"
#$result = "? (192.168.0.1) at 00:0b:5d:91:fc:bb [ether] on lan";
$hash->{MAC} = $result; Log3 undef, 3, "[STV] defined with host: $hash->{Host} port: $hash->{Port} MAC: $hash->{MAC}";
$hash->{MyIP} = getIP(); $hash->{STATE} = 'Initialized';
} return undef;
if ( $hash->{Port} != 55000 && $hash->{Port} != 52235 ){
return "[STV] Port is not supported";
}
Log3 undef, 3, "[STV] defined with host: $hash->{Host} port: $hash->{Port} MAC: $hash->{MAC}";
$hash->{STATE} = 'Initialized';
return undef;
} }
sub connection($$) sub connection($$)
{ {
my $tmp = shift ; my $tmp = shift ;
Log3 undef, 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 = "";
my $sock = new IO::Socket::INET ( my $sock = new IO::Socket::INET (
PeerAddr => $TV, PeerAddr => $TV,
PeerPort => '52235', PeerPort => '52235',
Proto => 'tcp', Proto => 'tcp',
Timout => 5 Timout => 5
); );
if (defined ($sock)){ if (defined ($sock)){
print $sock $tmp; print $sock $tmp;
my $buff =""; my $buff ="";
while ((read $sock, $buff, 1) > 0){ while ((read $sock, $buff, 1) > 0){
$buffer .= $buff; $buffer .= $buff;
} }
@tmp2 = split (/\n/,$buffer); @tmp2 = split (/\n/,$buffer);
$sock->close(); $sock->close();
Log3 undef, 4, "[STV] $TV: socket closed"; Log3 undef, 4, "[STV] $TV: socket closed";
}else{ }else{
Log3 undef, 4, "[STV] $TV: not able to close socket"; Log3 undef, 4, "[STV] $TV: not able to close socket";
} }
} }
# new Samsung Models # new Samsung Models
@ -174,7 +248,6 @@ sub STV_55000($$$)
my $par=undef; my $par=undef;
my @ARGV = split(" ",$cmd); my @ARGV = split(" ",$cmd);
#### Configuration #### Configuration
my $name = $hash->{NAME};
my $tv = "UE46ES8090"; # Might need changing to match your TV type #"UE46ES8090" my $tv = "UE46ES8090"; # Might need changing to match your TV type #"UE46ES8090"
my $port = $hash->{Port}; # TCP port of Samsung TV my $port = $hash->{Port}; # TCP port of Samsung TV
my $tvip = $hash->{Host}; # IP Address of TV #"192.168.2.124" my $tvip = $hash->{Host}; # IP Address of TV #"192.168.2.124"
@ -186,60 +259,60 @@ 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$/) {
Log3 $name, 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.";
} }
Log3 $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,
Proto => 'tcp', Proto => 'tcp',
Timout => 5 Timout => 5
); );
if (defined ($sock)){
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;
print $sock $part1;
my $messagepart2 = chr(0xc8) . chr(0x00); if (defined ($sock)){
my $part2 = chr(0x00) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart2)) . chr(0x00) . $messagepart2; 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, "");
print $sock $part2; my $part1 = chr(0x00) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart1)) . chr(0x00) . $messagepart1;
# Preceding sections all first time only print $sock $part1;
if (defined($par)) { my $messagepart2 = chr(0xc8) . chr(0x00);
# Send text, e.g. in YouTube app's search, N.B. NOT BBC iPlayer app. my $part2 = chr(0x00) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart2)) . chr(0x00) . $messagepart2;
my $text = $par; print $sock $part2;
my $messagepart3 = chr(0x01) . chr(0x00) . chr(length(encode_base64($text, ""))) . chr(0x00) . encode_base64($text, ""); # Preceding sections all first time only
my $part3 = chr(0x01) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart3)) . chr(0x00) . $messagepart3;
print $sock $part3;
}
else {
foreach my $argnum (0 .. $#ARGV) {
# Send remote key(s)
#Log4 $name, 4, "[STV] sending ".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 $part3 = chr(0x00) . chr(length($tvappstring)) . chr(0x00) . $tvappstring . chr(length($messagepart3)) . chr(0x00) . $messagepart3;
print $sock $part3;
sleep(1);
# select(undef, undef, undef, 0.5);
}
}
close($sock); if (defined($par)) {
}else{ # Send text, e.g. in YouTube app's search, N.B. NOT BBC iPlayer app.
#Log5 $name, 3, "[STV] Could not create socket. Aborting." unless $sock; my $text = $par;
} my $messagepart3 = chr(0x01) . chr(0x00) . chr(length(encode_base64($text, ""))) . chr(0x00) . encode_base64($text, "");
my $part3 = chr(0x01) . chr(length($appstring)) . chr(0x00) . $appstring . chr(length($messagepart3)) . chr(0x00) . $messagepart3;
print $sock $part3;
}
else {
foreach my $argnum (0 .. $#ARGV) {
# Send remote key(s)
#Log4 $name, 4, "[STV] sending ".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 $part3 = chr(0x00) . chr(length($tvappstring)) . chr(0x00) . $tvappstring . chr(length($messagepart3)) . chr(0x00) . $messagepart3;
print $sock $part3;
sleep(1);
# select(undef, undef, undef, 0.5);
}
}
close($sock);
}else{
#Log5 $name, 3, "[STV] Could not create socket. Aborting." unless $sock;
}
} }
} }
# old Samsung Models # old Samsung Models
sub STV_52235($@$@) sub STV_52235($@)
{ {
my ($hash, @a) = @_; my ($hash, @a) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $TV = $hash->{Host}; my $TV = $hash->{Host};
@ -270,79 +343,79 @@ sub STV_52235($@$@)
my $size = ""; my $size = "";
my $body = ""; my $body = "";
if ( $arg eq "mute" ) if ( $arg eq "mute" )
{ {
$kind = 1; $kind = 1;
if ( $cont2 eq "off" ){ if ( $cont2 eq "off" ){
$cont2 = 0 ; $cont2 = 0 ;
}else { }else {
$cont2 = 1 ; $cont2 = 1 ;
} }
} }
if ( $arg eq "volume") if ( $arg eq "volume")
{ {
if ( $cont2 > 0 and $cont2 < 100 ){ if ( $cont2 > 0 and $cont2 < 100 ){
$kind = 1; $kind = 1;
}else { }else {
Log3 $name, 3, "[STV] $name Volume: not correct"; Log3 $name, 3, "[STV] $name Volume: not correct";
$kind = 0; $kind = 0;
} }
} }
if ( $arg eq "call") if ( $arg eq "call")
{ {
$kind = 2; $kind = 2;
} }
if ( $arg eq "sms") if ( $arg eq "sms")
{ {
$kind = 3; $kind = 3;
for my $i (6..$count){ for my $i (6..$count){
$body .= $a[$i]; $body .= $a[$i];
$body .= " "; $body .= " ";
} }
} }
if ( $arg eq "date") if ( $arg eq "date")
{ {
$kind = 4; $kind = 4;
for my $i (10..$count){ for my $i (10..$count){
$body .= $a[$i]; $body .= $a[$i];
$body .= " "; $body .= " ";
} }
} }
if ( $kind eq 1){ if ( $kind eq 1){
$callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"; $callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
$callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n"; $callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
$callsoap .= "<s:Body>\r\n"; $callsoap .= "<s:Body>\r\n";
$callsoap .= "<ns0:Set$cont1 xmlns:ns0=\"urn:schemas-upnp-org:service:RenderingControl:1\">\r\n"; $callsoap .= "<ns0:Set$cont1 xmlns:ns0=\"urn:schemas-upnp-org:service:RenderingControl:1\">\r\n";
$callsoap .= "<InstanceID>0</InstanceID>\r\n"; $callsoap .= "<InstanceID>0</InstanceID>\r\n";
$callsoap .= "<Desired$cont1>$cont2</Desired$cont1>\r\n"; $callsoap .= "<Desired$cont1>$cont2</Desired$cont1>\r\n";
$callsoap .= "<Channel>Master</Channel>\r\n"; $callsoap .= "<Channel>Master</Channel>\r\n";
$callsoap .= "</ns0:Set$cont1>\r\n"; $callsoap .= "</ns0:Set$cont1>\r\n";
$callsoap .= "</s:Body>\r\n"; $callsoap .= "</s:Body>\r\n";
$callsoap .= "</s:Envelope>\r\n"; $callsoap .= "</s:Envelope>\r\n";
$size = length($callsoap); $size = length($callsoap);
$head .= "POST /upnp/control/RenderingControl1 HTTP/1.1\r\n"; $head .= "POST /upnp/control/RenderingControl1 HTTP/1.1\r\n";
$head .= "Content-Type: text/xml; charset=\"utf-8\"\r\n"; $head .= "Content-Type: text/xml; charset=\"utf-8\"\r\n";
$head .= "SOAPACTION: \"SoapAction:urn:schemas-upnp-org:service:RenderingControl:1#Set$cont1\"\r\n"; $head .= "SOAPACTION: \"SoapAction:urn:schemas-upnp-org:service:RenderingControl:1#Set$cont1\"\r\n";
$head .= "Cache-Control: no-cache\r\n"; $head .= "Cache-Control: no-cache\r\n";
$head .= "Host: $TV:52235\r\n"; $head .= "Host: $TV:52235\r\n";
$head .= "Content-Length: $size\r\n"; $head .= "Content-Length: $size\r\n";
$head .= "Connection: Close\r\n"; $head .= "Connection: Close\r\n";
$head .= "\r\n"; $head .= "\r\n";
$message .= $head; $message .= $head;
$message .= $callsoap; $message .= $callsoap;
} }
my $calldate=`date +"%Y-%m-%d"`; my $calldate=`date +"%Y-%m-%d"`;
chomp($calldate); chomp($calldate);
my $calltime=`date +"%H:%M:%S"`; my $calltime=`date +"%H:%M:%S"`;
chomp($calltime); chomp($calltime);
if ( $kind eq 2 ){ # CALL if ( $kind eq 2 ){ # CALL
$callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"; $callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
$callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" >\r\n"; $callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" >\r\n";
$callsoap .= "<s:Body>\r\n"; $callsoap .= "<s:Body>\r\n";
@ -383,7 +456,7 @@ if ( $kind eq 2 ){ # CALL
$message .= $callsoap; $message .= $callsoap;
} }
if ( $kind eq 3 ){ # SMS if ( $kind eq 3 ){ # SMS
$callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"; $callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
$callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" >\r\n"; $callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" >\r\n";
$callsoap .= "<s:Body>\r\n"; $callsoap .= "<s:Body>\r\n";
@ -405,7 +478,7 @@ if ( $kind eq 3 ){ # SMS
$callsoap .= "&lt;Name&gt;Von: $cont2&lt;/Name&gt;\r\n"; $callsoap .= "&lt;Name&gt;Von: $cont2&lt;/Name&gt;\r\n";
$callsoap .= "&lt;Number&gt;Nr: $cont3&lt;/Number&gt;\r\n"; $callsoap .= "&lt;Number&gt;Nr: $cont3&lt;/Number&gt;\r\n";
$callsoap .= "&lt;/Sender&gt;\r\n"; $callsoap .= "&lt;/Sender&gt;\r\n";
$callsoap .= "&lt;Body&gt;Inhalt: $body&lt;/Body&gt;\r\n"; $callsoap .= "&lt;Body&gt;Inhalt: $body&lt;/Body&gt;\r\n";
$callsoap .= "</Message>\r\n"; $callsoap .= "</Message>\r\n";
$callsoap .= "</u:AddMessage>\r\n"; $callsoap .= "</u:AddMessage>\r\n";
$callsoap .= "</s:Body>\r\n"; $callsoap .= "</s:Body>\r\n";
@ -425,7 +498,7 @@ if ( $kind eq 3 ){ # SMS
$message .= $callsoap; $message .= $callsoap;
} }
if ( $kind eq 4 ){ # Termin if ( $kind eq 4 ){ # Termin
$callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"; $callsoap .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
$callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" >\r\n"; $callsoap .= "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" >\r\n";
$callsoap .= "<s:Body>\r\n"; $callsoap .= "<s:Body>\r\n";
@ -439,11 +512,11 @@ if ( $kind eq 4 ){ # Termin
$callsoap .= "&lt;Date&gt;$cont2&lt;/Date&gt;\r\n"; $callsoap .= "&lt;Date&gt;$cont2&lt;/Date&gt;\r\n";
$callsoap .= "&lt;Time&gt;$cont3&lt;/Time&gt;\r\n"; $callsoap .= "&lt;Time&gt;$cont3&lt;/Time&gt;\r\n";
$callsoap .= "&lt;/StartTime&gt;\r\n"; $callsoap .= "&lt;/StartTime&gt;\r\n";
$callsoap .= "&lt;Owner&gt;\r\n"; $callsoap .= "&lt;Owner&gt;\r\n";
$callsoap .= "&lt;Name&gt;Fr: $cont4&lt;/Name&gt;\r\n"; $callsoap .= "&lt;Name&gt;Fr: $cont4&lt;/Name&gt;\r\n";
$callsoap .= "&lt;Number&gt;Nr: $cont5&lt;/Number&gt;\r\n"; $callsoap .= "&lt;Number&gt;Nr: $cont5&lt;/Number&gt;\r\n";
$callsoap .= "&lt;/Owner&gt;\r\n"; $callsoap .= "&lt;/Owner&gt;\r\n";
$callsoap .= "&lt;Subject&gt;Betreff: $cont6&lt;/Subject&gt;\r\n"; $callsoap .= "&lt;Subject&gt;Betreff: $cont6&lt;/Subject&gt;\r\n";
$callsoap .= "&lt;EndTime&gt;\r\n"; $callsoap .= "&lt;EndTime&gt;\r\n";
$callsoap .= "&lt;Date&gt;$cont7&lt;/Date&gt;\r\n"; $callsoap .= "&lt;Date&gt;$cont7&lt;/Date&gt;\r\n";
$callsoap .= "&lt;Time&gt;$cont8&lt;/Time&gt;\r\n"; $callsoap .= "&lt;Time&gt;$cont8&lt;/Time&gt;\r\n";
@ -467,13 +540,13 @@ if ( $kind eq 4 ){ # Termin
$message .= $head; $message .= $head;
$message .= $callsoap; $message .= $callsoap;
} }
if ( $kind ne 0 ){ if ( $kind ne 0 ){
connection($message, $TV); connection($message, $TV);
}else{ }else{
return "Unknown argument $name, choose one of mute volume call sms date"; return "Unknown argument $name, choose one of mute volume call sms date";
} }
} }
sub STV_Set($@) sub STV_Set($@)
@ -488,20 +561,25 @@ sub STV_Set($@)
return $hash->{".validcommands"}; return $hash->{".validcommands"};
} }
if ($hash->{".validcommands"} =~ /$cmd/) { if ($hash->{".validcommands"} =~ /$cmd/) {
if ($Port eq 55000 ){ if ((AttrVal($name, "setWhenOffline", undef) eq "ignore") and ($hash->{STATE} ne "opened")) {
STV_55000($hash,$nam,$cmd); Log3 $name, 3, "[STV] Device seems offline. Set command ignored: $cmd";
} return;
if ($Port eq 52235 ){ }
STV_52235($hash,@_);
} if ($Port eq 55000 ){
STV_55000($hash,$nam,$cmd);
}
if ($Port eq 52235 ){
STV_52235($hash,@_);
}
} else { } else {
my $ret = "[STV] Invalid command $cmd. Use any of:\n"; my $ret = "[STV] Invalid command $cmd. Use any of:\n";
my @cmds = split(" ",$hash->{".validcommands"}); my @cmds = split(" ",$hash->{".validcommands"});
foreach my $line (0..$#cmds) { foreach my $line (0..$#cmds) {
$ret .= "\n" if ($line > 1 && $line/10 == int($line/10)); $ret .= "\n" if ($line > 1 && $line/10 == int($line/10));
$ret .= $cmds[$line]." "; $ret .= $cmds[$line]." ";
} }
return $ret; return $ret;
} }
} }