From 1cb77c3ec9cc0ec8be78bd06d1c7ab091ea19e62 Mon Sep 17 00:00:00 2001 From: mike3436 <> Date: Sun, 7 May 2017 21:52:10 +0000 Subject: [PATCH] 26_tahoma.pm:V0214 encryption can be disabled, setClosureAndLinearSpeed corrected git-svn-id: https://svn.fhem.de/fhem/trunk@14213 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/26_tahoma.pm | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/26_tahoma.pm b/fhem/FHEM/26_tahoma.pm index 303b0d076..d838e3168 100644 --- a/fhem/FHEM/26_tahoma.pm +++ b/fhem/FHEM/26_tahoma.pm @@ -1,4 +1,5 @@ # $Id$ +# $Id$ ################################################################ # # Copyright notice @@ -43,6 +44,8 @@ # 2017-01-24 V 0212 Attribut interval used to disable or enable refreshAllstates # 2017-01-24 V 0212 Setup changes recognized for reading places # 2017-03-23 V 0213 username and password stored encrypted +# 2017-05-07 V 0214 encryption can be disabled by new attribut cryptLoginData +# 2017-05-07 V 0214 correct parameters of setClosureAndLinearSpeed caused syntax error package main; @@ -83,6 +86,7 @@ sub tahoma_Initialize($) "url ". "placeClasses ". "levelInvert ". + "cryptLoginData ". "userAgent "; $hash->{AttrList} .= $readingFnAttributes; } @@ -95,7 +99,7 @@ sub tahoma_Define($$) my @a = split("[ \t][ \t]*", $def); - my $ModuleVersion = "0213"; + my $ModuleVersion = "0214"; my $subtype; my $name = $a[0]; @@ -150,13 +154,11 @@ sub tahoma_Define($$) } elsif( $a[2] eq "ACCOUNT" && @a == 5 ) { $subtype = "ACCOUNT"; - my $username = tahoma_encrypt($a[@a-2]); - my $password = tahoma_encrypt($a[@a-1]); - + my $username = $a[@a-2]; + my $password = $a[@a-1]; + $hash->{Clients} = ":tahoma:"; - $hash->{DEF} = "$subtype $username $password"; - $hash->{helper}{username} = $username; $hash->{helper}{password} = $password; $hash->{BLOCKING} = 0; @@ -193,6 +195,24 @@ sub tahoma_Notify($$) return if($dev->{NAME} ne "global"); return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})); + if( $hash->{SUBTYPE} eq "ACCOUNT" ) + { + my $name = $hash->{NAME}; + my $username = $hash->{helper}{username}; + my $password = $hash->{helper}{password}; + if ((defined $attr{$name}{cryptLoginData}) && (not $attr{$name}{cryptLoginData})) + { + $username = tahoma_decrypt($username); + $password = tahoma_decrypt($password); + } + else + { + $username = tahoma_encrypt($username); + $password = tahoma_encrypt($password); + } + $hash->{DEF} = "$hash->{SUBTYPE} $username $password"; + } + tahoma_connect($hash) if( $hash->{SUBTYPE} eq "ACCOUNT" ); tahoma_initDevice($hash) if( $hash->{SUBTYPE} eq "DEVICE" ); tahoma_initDevice($hash) if( $hash->{SUBTYPE} eq "PLACE" ); @@ -683,6 +703,8 @@ sub tahoma_applyRequest($$$) $dataHead .= ' - Schliessen - iPhone","actions":['; } elsif ($commandChecked eq 'open') { $dataHead .= ' - Oeffnen - iPhone","actions":['; + } elsif ($commandChecked eq 'setClosureAndLinearSpeed') { #neu fuer setClosureAndLinearSpeed + $dataHead .= ' - Positionieren auf '.(split(',',$valueChecked))[0].' % - iPhone","actions":['; #neu fuer setClosureAndLinearSpeed } else { $dataHead .= " - $commandChecked $valueChecked".' - iPhone","actions":['; } @@ -1454,6 +1476,8 @@ sub tahoma_decrypt($) my $key = getUniqueId(); my $decoded; + return $encoded if not ( $encoded =~ /^crypt:(.*)/ ); + $encoded = $1 if( $encoded =~ /^crypt:(.*)/ ); for my $char (map { pack('C', hex($_)) } ($encoded =~ /(..)/g)) { @@ -1514,6 +1538,10 @@ sub tahoma_decrypt($) Normally, the web commands will be send asynchron, and this can be forced to wait of the result by blocking=1
attr tahoma1 blocking 1
+
local Attributes for DEVICE: