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

HMCCU: Bugfixes and improvements

git-svn-id: https://svn.fhem.de/fhem/trunk@25675 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
zap 2022-02-13 15:00:07 +00:00
parent 1e4bc06ec7
commit 594fc4d420
6 changed files with 84 additions and 42 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: bugfixes and improvements
- bugfix: 70_ESCVP21net: bugfixes
- feature: 73_GardenaSmartBridge: asyncron response processing,
no blocking if more then 3-4 devices

View File

@ -12,7 +12,7 @@
# CCU group devices, HomeGear, CUxD, Osram Lightify, Homematic Virtual Layer
# and Philips Hue (not tested)
#
# (c) 2021 by zap (zap01 <at> t-online <dot> de)
# (c) 2022 by zap (zap01 <at> t-online <dot> de)
#
##############################################################################
#
@ -57,7 +57,7 @@ my %HMCCU_CUST_CHN_DEFAULTS;
my %HMCCU_CUST_DEV_DEFAULTS;
# HMCCU version
my $HMCCU_VERSION = '5.0 220301356';
my $HMCCU_VERSION = '5.0 220431743';
# Timeout for CCU requests (seconds)
my $HMCCU_TIMEOUT_REQUEST = 4;
@ -2485,15 +2485,15 @@ sub HMCCU_ModifyReadingName ($$)
my $f = 0;
foreach my $rr (@$srl) {
my ($rold, $rnew) = split (':', $rr);
if (!defined ($rnew) || $rnew eq '') {
# Suppress reading
$f = 1;
next;
}
my @rnewList = split (',', $rnew);
my ($rold, $rnw) = split (':', $rr);
next if (!defined($rold) || $rold eq '');
if ($rn =~ /$rold/) {
foreach my $rnew (@rnewList) {
if (!defined ($rnw) || $rnw eq '') {
# Suppress reading
$f = 1;
next;
}
foreach my $rnew (split (',', $rnw)) {
my $radd = $rn;
if ($rnew =~ /^\+(.+)$/) {
# Add new reading
@ -2718,10 +2718,14 @@ sub HMCCU_Log ($$$;$)
if (ref($msg) eq 'ARRAY') {
foreach my $m (@$msg) {
# Remove credentials from URLs
$m =~ s/(https?:\/\/)[^\@]+\@/$1/g;
Log3 $logname, $level, "$type [$name] $m";
}
}
else {
# Remove credentials from URLs
$msg =~ s/(https?:\/\/)[^\@]+\@/$1/g;
Log3 $logname, $level, "$type [$name] $msg";
}
@ -7837,8 +7841,11 @@ sub HMCCU_ExecuteGetParameterCommand ($@)
my %objects;
foreach my $a (@$addList) {
my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $a, $clHash->{ccuif}) // return HMCCU_Log (
$clHash, 2, "Can't get device description", undef);
my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $a, $clHash->{ccuif});
if (!defined($devDesc)) {
HMCCU_Log ($clHash, 2, "Can't get device description");
return undef;
}
my $paramset = $defParamset eq '' ? $devDesc->{PARAMSETS} : $defParamset;
my ($da, $dc) = HMCCU_SplitChnAddr ($a, 'd');
@ -10088,6 +10095,15 @@ sub HMCCU_Min ($$)
{
my ($a, $b) = @_;
if (!defined($a) || !defined($b)) {
HMCCU_Log (undef, 2, "Argument not defined in HMCCU_Min ".stacktraceAsString(undef));
return 0;
}
if (!HMCCU_IsFltNum($a) || !HMCCU_IsFltNum($b)) {
HMCCU_Log (undef, 2, "Argument $a or $b isn't numeric in HMCCU_Min ".stacktraceAsString(undef));
return 0;
}
return $a < $b ? $a : $b;
}
@ -10095,6 +10111,15 @@ sub HMCCU_Max ($$)
{
my ($a, $b) = @_;
if (!defined($a) || !defined($b)) {
HMCCU_Log (undef, 2, "Argument not defined in HMCCU_Min ".stacktraceAsString(undef));
return 0;
}
if (!HMCCU_IsFltNum($a) || !HMCCU_IsFltNum($b)) {
HMCCU_Log (undef, 2, "Argument $a or $b isn't numeric in HMCCU_Max ".stacktraceAsString(undef));
return 0;
}
return $a > $b ? $a : $b;
}
@ -10537,7 +10562,7 @@ sub HMCCU_BitsToStr ($$)
sub HMCCU_AdjustValue ($$$)
{
my ($value, $low, $high);
my ($value, $low, $high) = @_;;
return $low if ($value < $low);
return $high if ($value > $high);

View File

@ -6,7 +6,7 @@
#
# Version 5.0
#
# (c) 2021 zap (zap01 <at> t-online <dot> de)
# (c) 2022 zap (zap01 <at> t-online <dot> de)
#
######################################################################
# Client device for Homematic channels.
@ -19,7 +19,7 @@ use strict;
use warnings;
use SetExtensions;
require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
# require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
sub HMCCUCHN_Initialize ($);
sub HMCCUCHN_Define ($@);
@ -30,7 +30,7 @@ sub HMCCUCHN_Set ($@);
sub HMCCUCHN_Get ($@);
sub HMCCUCHN_Attr ($@);
my $HMCCUCHN_VERSION = '5.0 220301356';
my $HMCCUCHN_VERSION = '5.0 220431743';
######################################################################
# Initialize module

View File

@ -6,7 +6,7 @@
#
# Version 5.0
#
# (c) 2021 zap (zap01 <at> t-online <dot> de)
# (c) 2022 zap (zap01 <at> t-online <dot> de)
#
######################################################################
# Client device for Homematic devices.
@ -20,7 +20,7 @@ use warnings;
# use Data::Dumper;
use SetExtensions;
require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
# require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
sub HMCCUDEV_Initialize ($);
sub HMCCUDEV_Define ($@);
@ -31,7 +31,7 @@ sub HMCCUDEV_Set ($@);
sub HMCCUDEV_Get ($@);
sub HMCCUDEV_Attr ($@);
my $HMCCUDEV_VERSION = '5.0 220301356';
my $HMCCUDEV_VERSION = '5.0 220431743';
######################################################################
# Initialize module
@ -719,12 +719,12 @@ sub HMCCUDEV_Get ($@)
commands are allowed:
<br/><br/>
<ul>
<li>text1-3=Text - Content of display line 2-4</li>
<li>icon1-3=IconCode - Icons of display line 2-4</li>
<li>sound=SoundCode - Sound</li>
<li>signal=SignalCode - Optical signal</li>
<li>pause=Seconds - Pause between signals (1-160)</li>
<li>repeat=Count - Repeat count for sound (0-15)</li>
<li>text1-3:Text - Content of display line 2-4</li>
<li>icon1-3:IconCode - Icons of display line 2-4</li>
<li>sound:SoundCode - Sound</li>
<li>signal:SignalCode - Optical signal</li>
<li>pause:Seconds - Pause between signals (1-160)</li>
<li>repeat:Count - Repeat count for sound (0-15)</li>
</ul>
<br/>
IconCode := ico_off, ico_on, ico_open, ico_closed, ico_error, ico_ok, ico_info,
@ -734,7 +734,7 @@ sub HMCCUDEV_Get ($@)
snd_long<br/><br/>
Example:<br/>
<code>
set HM_EPDISP datapoint 3.SUBMIT "text1:Line2,text2:Has Blank,text3:10:05:21,sound:snd_short,signal:sig_red
set HM_EPDISP datapoint 3.SUBMIT text1:Line2,text2:Has Blank,text3:10:05:21,sound:snd_short,signal:sig_red
</code>
</li>
</ul>

View File

@ -17,7 +17,7 @@
# RPC::XML::Client
# RPC::XML::Server
#
# ND deaktiviert in Read und Write!!
# ND deactivated in Read and Write!!
##############################################################################
@ -31,7 +31,7 @@ use RPC::XML::Client;
use RPC::XML::Server;
use SetExtensions;
require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
# require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
######################################################################
@ -39,7 +39,7 @@ require "$attr{global}{modpath}/FHEM/88_HMCCU.pm";
######################################################################
# HMCCURPC version
my $HMCCURPCPROC_VERSION = '5.0 220301356';
my $HMCCURPCPROC_VERSION = '5.0 220431743';
# Maximum number of events processed per call of Read()
my $HMCCURPCPROC_MAX_EVENTS = 100;
@ -1001,17 +1001,23 @@ sub HMCCURPCPROC_ProcessEvent ($$)
# Detect event type and clkey
my ($et, $clkey, $evdata) = split (/\|/, $event, 3);
return HMCCU_Log ($hash, 2, "Syntax error in RPC event data $event", undef)
if (!defined($evdata));
if (!defined($evdata)) {
HMCCU_Log ($hash, 2, "Syntax error in RPC event data $event");
return undef;
}
# Check for valid server
return HMCCU_Log ($hash, 2, "Received $et event for unknown RPC server $clkey", undef)
if ($clkey ne $rpcname);
if ($clkey ne $rpcname) {
HMCCU_Log ($hash, 2, "Received $et event for unknown RPC server $clkey");
return undef;
}
# Check event type
if (!exists ($rpceventargs{$et})) {
$et =~ s/([\x00-\xFF])/sprintf("0x%X ",ord($1))/eg;
return HMCCU_Log ($hash, 2, "Received unknown event from CCU: $et", undef);
HMCCU_Log ($hash, 2, "Received unknown event from CCU: $et");
return undef;
}
# Parse event
@ -1019,8 +1025,10 @@ sub HMCCURPCPROC_ProcessEvent ($$)
my $tc = scalar(@t);
# Check event parameters
return HMCCU_Log ($hash, 2, "Wrong number of $tc parameters in event $event. Expected ".
$rpceventargs{$et}, undef) if ($tc != $rpceventargs{$et});
if ($tc != $rpceventargs{$et}) {
HMCCU_Log ($hash, 2, "Wrong number of $tc parameters in event $event. Expected ".$rpceventargs{$et});
return undef;
}
# Update statistic counters
$rh->{rec}{$et}++;
@ -1061,7 +1069,8 @@ sub HMCCURPCPROC_ProcessEvent ($$)
return ($et, $clkey, ($srun == 0 ? 1 : 0), $srun);
}
else {
return HMCCU_Log ($hash, 0, "Received SL event. Wrong PID=".$t[0]." for RPC server $clkey", undef);
HMCCU_Log ($hash, 0, "Received SL event. Wrong PID=".$t[0]." for RPC server $clkey");
return undef;
}
}
elsif ($et eq 'IN') {
@ -1454,15 +1463,19 @@ sub HMCCURPCPROC_InitRPCServer ($$$$)
if ($prot eq 'B') {
$server->{__daemon} = IO::Socket::INET->new (LocalPort => $cbPort,
Type => SOCK_STREAM, Reuse => 1, Listen => SOMAXCONN);
return HMCCU_Log ($name, 1, "Can't create RPC callback server $clkey. Port $cbPort in use?", undef)
if (!($server->{__daemon}));
if (!($server->{__daemon})) {
HMCCU_Log ($name, 1, "Can't create RPC callback server $clkey. Port $cbPort in use?");
return undef;
}
return $server;
}
# Create XML RPC server
$server = RPC::XML::Server->new (port => $cbPort);
return HMCCU_Log ($name, 1, "Can't create RPC callback server $clkey. Port $cbPort in use?", undef)
if (!ref($server));
if (!ref($server)) {
HMCCU_Log ($name, 1, "Can't create RPC callback server $clkey. Port $cbPort in use?");
return undef;
}
HMCCU_Log ($name, 2, "Callback server $clkey created. Listening on port $cbPort");
# Callback for events

View File

@ -8,7 +8,7 @@
#
# Configuration parameters for HomeMatic devices.
#
# (c) 2021 by zap (zap01 <at> t-online <dot> de)
# (c) 2022 by zap (zap01 <at> t-online <dot> de)
#
#########################################################################
@ -208,6 +208,9 @@ $HMCCU_CONFIG_VERSION = '5.0';
'THERMALCONTROL_TRANSMIT' => {
F => 3, S => 'ACTUAL_TEMPERATURE', C => 'SET_TEMPERATURE', V => 'on:30.5,off:4.5', P => 2
},
'TILT_SENSOR' => {
F => 3, S => 'STATE', C => '', V => '', P => 1
},
'VIRTUAL_KEY' => {
F => 3, S => 'PRESS_SHORT', C => 'PRESS_SHORT', V => 'pressed:true', P => 1
},