mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +00:00
01_FHEMWEB.pm & co: Dump "Probably associated with" in the raw definition (Forum #60599)
git-svn-id: https://svn.fhem.de/fhem/trunk@12772 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1ad11015f7
commit
4d697abbac
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 01_FHEMWEB: Dump "Probably associated with" in Raw definition
|
||||||
- bugfix: 93_DbRep: added balance diff to diffValue, balance diff to next
|
- bugfix: 93_DbRep: added balance diff to diffValue, balance diff to next
|
||||||
period if value is 0 between two periods with values
|
period if value is 0 between two periods with values
|
||||||
are set
|
are set
|
||||||
|
@ -1260,17 +1260,7 @@ FW_doDetail($)
|
|||||||
FW_pO FW_detailSelect($d, "attr", $attrList);
|
FW_pO FW_detailSelect($d, "attr", $attrList);
|
||||||
|
|
||||||
FW_makeTable("Attributes", $d, $attr{$d}, "deleteattr");
|
FW_makeTable("Attributes", $d, $attr{$d}, "deleteattr");
|
||||||
## dependent objects
|
FW_makeTableFromArray("Probably associated with", "assoc", getPawList($d));
|
||||||
my @dob; # dependent objects - triggered by current device
|
|
||||||
foreach my $dn (sort keys %defs) {
|
|
||||||
next if(!$dn || $dn eq $d);
|
|
||||||
my $dh = $defs{$dn};
|
|
||||||
if(($dh->{DEF} && $dh->{DEF} =~ m/\b$d\b/) ||
|
|
||||||
($h->{DEF} && $h->{DEF} =~ m/\b$dn\b/)) {
|
|
||||||
push(@dob, $dn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FW_makeTableFromArray("Probably associated with", "assoc", @dob,);
|
|
||||||
|
|
||||||
FW_pO "</td></tr></table>";
|
FW_pO "</td></tr></table>";
|
||||||
|
|
||||||
@ -1278,7 +1268,7 @@ FW_doDetail($)
|
|||||||
|
|
||||||
FW_pH "cmd=style iconFor $d", "Select icon", undef, "detLink iconFor";
|
FW_pH "cmd=style iconFor $d", "Select icon", undef, "detLink iconFor";
|
||||||
FW_pH "cmd=style showDSI $d", "Extend devStateIcon", undef, "detLink showDSI";
|
FW_pH "cmd=style showDSI $d", "Extend devStateIcon", undef, "detLink showDSI";
|
||||||
FW_pH "cmd=rawDef $d", "Raw defintion", undef, "detLink rawDef";
|
FW_pH "cmd=rawDef $d", "Raw definition", undef, "detLink rawDef";
|
||||||
FW_pH "cmd=delete $d", "Delete this device ($d)", undef, "detLink delDev"
|
FW_pH "cmd=delete $d", "Delete this device ($d)", undef, "detLink delDev"
|
||||||
if($d ne "global");
|
if($d ne "global");
|
||||||
my $sfx = AttrVal("global", "language", "EN");
|
my $sfx = AttrVal("global", "language", "EN");
|
||||||
|
@ -888,7 +888,7 @@ The following local attributes are used by a wider range of devices:
|
|||||||
<ul>
|
<ul>
|
||||||
<code>list [devspec] [value]</code><br>
|
<code>list [devspec] [value]</code><br>
|
||||||
or<br>
|
or<br>
|
||||||
<code>list -r devspec</code><br>
|
<code>list {-r|-R} devspec</code><br>
|
||||||
<br><br>
|
<br><br>
|
||||||
Output a list of all definitions, all notify settings and all at
|
Output a list of all definitions, all notify settings and all at
|
||||||
entries. This is one of the few commands which return a string in a
|
entries. This is one of the few commands which return a string in a
|
||||||
@ -950,7 +950,9 @@ The following local attributes are used by a wider range of devices:
|
|||||||
[...]
|
[...]
|
||||||
</code></pre>
|
</code></pre>
|
||||||
With the -r (raw) option output the device definition in a format suitable
|
With the -r (raw) option output the device definition in a format suitable
|
||||||
for inclusion in fhem.cfg and fhem.state.
|
for inclusion in fhem.cfg and fhem.state. -R returns the definition of the
|
||||||
|
device itself, together with the definition of probably associated devices.
|
||||||
|
Note: the algorithm to select associated devices is known to be imperfect.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a name="modify"></a>
|
<a name="modify"></a>
|
||||||
|
@ -937,7 +937,7 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
<ul>
|
<ul>
|
||||||
<code>list [devspec] [value]</code><br>
|
<code>list [devspec] [value]</code><br>
|
||||||
oder<br>
|
oder<br>
|
||||||
<code>list -r devspec</code><br>
|
<code>list {-r|-R} devspec</code><br>
|
||||||
<br><br>
|
<br><br>
|
||||||
Auflistung aller "definitions", "notify" und
|
Auflistung aller "definitions", "notify" und
|
||||||
"at"-Definitionen. Dies ist eines der wenigen Befehle, die im
|
"at"-Definitionen. Dies ist eines der wenigen Befehle, die im
|
||||||
@ -999,7 +999,9 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
[...]
|
[...]
|
||||||
</code></pre>
|
</code></pre>
|
||||||
Mit der -r (raw) Option werden die Daten in einem für fhem.cfg bzw.
|
Mit der -r (raw) Option werden die Daten in einem für fhem.cfg bzw.
|
||||||
fhem.state passenden format generiert.
|
fhem.state passenden Format generiert. -R liefert diese Daten auch für
|
||||||
|
alle von diesem Gerät vermutlich benögten Geräte.
|
||||||
|
Achtung: die Bestimmung dieser Liste ist ungenau.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
34
fhem/fhem.pl
34
fhem/fhem.pl
@ -114,6 +114,7 @@ sub fhemTzOffset($);
|
|||||||
sub getAllAttr($);
|
sub getAllAttr($);
|
||||||
sub getAllGets($);
|
sub getAllGets($);
|
||||||
sub getAllSets($);
|
sub getAllSets($);
|
||||||
|
sub getPawList($);
|
||||||
sub getUniqueId();
|
sub getUniqueId();
|
||||||
sub latin1ToUtf8($);
|
sub latin1ToUtf8($);
|
||||||
sub myrename($$$);
|
sub myrename($$$);
|
||||||
@ -2187,9 +2188,17 @@ CommandList($$)
|
|||||||
my ($cl, $param) = @_;
|
my ($cl, $param) = @_;
|
||||||
my $str = "";
|
my $str = "";
|
||||||
|
|
||||||
if($param =~ m/^-r *(.*)$/) {
|
if($param =~ m/^-r *(.*)$/i) {
|
||||||
my @list = devspec2array($1 ? $1 : ".*", $cl);
|
my @list;
|
||||||
foreach my $d (sort @list) {
|
my $arg = $1;
|
||||||
|
if($param =~ m/^-R/) {
|
||||||
|
return "-R needs a valid device as argument" if(!$arg);
|
||||||
|
push @list, $arg;
|
||||||
|
push @list, getPawList($arg);
|
||||||
|
} else {
|
||||||
|
@list = devspec2array($arg ? $arg : ".*", $cl);
|
||||||
|
}
|
||||||
|
foreach my $d (@list) {
|
||||||
return "No device named $d found" if(!defined($defs{$d}));
|
return "No device named $d found" if(!defined($defs{$d}));
|
||||||
$str .= "\n" if($str);
|
$str .= "\n" if($str);
|
||||||
my @a = GetDefAndAttr($d);
|
my @a = GetDefAndAttr($d);
|
||||||
@ -4802,7 +4811,7 @@ parseParams($;$)
|
|||||||
$value =~ s/^.(.*).$/$1/;
|
$value =~ s/^.(.*).$/$1/;
|
||||||
}
|
}
|
||||||
|
|
||||||
#collext all parts until opening { and closing } are matched
|
#collect all parts until opening { and closing } are matched
|
||||||
if( $value =~ m/^{/ ) { # } for match
|
if( $value =~ m/^{/ ) { # } for match
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
for my $i (0..length($value)-1) {
|
for my $i (0..length($value)-1) {
|
||||||
@ -4835,5 +4844,22 @@ parseParams($;$)
|
|||||||
return(\@a, \%h);
|
return(\@a, \%h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# get "Porbably Associated With" list for a devicename
|
||||||
|
sub
|
||||||
|
getPawList($)
|
||||||
|
{
|
||||||
|
my ($d) = @_;
|
||||||
|
my $h = $defs{$d};
|
||||||
|
my @dob;
|
||||||
|
foreach my $dn (sort keys %defs) {
|
||||||
|
next if(!$dn || $dn eq $d);
|
||||||
|
my $dh = $defs{$dn};
|
||||||
|
if(($dh->{DEF} && $dh->{DEF} =~ m/\b$d\b/) ||
|
||||||
|
($h->{DEF} && $h->{DEF} =~ m/\b$dn\b/)) {
|
||||||
|
push(@dob, $dn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return @dob;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -602,23 +602,32 @@ FW_rawDef()
|
|||||||
$("#content").append('<div id="rawDef">'+
|
$("#content").append('<div id="rawDef">'+
|
||||||
'<textarea id="td_longText" rows="25" cols="60" style="width:99%"/>'+
|
'<textarea id="td_longText" rows="25" cols="60" style="width:99%"/>'+
|
||||||
'<button>Execute commands</button>'+
|
'<button>Execute commands</button>'+
|
||||||
|
' Dump "Probably associated with" too <input type="checkbox">'+
|
||||||
'</div></br>');
|
'</div></br>');
|
||||||
|
|
||||||
FW_cmd(FW_root+"?cmd=list -r "+dev+"&XHR=1", function(data) {
|
function
|
||||||
data = data.replace(/^define/, "defmod");
|
fillData(opt)
|
||||||
$("#rawDef textarea").val(data);
|
{
|
||||||
var off = $("#rawDef").position().top-20;
|
FW_cmd(FW_root+"?cmd=list "+opt+" "+dev+"&XHR=1", function(data) {
|
||||||
$('body, html').animate({scrollTop:off}, 500);
|
var re = new RegExp("^define", "gm");
|
||||||
$("#rawDef button").hide();
|
data = data.replace(re, "defmod");
|
||||||
|
$("#rawDef textarea").val(data);
|
||||||
|
var off = $("#rawDef").position().top-20;
|
||||||
|
$('body, html').animate({scrollTop:off}, 500);
|
||||||
|
$("#rawDef button").hide();
|
||||||
|
|
||||||
$('#rawDef textarea').bind('input propertychange', function() {
|
$('#rawDef textarea').bind('input propertychange', function() {
|
||||||
var nData = $("#rawDef textarea").val();
|
var nData = $("#rawDef textarea").val();
|
||||||
if(nData != data)
|
if(nData != data)
|
||||||
$("#rawDef button").show();
|
$("#rawDef button").show();
|
||||||
else
|
else
|
||||||
$("#rawDef button").hide();
|
$("#rawDef button").hide();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
fillData("-r");
|
||||||
|
|
||||||
|
$("#rawDef input").click(function(){fillData(this.checked ?"-R":"-r")});
|
||||||
|
|
||||||
$("#rawDef button").click(function(){
|
$("#rawDef button").click(function(){
|
||||||
var data = $("#rawDef textarea").val();
|
var data = $("#rawDef textarea").val();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user