From 6e8848d4602f8f54d16ce83e399750e2c9ed7f42 Mon Sep 17 00:00:00 2001 From: zap <> Date: Sat, 11 May 2019 15:18:23 +0000 Subject: [PATCH] HMCCU: Disable initial device update git-svn-id: https://svn.fhem.de/fhem/trunk@19373 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/88_HMCCU.pm | 24 ++++++++++------- fhem/FHEM/88_HMCCURPCPROC.pm | 52 ++++++++++++++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 3aaecdcc8..735d60ea7 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: Flag for disabling initial device update - bugfix: 10_MYSENSORS_DEVICE: prevent fhem crashing by ack timeout at higher verobse levels - change: 98_Heating_Control.pm will be removed soon. Users will need to diff --git a/fhem/FHEM/88_HMCCU.pm b/fhem/FHEM/88_HMCCU.pm index 855bf3e55..2a9d2a553 100755 --- a/fhem/FHEM/88_HMCCU.pm +++ b/fhem/FHEM/88_HMCCU.pm @@ -4,7 +4,7 @@ # # $Id$ # -# Version 4.3.014 +# Version 4.3.015 # # Module for communication between FHEM and Homematic CCU2/3. # @@ -52,7 +52,7 @@ my %HMCCU_CUST_CHN_DEFAULTS; my %HMCCU_CUST_DEV_DEFAULTS; # HMCCU version -my $HMCCU_VERSION = '4.3.014'; +my $HMCCU_VERSION = '4.3.015'; # Constants and default values my $HMCCU_MAX_IOERRORS = 100; @@ -2639,7 +2639,10 @@ sub HMCCU_SetRPCState ($@) my $st = $hash->{hmccu}{interfaces}{$i}{state}; $stc{$st}++ if (exists ($stc{$st})); if ($hash->{hmccu}{interfaces}{$i}{manager} eq 'HMCCU') { - $filter = defined ($filter) ? "$filter|$i" : $i; + my $rpcFlags = AttrVal ($hash->{hmccu}{interfaces}{$i}{device}, 'ccuflags', 'null'); + if ($rpcFlags !~ /noInitialUpdate/) { + $filter = defined ($filter) ? "$filter|$i" : $i; + } } } @@ -2659,7 +2662,7 @@ sub HMCCU_SetRPCState ($@) DoTrigger ($name, "RPC server $rpcstate"); if ($rpcstate eq 'running') { my ($c_ok, $c_err) = HMCCU_UpdateClients ($hash, '.*', 'Attr', 0, $filter); - HMCCU_Log ($hash, 2, "Updated devices. Success=$c_ok Failed=$c_err", undef); + HMCCU_Log ($hash, 2, "Updated devices for interface filter $filter. Success=$c_ok Failed=$c_err", undef); } } } @@ -6812,7 +6815,8 @@ sub HMCCU_RPCGetConfig ($$$$) my $hmccu_hash = HMCCU_GetHash ($hash); return (-3, $result) if (!defined ($hmccu_hash)); return (-4, $result) if ($type ne 'HMCCU' && $hash->{ccudevstate} eq 'deleted'); - + + my $hmccuflags = HMCCU_GetFlags ($hmccu_hash->{NAME}); my $ccuflags = HMCCU_GetFlags ($name); my $ccureadings = AttrVal ($name, 'ccureadings', $ccuflags =~ /noReadings/ ? 0 : 1); my $readingformat = HMCCU_GetAttrReadingFormat ($hash, $hmccu_hash); @@ -6834,7 +6838,7 @@ sub HMCCU_RPCGetConfig ($$$$) if ($rpctype eq 'B') { HMCCU_Trace ($hash, 2, $fnc, "Method=$method Addr=$addr Port=$port"); - if ($ccuflags =~ /(extrpc|procrpc)/) { + if ($hmccuflags =~ /(extrpc|procrpc)/) { $res = HMCCURPCPROC_SendRequest ($rpchash, $method, $BINRPC_STRING, $addr, $BINRPC_STRING, "MASTER"); } @@ -6916,13 +6920,15 @@ sub HMCCU_RPCSetConfig ($$$) my $name = $hash->{NAME}; my $type = $hash->{TYPE}; - my $ccuflags = HMCCU_GetFlags ($name); my $addr; my $res; my $hmccu_hash = HMCCU_GetHash ($hash); return -3 if (!defined ($hmccu_hash)); return -4 if ($type ne 'HMCCU' && $hash->{ccudevstate} eq 'deleted'); + + my $hmccuflags = HMCCU_GetFlags ($hmccu_hash->{NAME}); + my $ccuflags = HMCCU_GetFlags ($name); my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($hmccu_hash, $param, $HMCCU_FLAG_FULLADDR); @@ -6954,7 +6960,7 @@ sub HMCCU_RPCSetConfig ($$$) $binpar{$e}{V} = $parref->{$e}; } - if ($ccuflags =~ /(extrpc|procrpc)/) { + if ($hmccuflags =~ /(extrpc|procrpc)/) { $res = HMCCURPCPROC_SendRequest ($rpchash, "putParamset", $BINRPC_STRING, $addr, $BINRPC_STRING, "MASTER", $BINRPC_STRUCT, \%binpar); } @@ -8400,7 +8406,7 @@ sub HMCCU_CCURPC_ListDevicesCB ($$) procrpc - Use external RPC server provided by module HMCCPRPCPROC. During first RPC server start HMCCU will create a HMCCURPCPROC device for each interface confiugured in attribute 'rpcinterface'
- reconnect - Automatically reconnect to CCU when events timeout occurred. + reconnect - Automatically reconnect to CCU when events timeout occurred.
Flags intrpc, extrpc and procrpc cannot be combined.
  • ccuget {State | Value}
    diff --git a/fhem/FHEM/88_HMCCURPCPROC.pm b/fhem/FHEM/88_HMCCURPCPROC.pm index ea54bcf28..e9b20a468 100755 --- a/fhem/FHEM/88_HMCCURPCPROC.pm +++ b/fhem/FHEM/88_HMCCURPCPROC.pm @@ -4,7 +4,7 @@ # # $Id$ # -# Version 1.7.001 +# Version 1.7.002 # # Subprocess based RPC Server module for HMCCU. # @@ -158,6 +158,7 @@ sub HMCCURPCPROC_EventCB ($$$$$); sub HMCCURPCPROC_ListDevicesCB ($$); # Binary RPC encoding functions +sub HMCCURPCPROC_RPCNewValue ($$); sub HMCCURPCPROC_EncInteger ($); sub HMCCURPCPROC_EncBool ($); sub HMCCURPCPROC_EncString ($); @@ -202,7 +203,7 @@ sub HMCCURPCPROC_Initialize ($) $hash->{parseParams} = 1; - $hash->{AttrList} = "ccuflags:multiple-strict,expert,logEvents,ccuInit,queueEvents,noEvents". + $hash->{AttrList} = "ccuflags:multiple-strict,expert,logEvents,ccuInit,queueEvents,noEvents,noInitialUpdate". " rpcMaxEvents rpcQueueSend rpcQueueSize rpcMaxIOErrors". " rpcServerAddr rpcServerPort rpcWriteTimeout rpcAcceptTimeout". " rpcConnTimeout rpcStatistics rpcEventTimeout rpcPingCCU ". @@ -2252,6 +2253,52 @@ sub HMCCURPCPROC_ListDevicesCB ($$) return RPC::XML::array->new (); } +###################################################################### +# Convert value to RPC data type +# Valid types are bool, boolean, int, integer, float, double, string. +# If type is undefined, type is detected. If type cannot be detected +# value is returned as is. +###################################################################### + +sub HMCCURPCPROC_RPCNewValue ($$) +{ + my ($value, $type) = @_; + + # Try to detect type if type not specified + if (!defined ($type)) { + if (lc($value) =~ /^(true|false)$/) { + $type = 'boolean'; + } + elsif ($value =~ /^[-+]?\d+$/) { + $type = 'integer'; + } + elsif ($value =~ /^[-+]?[0-9]*\.[0-9]+$/) { + # A float must contain at least a dot followed by a digit + $type = 'float'; + } + elsif ($value =~ /[a-zA-Z_ ]/ || $value =~ /^'.+'$/ || $value =~ /^".+"$/) { + $type = 'string'; + } + } + + if (defined ($type)) { + my $lcType = lc($type); + if ($lcType =~ /^bool/ && uc($value) =~ /^(TRUE|FALSE|0|1)$/) { + return RPC::XML::boolean->new ($value); + } + elsif ($lcType =~ /^int/ && $value =~ /^[-+]?\d+$/) { + return RPC::XML::int->new ($value); + } + elsif ($lcType =~ /^(float|double)$/ && $value =~ /^[-+]?[0-9]*\.[0-9]+$/) { + return RPC::XML::double->new ($value); + } + elsif ($lcType =~ /^str/) { + return RPC::XML::string->new ($value); + } + } + + return $value; +} ###################################################################### # Binary RPC encoding functions @@ -2805,6 +2852,7 @@ sub HMCCURPCPROC_DecodeResponse ($) expert - Activate expert mode
    logEvents - Events are written into FHEM logfile if verbose is 4
    noEvents - Ignore events from CCU, do not update client device readings.
    + noInitalUpdate - Do not update devices after RPC server started.
    queueEvents - Always write events into queue and send them asynchronously to FHEM. Frequency of event transmission to FHEM depends on attribute rpcConnTimeout.