2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-29 11:27:08 +00:00

26_tahoma.pm:2014-10-18 V 0101 last Version using XML Interface

git-svn-id: https://svn.fhem.de/fhem/trunk@11676 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mike3436 2016-06-17 21:46:24 +00:00
parent 580c6d6506
commit 6a9b8d8aa1

View File

@ -26,6 +26,7 @@
# $Id: 26_tahoma.pm # $Id: 26_tahoma.pm
# #
# 2014-08-01 V 0100 first Version using XML Interface # 2014-08-01 V 0100 first Version using XML Interface
# 2014-10-09 V 0101
package main; package main;
@ -55,13 +56,14 @@ sub tahoma_Initialize($)
$hash->{GetFn} = "tahoma_Get"; $hash->{GetFn} = "tahoma_Get";
$hash->{AttrFn} = "tahoma_Attr"; $hash->{AttrFn} = "tahoma_Attr";
$hash->{AttrList} = "IODev ". $hash->{AttrList} = "IODev ".
"blocking ".
"debug:1 ". "debug:1 ".
"disable:1 ". "disable:1 ".
"interval ". "interval ".
"logfile ". "logfile ".
"proxy ".
"url ". "url ".
"userAgent ". "userAgent ";
"proxy ";
$hash->{AttrList} .= $readingFnAttributes; $hash->{AttrList} .= $readingFnAttributes;
} }
@ -133,7 +135,7 @@ sub tahoma_Define($$)
$hash->{username} = $username; $hash->{username} = $username;
$hash->{password} = $password; $hash->{password} = $password;
$hash->{BLOCKING} = 0;
$hash->{INTERVAL} = 2; $hash->{INTERVAL} = 2;
} else { } else {
@ -217,7 +219,7 @@ sub tahoma_login($)
'getSensorTriggers', 'getSensorTriggers',
'getUserPreferences', 'getUserPreferences',
'getSetupOptions', 'getSetupOptions',
'getAvailableProtocolsType', #'getAvailableProtocolsType',
'getActiveProtocolsType', 'getActiveProtocolsType',
'getSetupQuota', 'getSetupQuota',
'getSetupDawnAndDuskTimes' ); 'getSetupDawnAndDuskTimes' );
@ -689,14 +691,14 @@ sub tahoma_parseGetEvents($$)
#print Dumper($xml); #print Dumper($xml);
foreach my $devices ( @{$xml->{eventPollResponse}{events}{event}} ) { foreach my $devices ( @{$xml->{eventPollResponse}{events}{event}} ) {
if( defined($devices->{deviceURL}) ) { if( defined($devices->{deviceURL}) ) {
#print "\nDevice=$devices->{deviceURL} found\n"; print "\nDevice=$devices->{deviceURL} found\n";
my $id = $devices->{deviceURL}; my $id = $devices->{deviceURL};
my $fid = (split("/",$id))[-1]; my $fid = (split("/",$id))[-1];
my $devname = "tahoma_". $fid; my $devname = "tahoma_". $fid;
my $d = $modules{$hash->{TYPE}}{defptr}{"$fid"}; my $d = $modules{$hash->{TYPE}}{defptr}{"$fid"};
if( defined($d) && $d->{NAME} eq $devname ) if( defined($d) )# && $d->{NAME} eq $devname )
{ {
#print "\nDevice=$devices->{deviceURL} updated\n"; print "\nDevice=$devices->{deviceURL} updated\n";
readingsBeginUpdate($d); readingsBeginUpdate($d);
foreach my $state (@{$devices->{deviceStates}{state}}) { foreach my $state (@{$devices->{deviceStates}{state}}) {
#print "$devname $state->{name} = $state->{value}\n"; #print "$devname $state->{name} = $state->{value}\n";
@ -922,6 +924,9 @@ sub tahoma_Attr($$$)
} else { } else {
$attr{$name}{$attrName} = 0; $attr{$name}{$attrName} = 0;
} }
} elsif( $attrName eq "blocking" ) {
my $hash = $defs{$name};
$hash->{BLOCKING} = $attrVal;
} }
if( $cmd eq "set" ) { if( $cmd eq "set" ) {
@ -966,10 +971,10 @@ sub tahoma_UserAgent_NonblockingGet($)
my $response = ""; my $response = "";
my $url = $hash->{url} . $param->{page}; my $url = $hash->{url} . $param->{page};
$url .= $param->{subpage} if (defined $param->{subpage}); $url .= $param->{subpage} if ((defined $param->{subpage}) && !(substr($url,0,4) eq 'file'));
$url .= '.xml' if (substr($url,0,4) eq 'file'); $url .= '.xml' if (substr($url,0,4) eq 'file');
my $nonblocking = $param->{nonblocking} && !(substr($url,0,4) eq 'file'); my $nonblocking = !$hash->{BLOCKING} && $param->{nonblocking} && !(substr($url,0,4) eq 'file');
if ($param->{data} && !(substr($url,0,4) eq 'file')) if ($param->{data} && !(substr($url,0,4) eq 'file'))
{ {
@ -992,8 +997,10 @@ sub tahoma_UserAgent_NonblockingGet($)
$response = $agent->post( $url, content => $data, ':content_cb' => sub() $response = $agent->post( $url, content => $data, ':content_cb' => sub()
{ {
my ($content, $response, $protocol, $entry) = @_; my ($content, $response, $protocol, $entry) = @_;
#my $len = length $content;
#print "tahoma_UserAgent_NonblockingGet len=$len $content\n\n";
$param->{callback}($param, undef, $content); $param->{callback}($param, undef, $content);
return; #return;
} ); } );
} }
} }
@ -1004,8 +1011,10 @@ sub tahoma_UserAgent_NonblockingGet($)
$response = $agent->get( $url, ':content_cb' => sub() $response = $agent->get( $url, ':content_cb' => sub()
{ {
my ($content, $response, $protocol, $entry) = @_; my ($content, $response, $protocol, $entry) = @_;
#my $len = length $content;
#print "tahoma_UserAgent_NonblockingGet len=$len $content\n\n";
$param->{callback}($param, undef, $content); $param->{callback}($param, undef, $content);
return; #return;
} ); } );
} }
} }