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.
|
||||
# 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
|
||||
period if value is 0 between two periods with values
|
||||
are set
|
||||
|
@ -1260,17 +1260,7 @@ FW_doDetail($)
|
||||
FW_pO FW_detailSelect($d, "attr", $attrList);
|
||||
|
||||
FW_makeTable("Attributes", $d, $attr{$d}, "deleteattr");
|
||||
## dependent objects
|
||||
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_makeTableFromArray("Probably associated with", "assoc", getPawList($d));
|
||||
|
||||
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 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"
|
||||
if($d ne "global");
|
||||
my $sfx = AttrVal("global", "language", "EN");
|
||||
|
@ -888,7 +888,7 @@ The following local attributes are used by a wider range of devices:
|
||||
<ul>
|
||||
<code>list [devspec] [value]</code><br>
|
||||
or<br>
|
||||
<code>list -r devspec</code><br>
|
||||
<code>list {-r|-R} devspec</code><br>
|
||||
<br><br>
|
||||
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
|
||||
@ -950,7 +950,9 @@ The following local attributes are used by a wider range of devices:
|
||||
[...]
|
||||
</code></pre>
|
||||
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>
|
||||
|
||||
<a name="modify"></a>
|
||||
|
@ -937,7 +937,7 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
<ul>
|
||||
<code>list [devspec] [value]</code><br>
|
||||
oder<br>
|
||||
<code>list -r devspec</code><br>
|
||||
<code>list {-r|-R} devspec</code><br>
|
||||
<br><br>
|
||||
Auflistung aller "definitions", "notify" und
|
||||
"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>
|
||||
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>
|
||||
|
||||
|
||||
|
34
fhem/fhem.pl
34
fhem/fhem.pl
@ -114,6 +114,7 @@ sub fhemTzOffset($);
|
||||
sub getAllAttr($);
|
||||
sub getAllGets($);
|
||||
sub getAllSets($);
|
||||
sub getPawList($);
|
||||
sub getUniqueId();
|
||||
sub latin1ToUtf8($);
|
||||
sub myrename($$$);
|
||||
@ -2187,9 +2188,17 @@ CommandList($$)
|
||||
my ($cl, $param) = @_;
|
||||
my $str = "";
|
||||
|
||||
if($param =~ m/^-r *(.*)$/) {
|
||||
my @list = devspec2array($1 ? $1 : ".*", $cl);
|
||||
foreach my $d (sort @list) {
|
||||
if($param =~ m/^-r *(.*)$/i) {
|
||||
my @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}));
|
||||
$str .= "\n" if($str);
|
||||
my @a = GetDefAndAttr($d);
|
||||
@ -4802,7 +4811,7 @@ parseParams($;$)
|
||||
$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
|
||||
my $count = 0;
|
||||
for my $i (0..length($value)-1) {
|
||||
@ -4835,5 +4844,22 @@ parseParams($;$)
|
||||
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;
|
||||
|
@ -602,23 +602,32 @@ FW_rawDef()
|
||||
$("#content").append('<div id="rawDef">'+
|
||||
'<textarea id="td_longText" rows="25" cols="60" style="width:99%"/>'+
|
||||
'<button>Execute commands</button>'+
|
||||
' Dump "Probably associated with" too <input type="checkbox">'+
|
||||
'</div></br>');
|
||||
|
||||
FW_cmd(FW_root+"?cmd=list -r "+dev+"&XHR=1", function(data) {
|
||||
data = data.replace(/^define/, "defmod");
|
||||
$("#rawDef textarea").val(data);
|
||||
var off = $("#rawDef").position().top-20;
|
||||
$('body, html').animate({scrollTop:off}, 500);
|
||||
$("#rawDef button").hide();
|
||||
function
|
||||
fillData(opt)
|
||||
{
|
||||
FW_cmd(FW_root+"?cmd=list "+opt+" "+dev+"&XHR=1", function(data) {
|
||||
var re = new RegExp("^define", "gm");
|
||||
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() {
|
||||
var nData = $("#rawDef textarea").val();
|
||||
if(nData != data)
|
||||
$("#rawDef button").show();
|
||||
else
|
||||
$("#rawDef button").hide();
|
||||
$('#rawDef textarea').bind('input propertychange', function() {
|
||||
var nData = $("#rawDef textarea").val();
|
||||
if(nData != data)
|
||||
$("#rawDef button").show();
|
||||
else
|
||||
$("#rawDef button").hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
fillData("-r");
|
||||
|
||||
$("#rawDef input").click(function(){fillData(this.checked ?"-R":"-r")});
|
||||
|
||||
$("#rawDef button").click(function(){
|
||||
var data = $("#rawDef textarea").val();
|
||||
|
Loading…
x
Reference in New Issue
Block a user