2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

HMCCU: Several improvements and bug fixes

git-svn-id: https://svn.fhem.de/fhem/trunk@25347 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
zap 2021-12-15 16:16:55 +00:00
parent 5c4c6a2f5f
commit 5c30abcd65
6 changed files with 95 additions and 96 deletions

View File

@ -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: Several improvements and bug fixes
- feature: 93_DbRep: Pragma query possible in sqlCmd, new getter initData
minor fixes
- bugfix: 88_HMCCU: Several improvements and bug fixes

View File

@ -57,7 +57,7 @@ my %HMCCU_CUST_CHN_DEFAULTS;
my %HMCCU_CUST_DEV_DEFAULTS;
# HMCCU version
my $HMCCU_VERSION = '5.0 213461309';
my $HMCCU_VERSION = '5.0 213491649';
# Timeout for CCU requests (seconds)
my $HMCCU_TIMEOUT_REQUEST = 4;
@ -286,7 +286,6 @@ sub HMCCU_GetFirmwareVersions ($$);
sub HMCCU_GetGroupMembers ($$);
sub HMCCU_GetMatchingDevices ($$$$);
sub HMCCU_GetParamDef ($$$;$);
sub HMCCU_GetParamValueConversion ($$$$$);
sub HMCCU_GetReceivers ($$$);
sub HMCCU_IsValidChannel ($$$);
sub HMCCU_IsValidDevice ($$$);
@ -2877,20 +2876,30 @@ sub HMCCU_Substitute ($$$$$;$$)
return $HMCCU_CONVERSIONS->{DEFAULT}{$dpt}{$value};
}
# Substitute enumerations
# Substitute enumerations and default parameter type conversions
if (defined($devDesc) && defined($ioHash)) {
my $paramDef = HMCCU_GetParamDef ($ioHash, $devDesc, 'VALUES', $dpt);
if (!defined($paramDef) && defined($paramDef->{TYPE}) &&
$paramDef->{TYPE} eq 'ENUM' && defined($paramDef->{VALUE_LIST})) {
my $i = defined($paramDef->{MIN}) ? $paramDef->{MIN} : 0;
if ($mode) {
my %enumVals = map { $_ => $i++ } split(',', $paramDef->{VALUE_LIST});
return $enumVals{$value} if (exists($enumVals{$value}));
if (defined($paramDef) && defined($paramDef->{TYPE})) {
my %ct = (
'BOOL' => { '0' => 'false', '1' => 'true' }
);
my $parType = $paramDef->{TYPE};
if ($parType eq 'ENUM' && defined($paramDef->{VALUE_LIST})) {
my $i = defined($paramDef->{MIN}) ? $paramDef->{MIN} : 0;
if ($mode == 1) {
my %enumVals = map { $_ => $i++ } split(',', $paramDef->{VALUE_LIST});
return $enumVals{$value} if (exists($enumVals{$value}));
}
else {
my @enumList = split(',', $paramDef->{VALUE_LIST});
if (HMCCU_IsIntNum ($value)) {
my $idx = $value-$i;
return $enumList[$idx] if ($idx >= 0 && $idx < scalar(@enumList));
}
}
}
else {
my @enumList = split(',', $paramDef->{VALUE_LIST});
my $idx = $value-$i;
return $enumList[$idx] if ($idx >= 0 && $idx < scalar(@enumList));
elsif (exists($ct{$parType}) && exists($ct{$parType}{$value})) {
return $ct{$parType}{$value};
}
}
}
@ -4464,42 +4473,6 @@ sub HMCCU_IsValidParameter ($$$$;$)
return 0;
}
######################################################################
# Convert parameter value
# Parameters:
# $hash - Hash reference of IO device.
# $object - Device/channel address or device description reference.
# $paramset - Parameter set.
# $parameter - Parameter name.
# $value - Parameter value.
# Return converted or original value.
######################################################################
sub HMCCU_GetParamValueConversion ($$$$$)
{
my ($hash, $object, $paramset, $parameter, $value) = @_;
# Conversion table
my %ct = (
'BOOL' => { 0 => 'false', 1 => 'true' }
);
return $value if (!defined($object));
$paramset = 'LINK' if ($paramset =~ /^LINK\..+$/);
my $paramDef = HMCCU_GetParamDef ($hash, $object, $paramset, $parameter) // return $value;
my $type = $paramDef->{TYPE} // return $value;
return $ct{$type}{$value} if (exists($ct{$type}) && exists($ct{$type}{$value}));
if ($type eq 'ENUM' && exists($paramDef->{VALUE_LIST})) {
my @vl = split(',', $paramDef->{VALUE_LIST});
return $vl[$value] if ($value =~ /^[0-9]+$/ && $value < scalar(@vl));
}
return $value;
}
######################################################################
# Update client devices with peering information
# In addition peering information is stored in hash of IO device.
@ -4729,8 +4702,6 @@ sub HMCCU_UpdateParamsetReadings ($$$;$)
HMCCU_Trace ($clHash, 2, "$p: sv = $sv");
$fv = HMCCU_FormatReadingValue ($clHash, $sv, $p);
$cv = HMCCU_Substitute ($fv, $clHash, 0, $c, $p, $chnType, $devDesc);
$cv = HMCCU_GetParamValueConversion ($ioHash, $devDesc, $ps, $p, $fv)
if (defined($devDesc) && "$fv" eq "$cv");
HMCCU_UpdateInternalValues ($clHash, $chKey, $ps, 'SVAL', $cv);
push @chKeys, $chKey;
@ -9325,7 +9296,7 @@ sub HMCCU_ScaleValue ($$$$$;$)
$min = $paramDef->{MIN} if (defined($paramDef->{MIN}) && $paramDef->{MIN} ne '');
$max = $paramDef->{MAX} if (defined($paramDef->{MAX}) && $paramDef->{MAX} ne '');
$unit = $paramDef->{UNIT};
$unit = '100%' if ($dpt eq 'LEVEL' && !defined($unit));
$unit = '100%' if (!defined($unit) && ($dpt eq 'LEVEL' || $dpt eq 'LEVEL_2' || $dpt eq 'LEVEL_SLATS'));
}
else {
HMCCU_Trace ($hash, 2, "Can't get parameter definion for addr=$ccuaddr chn=$chnno dpt=$dpt");
@ -9865,14 +9836,15 @@ sub HMCCU_UpdateDeviceStates ($)
# Datapoints to be converted to readings
my %newReadings = (
'0.AES_KEY' => 'sign',
'0.RSSI_DEVICE' => 'rssidevice',
'0.RSSI_PEER' => 'rssipeer',
'0.LOW_BAT' => 'battery',
'0.LOWBAT' => 'battery',
'0.UNREACH' => 'activity',
'0.SABOTAGE' => 'sabotage',
'0.ERROR_SABOTAGE' => 'sabotage'
'0.AES_KEY' => 'sign',
'0.RSSI_DEVICE' => 'rssidevice',
'0.RSSI_PEER' => 'rssipeer',
'0.LOW_BAT' => 'battery',
'0.LOWBAT' => 'battery',
'0.OPERATING_VOLTAGE' => 'voltage',
'0.UNREACH' => 'activity',
'0.SABOTAGE' => 'sabotage',
'0.ERROR_SABOTAGE' => 'sabotage'
);
# The new readings

View File

@ -30,7 +30,7 @@ sub HMCCUCHN_Set ($@);
sub HMCCUCHN_Get ($@);
sub HMCCUCHN_Attr ($@);
my $HMCCUCHN_VERSION = '5.0 213461309';
my $HMCCUCHN_VERSION = '5.0 213491649';
######################################################################
# Initialize module

View File

@ -31,7 +31,7 @@ sub HMCCUDEV_Set ($@);
sub HMCCUDEV_Get ($@);
sub HMCCUDEV_Attr ($@);
my $HMCCUDEV_VERSION = '5.0 213461309';
my $HMCCUDEV_VERSION = '5.0 213491649';
######################################################################
# Initialize module

View File

@ -39,7 +39,7 @@ require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
######################################################################
# HMCCURPC version
my $HMCCURPCPROC_VERSION = '5.0 213461309';
my $HMCCURPCPROC_VERSION = '5.0 213491649';
# Maximum number of events processed per call of Read()
my $HMCCURPCPROC_MAX_EVENTS = 100;

View File

@ -76,6 +76,9 @@ $HMCCU_CONFIG_VERSION = '5.0';
'BRIGHTNESS_TRANSMITTER' => {
F => 3, S => 'CURRENT_ILLUMINATION', C => '', V => '', P => 2
},
'CAPACITIVE_FILLING_LEVEL_SENSOR' => {
F => 3, S => 'FILLING_LEVEL', C => '', V => '', P => 2
},
'CLIMATE_TRANSCEIVER' => {
F => 3, S => 'ACTUAL_TEMPERATURE', C => '', V => '', P => 1
},
@ -151,6 +154,12 @@ $HMCCU_CONFIG_VERSION = '5.0';
'PRESENCEDETECTOR_TRANSCEIVER' => {
F => 3, S => 'PRESENCE_DETECTION_STATE', C => 'PRESENCE_DETECTION_ACTIVE', V => 'active:1,inactive:0', P => 2
},
'RAINDETECTOR' => {
F => 3, S => 'STATE', C => '', V => '', P => 1
},
'RAINDETECTOR_HEAT' => {
F => 3, S => 'STATE', C => 'STATE', V => 'on:true,off:false', P => 2
},
'ROTARY_HANDLE_SENSOR' => {
F => 3, S => 'STATE', C => '', V => '', P => 2
},
@ -215,6 +224,8 @@ $HMCCU_CONFIG_VERSION = '5.0';
######################################################################
%HMCCU_READINGS = (
'ACCELERATION_TRANSCEIVER' =>
'^(C#\.)?MOTION:motion',
'ARMING' =>
'^(C#\.)?ARMSTATE$:+armState',
'BLIND' =>
@ -223,14 +234,17 @@ $HMCCU_CONFIG_VERSION = '5.0';
'^(C#\.)?LEVEL$:+pct,+level;^(C#\.)?LEVEL_2$:+pctSlats',
'BLIND_VIRTUAL_RECEIVER' =>
'^(C#\.)?LEVEL$:+pct,+level',
'SHUTTER_TRANSMITTER' =>
'^(C#\.)?LEVEL$:+pct,+level',
'SHUTTER_VIRTUAL_RECEIVER' =>
'^(C#\.)?LEVEL$:+pct,+level',
'SWITCH_PANIC' =>
'^(C#\.)?STATE$:+panic',
'SWITCH_SENSOR' =>
'^(C#\.)?STATE$:+sensor',
'CAPACITIVE_FILLING_LEVEL_SENSOR' =>
'^(C#\.)?FILLING_LEVEL$:+level',
'CLIMATECONTROL_REGULATOR' =>
'^(C#\.)?SETPOINT$:+desired-temp',
'CLIMATECONTROL_RT_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_TEMPERATURE$:+desired-temp',
'CLIMATE_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity',
'DIMMER' =>
'^(C#\.)?LEVEL$:+pct,+level',
'DIMMER_TRANSMITTER' =>
@ -239,46 +253,43 @@ $HMCCU_CONFIG_VERSION = '5.0';
'^(C#\.)?LEVEL$:+pct,+level;(C#\.)?COLOR$:+color',
'DIMMER_WEEK_PROFILE' =>
'^(C#\.)?WEEK_PROGRAM_CHANNEL_LOCKS$:+progMode',
'HEATING_CLIMATECONTROL_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?HUMIDITY$:+humidity;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_POINT_TEMPERATURE$:+desired-temp',
'JALOUSIE' =>
'^(C#\.)?LEVEL$:+pct,+level;(C#\.)?LEVEL_SLATS$:+pctSlats',
'KEY' =>
'^(C#\.)?PRESS_(SHORT|LONG)$:+pressed',
'KEY_TRANSCEIVER' =>
'^(C#\.)?PRESS_(SHORT|LONG)$:+pressed',
'VIRTUAL_KEY' =>
'^(C#\.)?PRESS_(SHORT|LONG)$:+pressed',
'ACCELERATION_TRANSCEIVER' =>
'^(C#\.)?MOTION:motion',
'MOTION_DETECTOR' =>
'^(C#\.)?BRIGHTNESS$:brightness;(C#\.)?MOTION:motion',
'MOTIONDETECTOR_TRANSCEIVER' =>
'^(C#\.)?ILLUMINATION$:brightness;^(C#\.)?MOTION$:motion;(C#\.)?MOTION_DETECTION_ACTIVE$:detection',
'PRESENCEDETECTOR_TRANSCEIVER' =>
'^(C#\.)?ILLUMINATION$:brightness;(C#\.)?PRESENCE_DETECTION_STATE:presence;(C#\.)?PRESENCE_DETECTION_ACTIVE:detection',
'SHUTTER_TRANSMITTER' =>
'^(C#\.)?LEVEL$:+pct,+level',
'SHUTTER_VIRTUAL_RECEIVER' =>
'^(C#\.)?LEVEL$:+pct,+level',
'SWITCH_PANIC' =>
'^(C#\.)?STATE$:+panic',
'SWITCH_SENSOR' =>
'^(C#\.)?STATE$:+sensor',
'THERMALCONTROL_TRANSMIT' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_TEMPERATURE$:+desired-temp',
'VIRTUAL_KEY' =>
'^(C#\.)?PRESS_(SHORT|LONG)$:+pressed',
'WEATHER' =>
'^(C#\.)?TEMPERATURE$:+measured-temp;'.
'^(C#\.)?HUMIDITY$:+humidity',
'WEATHER_TRANSMIT' =>
'^(C#\.)?TEMPERATURE$:+measured-temp;'.
'^(C#\.)?HUMIDITY$:+humidity',
'CLIMATE_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity',
'THERMALCONTROL_TRANSMIT' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_TEMPERATURE$:+desired-temp',
'CLIMATECONTROL_RT_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_TEMPERATURE$:+desired-temp',
'HEATING_CLIMATECONTROL_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?HUMIDITY$:+humidity;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_POINT_TEMPERATURE$:+desired-temp',
'CLIMATECONTROL_REGULATOR' =>
'^(C#\.)?SETPOINT$:+desired-temp',
'DEFAULT' =>
'^([0-9]{1,2}\.)?LEVEL$:+pct,+level;'.
'^([0-9]{1,2}\.)?SET_TEMPERATURE$:+desired-temp;'.
@ -351,9 +362,9 @@ $HMCCU_CONFIG_VERSION = '5.0';
'up' => 'V:LEVEL:?delta=+20',
'down' => 'V:LEVEL:?delta=-20',
'stop' => 'V:STOP:1',
'pctSlats' => 'V:LEVEL_2:?level V:LEVEL:101',
'openSlats' => 'V:LEVEL_2:100 V:LEVEL:101',
'closeSlats' => 'V:LEVEL_2:0 V:LEVEL:101',
'pctSlats' => 'V:LEVEL_2:?level V:LEVEL:100.5',
'openSlats' => 'V:LEVEL_2:100 V:LEVEL:100.5',
'closeSlats' => 'V:LEVEL_2:0 V:LEVEL:100.5',
},
'CLIMATECONTROL_REGULATOR' => {
'desired-temp' => 'V:SETPOINT:?temperature',
@ -442,6 +453,12 @@ $HMCCU_CONFIG_VERSION = '5.0';
'detection' => 'V:PRESENCE_DETECTION_ACTIVE:#detection=inactive,active',
'reset' => 'V:RESET_PRESENCE:true'
},
'RAINDETECTOR_HEAT' => {
'on' => 'V:STATE:1',
'off' => 'V:STATE:0',
'on-for-timer' => 'V:ON_TIME:?duration V:STATE:1',
'on-till' => 'V:ON_TIME:?time V:STATE:1'
},
'SHUTTER_VIRTUAL_RECEIVER' => {
'pct' => 'V:LEVEL:?level',
'open' => 'V:LEVEL:100',
@ -578,6 +595,9 @@ $HMCCU_CONFIG_VERSION = '5.0';
'cmdIcon' => 'reset:rc_BACK',
'webCmd' => 'detection:reset'
},
'RAINDETECTOR_HEAT' => {
'cmdIcon' => 'on:general_an off:general_aus'
},
'SHUTTER_CONTACT' => {
'_none_' => ''
},
@ -683,6 +703,12 @@ $HMCCU_CONFIG_VERSION = '5.0';
'PRESS_SHORT' => { '1' => 'pressed', 'true' => 'pressed' },
'PRESS_LONG' => { '1' => 'pressed', 'true' => 'pressed' }
},
'RAINDETECTOR' => {
'STATE' => { '0' => 'dry', 1 => 'rain' }
},
'RAINDETECTOR_HEAT' => {
'STATE' => { '0' => 'off', 'false' => 'off', '1' => 'on', 'true' => 'on' }
},
'SHUTTER_CONTACT' => {
'STATE' => { '0' => 'closed', '1' => 'open', 'false' => 'closed', 'true' => 'open' }
},