mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
00_ZWDongle.pm: neighborlist map stuff (Forum #54574)
git-svn-id: https://svn.fhem.de/fhem/trunk@11790 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9161aaa577
commit
682c96fe2d
@ -89,7 +89,7 @@ ZWDongle_Initialize($)
|
||||
$hash->{AttrFn} = "ZWDongle_Attr";
|
||||
$hash->{UndefFn} = "ZWDongle_Undef";
|
||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 model:ZWDongle disable:0,1 ".
|
||||
"homeId networkKey neighborListPos";
|
||||
"homeId networkKey neighborListPos neighborListFmt";
|
||||
$hash->{FW_detailFn} = "ZWDongle_fhemwebFn";
|
||||
}
|
||||
|
||||
@ -148,7 +148,6 @@ ZWDongle_fhemwebFn($$$$)
|
||||
my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
|
||||
|
||||
my $js = "$FW_ME/pgm2/zwave_neighborlist.js";
|
||||
my $np = AttrVal($d,'neighborListPos','360,430');
|
||||
|
||||
return
|
||||
"<div id='ZWDongleNr'><a id='zw_snm' href='#'>Show neighbor map</a></div>".
|
||||
@ -173,27 +172,41 @@ ZWDongle_nlData($)
|
||||
my @a = devspec2array("TYPE=ZWave,FILTER=IODev=$d");
|
||||
my (@dn, %nb, @ret);
|
||||
|
||||
my $fmt = eval AttrVal($d, "neighborListFmt",
|
||||
'{ txt=>"NAME", img=>"IMAGE", title=>"Time to ack: timeToAck" }');
|
||||
|
||||
for my $e (@a) {
|
||||
next if($defs{$e}{ZWaveSubDevice} ne "no");
|
||||
|
||||
my $title = ReadingsVal($e, "timeToAck", "");
|
||||
$title = "timeToAck: $title" if($title);
|
||||
|
||||
my $img = ZWave_getPic(ReadingsVal($e, "modelId", ""));
|
||||
my $h = $defs{$e};
|
||||
next if($h->{ZWaveSubDevice} ne "no");
|
||||
$h->{IMAGE} = ZWave_getPic(ReadingsVal($e, "modelId", ""));
|
||||
|
||||
my $nl = ReadingsVal($e, "neighborList", "");
|
||||
$nl =~ s/,/ /g; $nl =~ s/\bempty\b//g;
|
||||
my $pos = AttrVal($e, "neighborListPos", "");
|
||||
push @dn, $e if($nl =~ m/\b$d\b/);
|
||||
$nl = ReadingsVal($d, "neighborList_".hex($h->{nodeIdHex}), "")
|
||||
if(!$nl);
|
||||
|
||||
$nl =~ s/,/ /g; $nl =~ s/\bempty\b//g;
|
||||
push @dn, $e if($nl =~ m/\b$d\b/);
|
||||
$nl = '"'.join('","',split(" ", $nl)).'"' if($nl);
|
||||
push @ret, "\"$e\":{\"txt\":\"$e\",\"pos\":[$pos],\"class\":\"zwBox\",".
|
||||
"\"neighbors\":[$nl]".
|
||||
($title ? ",\"title\" : \"$title\"" : "").
|
||||
($img ? ",\"img\" : \"$img\"" : "").
|
||||
"}";
|
||||
|
||||
my %line = (
|
||||
pos => '['.AttrVal($e, "neighborListPos", "").']',
|
||||
class => '"zwBox"',
|
||||
neighbors => '['.$nl.']'
|
||||
);
|
||||
|
||||
my $r = $h->{READINGS};
|
||||
my $a = $attr{$e};
|
||||
for my $key (keys %{$fmt}) {
|
||||
my $val = $fmt->{$key};
|
||||
$val =~ s/\b(\w+)\b/{ $h->{$1} ? $h->{$1} :
|
||||
$r->{$1} ? $r->{$1} :
|
||||
$a->{$1} ? $a->{$1} : $1 }/ge;
|
||||
$line{$key} = "\"$val\"" if($val ne $fmt->{$key}); # Skip unchanged
|
||||
}
|
||||
push @ret, "\"$e\":{". join(',',map({"\"$_\":$line{$_}" } keys %line)) ."}";
|
||||
$nb{$e} = $nl;
|
||||
}
|
||||
|
||||
my $pos = AttrVal($d, "neighborListPos", "");
|
||||
my $nl = (@dn ? '"'.join('","',@dn).'"' : '');
|
||||
push @ret, "\"$d\":{\"txt\":\"$d\", \"pos\":[$pos],".
|
||||
@ -1120,6 +1133,21 @@ ZWDongle_Ready($)
|
||||
<li><a name="networkKey">networkKey</a><br>
|
||||
Needed for secure inclusion, hex string with length of 32
|
||||
</li>
|
||||
<li><a name="neighborListPos">neighborListPos</a><br>
|
||||
Used by the "Show neighbor map" function in the FHEMWEB ZWDongle detail
|
||||
screen to store the position of the box.
|
||||
</li>
|
||||
<li><a name="neighborListFmt">neighborListFmt</a><br>
|
||||
Used by the "Show neighbor map" function in the FHEMWEB ZWDongle detail
|
||||
screen. The value is a perl hash, specifiying the values for the keys
|
||||
txt, img and title. In the value each word is replaced by the
|
||||
corresponding Internal, Reading or Attribute of the device, if there is
|
||||
one to replace. Default is
|
||||
<ul><code>
|
||||
{ txt=>"NAME", img=>"IMAGE", title=>"Time to ack: timeToAck" }
|
||||
</code></ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
@ -5230,6 +5230,7 @@ s2Hex($)
|
||||
text after an update. </li>
|
||||
|
||||
<li><a href="#ignore">ignore</a></li>
|
||||
<li><a href="#neighborListPos">neighborListPos</a></li>
|
||||
<li><a href="#noExplorerFrames">noExplorerFrames</a><br>
|
||||
turn off the use of Explorer Frames
|
||||
</li>
|
||||
|
@ -149,7 +149,7 @@ function
|
||||
zw_drawbox(o)
|
||||
{
|
||||
var s = '';
|
||||
s += '<g data-name="'+o.txt+'">';
|
||||
s += '<g data-name="'+o.name+'">';
|
||||
if(o.title)
|
||||
s += '<title>'+o.title+'</title>';
|
||||
s += '<rect x="'+o.x+'" y="'+o.y+'" rx="5" ry="5" '+
|
||||
@ -203,19 +203,20 @@ zw_adjustLines(h, name)
|
||||
var la = h[name].lines;
|
||||
for(var i1=0; i1<la.length; i1++) {
|
||||
var se = la[i1].split('-');
|
||||
var attName = la[i1].replace(".", "\\.");
|
||||
if(la[i1].indexOf(name) == 0) { // we are the from line
|
||||
var p = zw_calcPos(h[se[0]], h[se[1]]);
|
||||
$("svg line[data-name="+la[i1]+"]")
|
||||
$("svg line[data-name="+attName+"]")
|
||||
.attr("x1", p.x)
|
||||
.attr("y1", p.y);
|
||||
} else {
|
||||
var p = zw_calcPos(h[se[1]], h[se[0]]);
|
||||
$("svg line[data-name="+la[i1]+"]")
|
||||
$("svg line[data-name="+attName+"]")
|
||||
.attr("x2", p.x)
|
||||
.attr("y2", p.y);
|
||||
}
|
||||
if (navigator.appVersion.indexOf("Trident") != -1) {
|
||||
var svgNode = $("svg line[data-name="+la[i1]+"]")[0];
|
||||
var svgNode = $("svg line[data-name="+attName+"]")[0];
|
||||
svgNode.parentNode.insertBefore(svgNode, svgNode);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user