mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 04:36:02 +00:00
ZWave.pm: get is using asyncOutput, wont block. (Forum #53315).
ZWave.pm: enable deviceOverview by adding FW_showStatus (Forum #53012) git-svn-id: https://svn.fhem.de/fhem/trunk@11553 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
219f6924f1
commit
46458d585f
@ -24,7 +24,7 @@ sub ZWCUL_SimpleWrite($$);
|
||||
sub ZWCUL_Write($$$);
|
||||
sub ZWCUL_ProcessSendStack($);
|
||||
|
||||
use vars qw(%zwave_id2class);
|
||||
our %zwave_id2class;
|
||||
my %ZWCUL_sentIdx;
|
||||
my %ZWCUL_sentIdx2cbid;
|
||||
|
||||
|
@ -1047,7 +1047,7 @@ FW_makeTable($$$@)
|
||||
return if(!$hash || !int(keys %{$hash}));
|
||||
my $class = lc($title);
|
||||
$class =~ s/[^A-Za-z]/_/g;
|
||||
FW_pO "<div class='makeTable wide'>";
|
||||
FW_pO "<div class='makeTable wide ".lc($title)."'>";
|
||||
FW_pO $title;
|
||||
FW_pO "<table class=\"block wide $class\">";
|
||||
my $si = AttrVal("global", "showInternalValues", 0);
|
||||
@ -1185,12 +1185,7 @@ FW_doDetail($)
|
||||
}
|
||||
FW_pO "<table><tr><td>";
|
||||
|
||||
if($modules{$t}{FW_detailFn}) {
|
||||
no strict "refs";
|
||||
my $txt = &{$modules{$t}{FW_detailFn}}($FW_wname, $d, $FW_room);
|
||||
FW_pO "$txt<br>" if(defined($txt));
|
||||
use strict "refs";
|
||||
} else {
|
||||
if(!$modules{$t}{FW_detailFn} || $modules{$t}{FW_showStatus}) {
|
||||
my $show = AttrVal($FW_wname, "deviceOverview", "always");
|
||||
|
||||
if( $show ne 'never' ) {
|
||||
@ -1225,6 +1220,13 @@ FW_doDetail($)
|
||||
}
|
||||
}
|
||||
}
|
||||
if($modules{$t}{FW_detailFn}) {
|
||||
no strict "refs";
|
||||
my $txt = &{$modules{$t}{FW_detailFn}}($FW_wname, $d, $FW_room);
|
||||
FW_pO "$txt<br>" if(defined($txt));
|
||||
use strict "refs";
|
||||
}
|
||||
|
||||
|
||||
FW_pO FW_detailSelect($d, "set", FW_widgetOverride($d, getAllSets($d)));
|
||||
FW_pO FW_detailSelect($d, "get", FW_widgetOverride($d, getAllGets($d)));
|
||||
|
@ -22,8 +22,8 @@ sub ZWave_secEnd($);
|
||||
sub ZWave_configParseModel($;$);
|
||||
sub ZWave_callbackId($);
|
||||
|
||||
use vars qw($FW_ME $FW_tp $FW_ss);
|
||||
use vars qw(%zwave_id2class);
|
||||
our ($FW_ME,$FW_tp,$FW_ss);
|
||||
our %zwave_id2class;
|
||||
|
||||
my %zwave_class = (
|
||||
NO_OPERATION => { id => '00' }, # lowlevel
|
||||
@ -504,7 +504,7 @@ my %zwave_modelIdAlias = ( "010f-0301-1001" => "Fibaro_FGRM222",
|
||||
"0115-0100-0102" => "ZME_KFOB" );
|
||||
|
||||
# Patching certain devices.
|
||||
use vars qw(%zwave_deviceSpecial);
|
||||
our %zwave_deviceSpecial;
|
||||
%zwave_deviceSpecial = (
|
||||
Fibaro_FGRM222 => {
|
||||
MANUFACTURER_PROPRIETARY => {
|
||||
@ -578,6 +578,7 @@ ZWave_Initialize($)
|
||||
map { $zwave_id2class{lc($zwave_class{$_}{id})} = $_ } keys %zwave_class;
|
||||
|
||||
$hash->{FW_detailFn} = "ZWave_fhemwebFn";
|
||||
$hash->{FW_showStatus} = 1;
|
||||
|
||||
eval { require Crypt::Rijndael; };
|
||||
if($@) {
|
||||
@ -900,18 +901,14 @@ ZWave_Cmd($$@)
|
||||
|
||||
my $val;
|
||||
if($type eq "get" && $hash->{CL}) { # Wait for the result for frontend cmd
|
||||
no strict "refs";
|
||||
my $iohash = $hash->{IODev};
|
||||
my $fn = $modules{$iohash->{TYPE}}{ReadAnswerFn};
|
||||
my $re = $cmdList{$cmd}{regexp};
|
||||
my ($err, $data) = &{$fn}($iohash, $cmd, $re ? $re : "^000400${id}..$cmdId")
|
||||
if($fn);
|
||||
use strict "refs";
|
||||
|
||||
return $err if($err);
|
||||
$data = "$cmd $id $data" if($re);
|
||||
|
||||
$val = ($data ? ZWave_Parse($iohash, $data, $type) : "no data returned");
|
||||
if(!$hash->{asyncGet}) {
|
||||
my $tHash = { hash=>$hash, CL=>$hash->{CL}, re=>"^000400${id}..$cmdId"};
|
||||
$hash->{asyncGet} = $tHash;
|
||||
InternalTimer(gettimeofday()+2, sub {
|
||||
asyncOutput($tHash->{CL}, "Timeout reading answer for $cmd");
|
||||
delete($hash->{asyncGet});
|
||||
}, $tHash, 0);
|
||||
}
|
||||
|
||||
} elsif($type ne "get") {
|
||||
if($cmd eq "neighborUpdate" ||
|
||||
@ -4113,6 +4110,11 @@ ZWave_Parse($$@)
|
||||
if(AttrVal($name, "eventForRaw", undef));
|
||||
readingsEndUpdate($hash, 1);
|
||||
|
||||
if($hash->{asyncGet} && $msg =~ m/$hash->{asyncGet}->{re}/) {
|
||||
RemoveInternalTimer($hash->{asyncGet});
|
||||
asyncOutput($hash->{asyncGet}{CL}, join("\n", @event));
|
||||
delete($hash->{asyncGet});
|
||||
}
|
||||
return join("\n", @event) if($srcCmd);
|
||||
return $name;
|
||||
}
|
||||
@ -4225,7 +4227,7 @@ ZWave_fhemwebFn($$$$)
|
||||
'<script type="text/javascript">'.
|
||||
"var d='$d', FW_tp='$FW_tp';" . <<'JSEND'
|
||||
$(document).ready(function() {
|
||||
$("div#ZWHelp").insertBefore("div.makeTable.wide:first"); // Move
|
||||
$("div#ZWHelp").insertBefore("div.makeTable.internals"); // Move
|
||||
$("div.detLink.ZWPepper").insertAfter("div.detLink.devSpecHelp");
|
||||
if(FW_tp) $("div.img.ZWPepper").appendTo("div#menu");
|
||||
$("select.set,select.get").each(function(){
|
||||
@ -4261,10 +4263,10 @@ s2Hex($)
|
||||
<h3>ZWave</h3>
|
||||
<ul>
|
||||
This module is used to control ZWave devices via FHEM, see <a
|
||||
href="http://www.z-wave.com">www.z-wave.com</a> on details for this device family.
|
||||
This module is a client of the <a href="#ZWDongle">ZWDongle</a> module, which
|
||||
is directly attached to the controller via USB or TCP/IP.
|
||||
To use the SECURITY features, the Crypt-Rijndael perl module is needed.
|
||||
href="http://www.z-wave.com">www.z-wave.com</a> on details for this device
|
||||
family. This module is a client of the <a href="#ZWDongle">ZWDongle</a>
|
||||
module, which is directly attached to the controller via USB or TCP/IP. To
|
||||
use the SECURITY features, the Crypt-Rijndael perl module is needed.
|
||||
<br><br>
|
||||
<a name="ZWavedefine"></a>
|
||||
<b>Define</b>
|
||||
@ -4514,7 +4516,8 @@ s2Hex($)
|
||||
<li>protectionSeq<br>
|
||||
device can be operated, if a certain sequence is keyed.</li>
|
||||
<li>protectionBytes LocalProtectionByte RFProtectionByte<br>
|
||||
for commandclass PROTECTION V2 - see devicemanual for supported protectionmodes</li>
|
||||
for commandclass PROTECTION V2 - see devicemanual for supported
|
||||
protectionmodes</li>
|
||||
|
||||
<br><br><b>Class SCENE_ACTIVATION</b>
|
||||
<li>sceneConfig<br>
|
||||
|
@ -286,7 +286,7 @@ telnet_Read($)
|
||||
if($gotCmd && $hash->{showPrompt} && !$hash->{rcvdQuit});
|
||||
|
||||
$ret =~ s/\n/\r\n/g if($hash->{Authenticated}); # only for DOS telnet
|
||||
telnet_Output($hash,$ret);
|
||||
telnet_Output($hash, $ret, 1);
|
||||
|
||||
if($hash->{rcvdQuit}) {
|
||||
if($hash->{isClient}) {
|
||||
@ -297,13 +297,15 @@ telnet_Read($)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub
|
||||
telnet_Output($$)
|
||||
telnet_Output($$$)
|
||||
{
|
||||
my ($hash,$ret) = @_;
|
||||
my ($hash,$ret,$nonl) = @_;
|
||||
|
||||
if($ret) {
|
||||
$ret = utf8ToLatin1($ret) if( $hash->{encoding} eq "latin1" );
|
||||
$ret = "\n$ret\n$hash->{prompt} " if(!$nonl); # AsyncOutput stuff
|
||||
for(;;) {
|
||||
my $l = syswrite($hash->{CD}, $ret);
|
||||
last if(!$l || $l == length($ret));
|
||||
@ -380,7 +382,7 @@ CommandTelnetInform($$)
|
||||
} elsif($param eq "log") {
|
||||
$logInform{$name} = sub($$){
|
||||
my ($me, $msg) = @_; # _NO_ Log3 here!
|
||||
telnet_Output($defs{$me}, $msg."\n");
|
||||
telnet_Output($defs{$me}, $msg."\n", 1);
|
||||
}
|
||||
|
||||
} elsif($param ne "off") {
|
||||
|
@ -495,7 +495,7 @@ FW_inlineModify() // Do not generate a new HTML page upon pressing modify
|
||||
}
|
||||
});
|
||||
|
||||
$("div input.psc[type=submit]").click(function(e){
|
||||
$("div input.psc[type=submit]:not(.get)").click(function(e){
|
||||
e.preventDefault();
|
||||
var newDef = typeof cm !== 'undefined' ?
|
||||
cm.getValue() : $(this).closest("form").find("textarea").val();
|
||||
|
Loading…
x
Reference in New Issue
Block a user