From aa273cc8ef660026c3734ffd6d76602c68a9eb53 Mon Sep 17 00:00:00 2001 From: zap <> Date: Sun, 18 Feb 2024 16:16:02 +0000 Subject: [PATCH] HMCCU: Fixed device detection bug git-svn-id: https://svn.fhem.de/fhem/trunk@28531 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/88_HMCCU.pm | 57 ++++++---------------------------------- fhem/FHEM/88_HMCCUDEV.pm | 36 ------------------------- fhem/FHEM/HMCCUConf.pm | 2 ++ 4 files changed, 11 insertions(+), 85 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index d67cde308..aadbe1752 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 88_HMCCU: fixed device detection bug - feature: 93_DbRep: sqlCmd executing ckey:latest possible - new: 73_PRESENCE2: cover version von 73_PRESENCE.pm - change: 76_SolarForecast: fillup AI data with sun azimuth / altitude diff --git a/fhem/FHEM/88_HMCCU.pm b/fhem/FHEM/88_HMCCU.pm index ba1818020..f6b5260b5 100755 --- a/fhem/FHEM/88_HMCCU.pm +++ b/fhem/FHEM/88_HMCCU.pm @@ -291,8 +291,6 @@ sub HMCCU_GetDeviceModel ($$$;$); sub HMCCU_GetDeviceName ($$;$); sub HMCCU_GetDeviceType ($$$); sub HMCCU_GetFirmwareVersions ($$); -sub HMCCU_GetGroupMembers ($$); -sub HMCCU_GetMatchingDevices ($$$$); sub HMCCU_GetParamDef ($$$;$); sub HMCCU_GetReceivers ($$$); sub HMCCU_IsValidChannel ($$$); @@ -3804,14 +3802,12 @@ sub HMCCU_GetDeviceConfig ($) $clHash->{ccudevstate} = 'inactive'; next; } + HMCCU_SetSCAttributes ($ioHash, $clHash); HMCCU_UpdateDevice ($ioHash, $clHash); HMCCU_UpdateDeviceRoles ($ioHash, $clHash); - -# my ($sc, $sd, $cc, $cd) = HMCCU_GetSCDatapoints ($clHash); - + HMCCU_SetDefaultSCDatapoints ($ioHash, $clHash); HMCCU_UpdateRoleCommands ($ioHash, $clHash); -# HMCCU_UpdateAdditionalCommands ($ioHash, $clHash, $cc, $cd); } return ($cDev, $cPar, $cLnk); @@ -5852,31 +5848,6 @@ sub HMCCU_GetValidChannelParameters ($$$;$) return $count; } -###################################################################### -# Get list of device or channel addresses for which device or channel -# name matches regular expression. -# Parameter mode can be 'dev' or 'chn'. -# Return number of matching entries. -###################################################################### - -sub HMCCU_GetMatchingDevices ($$$$) -{ - my ($hash, $regexp, $mode, $listref) = @_; - my $c = 0; - - foreach my $name (sort keys %{$hash->{hmccu}{adr}}) { - next if ( - $name !~/$regexp/ || - $hash->{hmccu}{adr}{$name}{addtype} ne $mode || - $hash->{hmccu}{adr}{$name}{valid} == 0 - ); - push (@$listref, $hash->{hmccu}{adr}{$name}{address}); - $c++; - } - - return $c; -} - ###################################################################### # Get name of a CCU device by address. # Channel number will be removed if specified. @@ -6040,20 +6011,6 @@ sub HMCCU_GetAddress ($$;$$) return ($defadd, $defchn, ''); } -###################################################################### -# Get addresses of group member devices. -# Group 'virtual' is ignored. -# Return list of device addresses or empty list on error. -###################################################################### - -sub HMCCU_GetGroupMembers ($$) -{ - my ($hash, $group) = @_; - - return $group ne 'virtual' && exists ($hash->{hmccu}{grp}{$group}) ? - split (',', $hash->{hmccu}{grp}{$group}{devs}) : (); -} - ###################################################################### # Check if parameter is a channel address (syntax) # f=1: Interface required. @@ -6649,14 +6606,14 @@ sub HMCCU_GetStateValues ($;$$) sub HMCCU_UpdateRoleCommands ($$) { - my ($ioHash, $clHash, $chnNo) = @_; - $chnNo //= ''; + my ($ioHash, $clHash) = @_; my %pset = ('V' => 'VALUES', 'M' => 'MASTER', 'D' => 'MASTER', 'I' => 'INTERNAL', 'S' => 'STRING'); my @cmdSetList = (); my @cmdGetList = (); return if (HMCCU_IsFlag ($ioHash, 'noAutoDetect') || !defined($clHash->{hmccu}{role}) || $clHash->{hmccu}{role} eq ''); + my $chnNo //= ''; my ($cc, $cd) = HMCCU_ControlDatapoint ($clHash); # Delete existing role commands @@ -6681,6 +6638,8 @@ sub HMCCU_UpdateRoleCommands ($$) $cmdType = $1; $cmd = $2; } + next URCCMD if (exists($clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}) && defined($clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{channel}) && + $cc ne '' && "$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{channel}" eq "$cc"); my $parAccess = $cmdType eq 'set' ? 2 : 5; my $cmdSyntax = $HMCCU_ROLECMDS->{$role}{$cmdKey}; @@ -7745,6 +7704,8 @@ sub HMCCU_SetSCDatapoints ($$;$$$) # Set value return 0 if (!HMCCU_IsDeviceActive ($clHash) || $v eq '' || $v eq '.' || $v =~ /^[0-9]+\.$/ || $v =~ /^\..+$/); +# HMCCU_Log ($clHash, 2, "SetSCDatapoint $v"); + if ($f & 10) { # statedatapoint / controldatapoint if ($v =~ /^([0-9]{1,2})\.(.+)$/) { @@ -7809,7 +7770,6 @@ sub HMCCU_SetSCDatapoints ($$;$$$) my ($cc, $cd) = HMCCU_ControlDatapoint ($clHash); if ($cc ne '' && $cd ne '') { HMCCU_UpdateRoleCommands ($ioHash, $clHash); -# HMCCU_UpdateAdditionalCommands ($ioHash, $clHash, $cc, $cd); } } @@ -7908,7 +7868,6 @@ sub HMCCU_SetDefaultSCDatapoints ($$;$$) my $dpt = $cd ne '' ? $cd : $sd; HMCCU_UpdateRoleCommands ($ioHash, $clHash); -# HMCCU_UpdateAdditionalCommands ($ioHash, $clHash, $chn, $dpt); } my $rsd = $sc ne '' && $sd ne '' ? 1 : 0; diff --git a/fhem/FHEM/88_HMCCUDEV.pm b/fhem/FHEM/88_HMCCUDEV.pm index c9cc7e56d..910cb96a6 100644 --- a/fhem/FHEM/88_HMCCUDEV.pm +++ b/fhem/FHEM/88_HMCCUDEV.pm @@ -97,17 +97,9 @@ sub HMCCUDEV_Define ($@) my ($devname, $devtype, $devspec) = splice (@$a, 0, 3); my $ioHash = undef; - # Handle some legacy options - return 'Virtual devices are no longer supported. Use FHEM built in features like readingsgroup or structure' - if ($devspec eq 'virtual'); - HMCCU_Log ($hash, 2, "Found old device definition syntax using group or groupexp. Group options will be ignored in future versions.") - if (exists($h->{group}) || exists($h->{groupexp})); - # Store some definitions for delayed initialization $hash->{readonly} = 'no'; $hash->{hmccu}{devspec} = $devspec; - $hash->{hmccu}{groupexp} = $h->{groupexp} if (exists($h->{groupexp})); - $hash->{hmccu}{group} = $h->{group} if (exists($h->{group})); $hash->{hmccu}{nodefaults} = $init_done ? 0 : 1; $hash->{hmccu}{forcedev} = 0; $hash->{hmccu}{detect} = 0; @@ -262,34 +254,6 @@ sub HMCCUDEV_InitDevice ($$) HMCCU_ExecuteGetExtValuesCommand ($devHash, $da); } - # Parse group options - if ($devHash->{ccuif} eq 'VirtualDevices') { - my @devlist = (); - if (exists ($devHash->{hmccu}{groupexp})) { - # Group devices specified by name expression - $gdcount = HMCCU_GetMatchingDevices ($ioHash, $devHash->{hmccu}{groupexp}, 'dev', \@devlist); - return 4 if ($gdcount == 0); - } - elsif (exists ($devHash->{hmccu}{group})) { - # Group devices specified by comma separated name list - my @gdevlist = split (',', $devHash->{hmccu}{group}); - $devHash->{ccugroup} = '' if (scalar(@gdevlist) > 0); - foreach my $gd (@gdevlist) { - return 1 if (!HMCCU_IsValidDevice ($ioHash, $gd, 7)); - my ($gda, $gdc) = HMCCU_GetAddress ($ioHash, $gd); - push @devlist, $gdc eq '' ? "$gda:$gdc" : $gda; - $gdcount++; - } - } - else { - # Group specified by CCU virtual group name - @devlist = HMCCU_GetGroupMembers ($ioHash, $gdname); - $gdcount = scalar (@devlist); - } - - $devHash->{ccugroup} = join (',', @devlist) if (scalar(@devlist) > 0); - } - return $rc; } diff --git a/fhem/FHEM/HMCCUConf.pm b/fhem/FHEM/HMCCUConf.pm index 025d9deda..b5144385b 100644 --- a/fhem/FHEM/HMCCUConf.pm +++ b/fhem/FHEM/HMCCUConf.pm @@ -410,6 +410,7 @@ $HMCCU_CONFIG_VERSION = '5.0'; 'pctSlats' => 'V:LEVEL_2:?level V:LEVEL:1.005', 'openSlats' => 'V:LEVEL_2:100 V:LEVEL:1.005', 'closeSlats' => 'V:LEVEL_2:0 V:LEVEL:1.005', + 'allLevels' => 'V:LEVEL_2:?slatLevel V:LEVEL:?blindLevel' }, 'CLIMATECONTROL_REGULATOR' => { 'desired-temp' => 'V:SETPOINT:?temperature', @@ -484,6 +485,7 @@ $HMCCU_CONFIG_VERSION = '5.0'; 'pctSlats' => 'V:LEVEL_SLATS:?level', 'openSlats' => 'V:LEVEL_SLATS:100', 'closeSlats' => 'V:LEVEL_SLATS:0', + 'allLevels' => 'V:LEVEL_SLATS:?slatLevel V:LEVEL:?blindLevel' }, 'KEY' => { 'on' => 'V:PRESS_SHORT:1',