From 197ccea4054f50c9939ae7c680af524a160e16c8 Mon Sep 17 00:00:00 2001 From: sailor-fhem <> Date: Fri, 16 Jan 2015 18:42:02 +0000 Subject: [PATCH] 73_km200.pm: Bugfix and DoNotPoll hierarchy git-svn-id: https://svn.fhem.de/fhem/trunk@7589 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/73_km200.pm | 97 ++++++++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/fhem/FHEM/73_km200.pm b/fhem/FHEM/73_km200.pm index 4fdd5bad5..6da8ef47f 100644 --- a/fhem/FHEM/73_km200.pm +++ b/fhem/FHEM/73_km200.pm @@ -1,4 +1,4 @@ -# $Id: 73_km200.pm 0037 2015-01-14 16:00:00Z Matthias_Deeke $ +# $Id: 73_km200.pm 0038 2015-01-16 19:30:00Z Matthias_Deeke $ ######################################################################################################################## # # 73_km200.pm @@ -132,9 +132,13 @@ # 0036 13.01.2015 Sailor km200_GetDynService Preparing DbLog Split # 0036 13.01.2015 Sailor km200_GetStatService Preparing DbLog Split # 0036 13.01.2015 Sailor =pod Correction of errors and German description added -# 0037 14.01.2015 Sailor km200_DbLog_splitFn Try-out DbLog Split +# 0037 14.01.2015 Sailor km200_DbLog_splitFn Try-out DbLog Split (Failed... no name of device handed over in event) # 0037 14.01.2015 Sailor =pod Correction of errors # 0037 14.01.2015 Sailor km200_Attr Readings are being deleted if set not to be polled by attribute +# 0038 16.01.2015 Sailor km200_Attr Implementing hierarchy top-down in DoNotPoll +# 0038 16.01.2015 Sailor km200_ParseHttpResponseInit Implementing hierarchy top-down in DoNotPoll +# 0038 16.01.2015 Sailor =pod Implementing hierarchy top-down in DoNotPoll +# 0038 16.01.2015 Sailor del_double Adding a helper to delete double entries in arrays ######################################################################################################################## @@ -203,7 +207,7 @@ sub km200_Define($$) my $url = $a[2]; my $km200_gateway_password = $a[3]; my $km200_private_password = $a[4]; - my $ModuleVersion = "0037"; + my $ModuleVersion = "0038"; $hash->{NAME} = $name; $hash->{STATE} = "define"; @@ -558,18 +562,17 @@ sub km200_Define($$) if ($Km200Info eq "ERROR") { ## Communication with Gateway WRONG !! ## - $hash->{STATE}="Error - No Communication"; return ($name .": km200 - ERROR - The communication between fhem and the Buderus KM200 failed! \n". - " Please check physical connection, IP-address and passwords! \n"); + " Please check physical connection, IP-address and passwords! \n"); } - elsif ($Km200Info eq "SERVICE NOT AVAILABLE") + elsif ($Km200Info eq "SERVICE NOT AVAILABLE") ## Communication OK but service not available ## { - Log3 $name, 5, $name. " : km200 - /gateway/DateTime : NOT AVAILABLE"; ## Communication OK but service not available ## + Log3 $name, 5, $name. " : km200 - /gateway/DateTime : NOT AVAILABLE"; } - else + else ## Communication OK and service is available ## { - Log3 $name, 5, $name. " : km200 - /gateway/DateTime : " .$Km200Info->{value}; ## Communication OK and service is available ## + Log3 $name, 5, $name. " : km200 - /gateway/DateTime : AVAILABLE"; } ####END####### Check whether communication to the physical unit is possible ################################END##### @@ -752,7 +755,21 @@ sub km200_Attr(@) RemoveInternalTimer($hash); ####END#### Stop the current timer - ###START###### Filter all services not to be polled out of known services = AllServices (new) #############START#### + + ###START###### Filter all services not to be polled out of known services = AllServices (new) #########START#### + + ### Search for all Services in @KM200_AllServices which containing the Service(hierarchy) not to be polled + my @KM200_DONOTPOLLTEMP = @KM200_DONOTPOLL; + foreach my $SearchWord(@KM200_DONOTPOLLTEMP) + { + my @DONOTPOLLGREP = grep {/^$SearchWord/}@KM200_AllServices; + @KM200_DONOTPOLL = (@KM200_DONOTPOLL, @DONOTPOLLGREP); + } + + ### Delete double entries in array + @KM200_DONOTPOLL = &del_double(@KM200_DONOTPOLL); + + ### For each Service not to be polled: Delete the Service from @KM200_AllServices and delete the reading in fhem foreach my $SearchWord(@KM200_DONOTPOLL) { my $FoundPosition = first_index{ $_ eq $SearchWord }@KM200_AllServices; @@ -765,15 +782,18 @@ sub km200_Attr(@) fhem( "deletereading $name $SearchWord" ); } } + + ### Save list of services to be polled to hash @{$hash->{Secret}{KM200ALLSERVICES}} = @KM200_AllServices; - ####END####### Filter all services not to be polled out of known services = AllServices (new) ##############END##### + + ####END####### Filter all services not to be polled out of known services = AllServices (new) ##########END##### Log3 $name, 5, $name. " : km200 - The following services will not be polled: ". @KM200_DONOTPOLL; - ###START###### Initiate the timer for first time polling of values from KM200 but wait 5s ################START#### + ###START###### Initiate the timer for first time polling of values from KM200 but wait 5s ############START#### InternalTimer(gettimeofday()+5, "km200_GetInitService", $hash, 0); Log3 $name, 5, $name. " : km200 - Internal timer for Init of services restarted after services set by attribute not to be polled."; - ####END####### Initiate the timer for first time polling of values from KM200 but wait 60s ################END##### + ####END####### Initiate the timer for first time polling of values from KM200 but wait 60s ############END##### } ### If no attributes of the above known ones have been selected else @@ -901,6 +921,16 @@ sub str_repeat($$) ####END######## Repeats "string" for "count" times #############################################################END##### +###START####### Removes double entries in arrays ##############################################################START#### +sub del_double +{ +my %all; +$all{$_}=0 for @_; +return (keys %all); +} +####END######## Removes double entries in arrays ###############################################################END##### + + ###START###### Subroutine Encrypt Data ########################################################################START#### sub km200_Encrypt($) { @@ -1124,7 +1154,7 @@ sub km200_GetSingleService($) else { Log3 $name, 4, $name. " : km200_GetSingleService: ". $Service . " NOT available"; - if ($hash->{CONSOLEMESSAGE} == true) {print "The following Service CANNOT be read : $Service \n";} + if ($hash->{CONSOLEMESSAGE} == true) {print "The following Service CANNOT be read : $Service \n";} } @@ -1254,13 +1284,13 @@ sub km200_ParseHttpResponseInit($) ### Check whether service is writeable and write name of service in array if ($json->{writeable} == 1) { - if ($hash->{CONSOLEMESSAGE} == true) {print " and is writeable";} + if ($hash->{CONSOLEMESSAGE} == true) {print " and is writeable ";} push (@KM200_WriteableServices, $Service); } else { # Do nothing - if ($hash->{CONSOLEMESSAGE} == true) {print " ";} + if ($hash->{CONSOLEMESSAGE} == true) {print " ";} } ### Check whether service is writeable and write name of service in array @@ -1276,7 +1306,7 @@ sub km200_ParseHttpResponseInit($) else { Log3 $name, 4, $name. " : km200_ParseHttpResponseInit: ". $Service . " NOT available"; - if ($hash->{CONSOLEMESSAGE} == true) {print "The following Service CANNOT be read : $Service \n";} + if ($hash->{CONSOLEMESSAGE} == true) {print "The following Service CANNOT be read : $Service \n";} } ### Log entries for debugging purposes @@ -1308,10 +1338,25 @@ sub km200_ParseHttpResponseInit($) } ####END####### Filter all static services out of responsive services = responsive dynamic services #########END##### + ###START###### Filter all responsive services out of known static services = responsive static services ###START#### + my @KM200_StatServices = (); + + foreach my $SearchWord(@KM200_RespondingServices) + { + my $FoundPosition = first_index{ $_ eq $SearchWord }@{$hash->{Secret}{KM200STATSERVICES}}; + if ($FoundPosition >= 0) + { + push (@KM200_StatServices, $SearchWord); + } + } + ####END####### Filter all responsive services out of known static services = responsive static services ####END##### + + ### Save arrays of services in hash @{$hash->{Secret}{KM200RESPONDINGSERVICES}} = @KM200_RespondingServices; @{$hash->{Secret}{KM200WRITEABLESERVICES}} = @KM200_WriteableServices; @{$hash->{Secret}{KM200DYNSERVICES}} = @KM200_DynServices; + @{$hash->{Secret}{KM200STATSERVICES}} = @KM200_StatServices; ### Save arrays of services in hash $hash->{status}{FlagInitRequest} = false; @@ -1793,7 +1838,8 @@ sub km200_ParseHttpResponseStat($)
DoNotPoll
: <service> : | Der Name des Service welcher ausgelesen werden soll. Z.B.: "/heatingCircuits/hc1/operationMode "- Es gibt nur den Wert, aber nicht die Werteliste oder den möglichen Wertebereich zurück. + Es gibt nur den Wert, aber nicht die Werteliste oder den möglichen Wertebereich zurück. |
IntervalDynVal
: IntervalStatVal
: PollingTimeout
: ConsoleMessage
: DoNotPoll
: