From ce2e38f4b5f729624802c7b44ef7def8d54e0ce4 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 12 Sep 2017 15:41:02 +0000 Subject: [PATCH] 00_ZWDongle: showSetInState Attribute (Forum #75742) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@15055 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/00_ZWDongle.pm | 30 +++++++++++++++++++++++++++--- FHEM/01_FHEMWEB.pm | 6 +++++- FHEM/10_ZWave.pm | 16 +++++++++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/FHEM/00_ZWDongle.pm b/FHEM/00_ZWDongle.pm index e56b85065..af2819985 100644 --- a/FHEM/00_ZWDongle.pm +++ b/FHEM/00_ZWDongle.pm @@ -92,9 +92,21 @@ ZWDongle_Initialize($) $hash->{GetFn} = "ZWDongle_Get"; $hash->{AttrFn} = "ZWDongle_Attr"; $hash->{UndefFn} = "ZWDongle_Undef"; - $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 model:ZWDongle disable:0,1 ". - "helpSites:multiple,pepper,alliance homeId networkKey ". - "neighborListPos neighborListFmt"; + no warnings 'qw'; + my @attrList = qw( + do_not_notify:1,0 + dummy:1,0 + model:ZWDongle + disable:0,1 + helpSites:multiple,pepper,alliance + homeId + networkKey + neighborListPos + neighborListFmt + showSetInState:1,0 + ); + use warnings 'qw'; + $hash->{AttrList} = join(" ", @attrList); $hash->{FW_detailFn} = "ZWDongle_fhemwebFn"; } @@ -957,6 +969,10 @@ ZWDongle_Attr($$$$) return "attr $name networkKey: not a hex string with a length of 32"; } return; + + } elsif($attr eq "showSetInState") { + $hash->{showSetInState} = ($cmd eq "set" ? (defined($value) ? $value:1) :0); + } return undef; @@ -1237,6 +1253,14 @@ ZWDongle_Ready($) { txt=>"NAME", img=>"IMAGE", title=>"Time to ack: timeToAck" } +
  • showSetInState
    + If the attribute is set to 1, and a user issues a set command to a ZWave + device, then the state of the ZWave device will be changed to + set_<cmd> first, and after the ACK from the device is received, to + <cmd>. E.g.: Issuing the command on changes the state first to + set_on, and after the device ack is received, to on. This is analoguos + to the CUL_HM module. Default for this attribute is 0. +

  • diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index aebabe505..94802853f 100644 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -615,13 +615,17 @@ FW_initInform($$) $me->{inform}{since} = time()-5 if(!defined($me->{inform}{since}) || $me->{inform}{since} !~ m/^\d+$/); + my $sinceTimestamp = FmtDateTime($me->{inform}{since}); if($longpoll) { - my $sinceTimestamp = FmtDateTime($me->{inform}{since}); TcpServer_WriteBlocking($me, "HTTP/1.1 200 OK\r\n". $FW_headerlines. "Content-Type: application/octet-stream; charset=$FW_encoding\r\n\r\n". FW_roomStatesForInform($me, $sinceTimestamp)); + + } else { # websocket + FW_addToWritebuffer($me, + FW_roomStatesForInform($me, $sinceTimestamp)); } if($FW_id && $defs{$FW_wname}{asyncOutput}) { diff --git a/FHEM/10_ZWave.pm b/FHEM/10_ZWave.pm index b72c6078f..9c0aa966f 100644 --- a/FHEM/10_ZWave.pm +++ b/FHEM/10_ZWave.pm @@ -1095,7 +1095,9 @@ ZWave_Cmd($$@) ZWave_processSendStack($baseHash, "next"); } $cmd .= " ".join(" ", @a) if(@a); - readingsSingleUpdate($hash, "state", $cmd, 1); + my $iohash = $hash->{IODev}; + readingsSingleUpdate($hash, "state", + $iohash->{showSetInState} ? "set_$cmd" : $cmd, 1); } @@ -4693,11 +4695,19 @@ ZWave_Parse($$@) "$ioName transmit $lmsg for CB $callbackid, target ". ($hash ? $hash->{NAME} : "unknown"); if($id eq "00") { + my $name=""; if($hash) { - readingsSingleUpdate($hash, "transmit", $lmsg, 0); ZWave_processSendStack($hash, "ack", $callbackid); + readingsSingleUpdate($hash, "transmit", $lmsg, 0); + if($iodev->{showSetInState}) { + my $state = ReadingsVal($hash->{NAME}, "state", ""); + if($state =~ m/^set_(.*)$/) { + readingsSingleUpdate($hash, "state", $1, 1); + $name = $hash->{NAME}; + } + } } - return ""; + return $name; } else { # Wait for the retry timer to remove this cmd from the stack. return "" if(!$hash);