mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-01 01:09:47 +00:00
allow <{...}> expressions to be updated by longpoll
git-svn-id: https://svn.fhem.de/fhem/trunk@4374 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
78a858cffe
commit
c1f410bb58
@ -266,7 +266,6 @@ readingsGroup_2html($)
|
|||||||
my $devices = $hash->{DEVICES};
|
my $devices = $hash->{DEVICES};
|
||||||
|
|
||||||
my $row = 1;
|
my $row = 1;
|
||||||
|
|
||||||
my $ret;
|
my $ret;
|
||||||
$ret .= "<table>";
|
$ret .= "<table>";
|
||||||
my $txt = AttrVal($d, "alias", $d);
|
my $txt = AttrVal($d, "alias", $d);
|
||||||
@ -275,6 +274,7 @@ readingsGroup_2html($)
|
|||||||
$ret .= "<tr><td><table $style class=\"block wide\">";
|
$ret .= "<tr><td><table $style class=\"block wide\">";
|
||||||
$ret .= "<tr><td colspan=\"99\"><div style=\"color:#ff8888;text-align:center\">updates disabled</div></tr>" if( $disable > 0 );
|
$ret .= "<tr><td colspan=\"99\"><div style=\"color:#ff8888;text-align:center\">updates disabled</div></tr>" if( $disable > 0 );
|
||||||
foreach my $device (@{$devices}) {
|
foreach my $device (@{$devices}) {
|
||||||
|
my $item = 0;
|
||||||
my $h = $defs{$device->[0]};
|
my $h = $defs{$device->[0]};
|
||||||
my $regex = $device->[1];
|
my $regex = $device->[1];
|
||||||
if( !$h && $device->[0] =~ m/^<.*>$/ ) {
|
if( !$h && $device->[0] =~ m/^<.*>$/ ) {
|
||||||
@ -297,7 +297,11 @@ readingsGroup_2html($)
|
|||||||
my $h = $h;
|
my $h = $h;
|
||||||
if( $regex && $regex =~ m/^<(.*)>$/ ) {
|
if( $regex && $regex =~ m/^<(.*)>$/ ) {
|
||||||
my $txt = $1;
|
my $txt = $1;
|
||||||
if( $txt =~ m/^{.*}$/ ) {
|
my $readings;
|
||||||
|
if( $txt =~ m/^{(.*)}(#[\w|.*]+)?$/ ) {
|
||||||
|
$txt = "{$1}";
|
||||||
|
$readings = $2;
|
||||||
|
|
||||||
my $new_line = $first;
|
my $new_line = $first;
|
||||||
my $DEVICE = $name;
|
my $DEVICE = $name;
|
||||||
($txt,$new_line) = eval $txt;
|
($txt,$new_line) = eval $txt;
|
||||||
@ -313,8 +317,11 @@ readingsGroup_2html($)
|
|||||||
$ret .= sprintf("<tr class=\"%s\">", ($row&1)?"odd":"even");
|
$ret .= sprintf("<tr class=\"%s\">", ($row&1)?"odd":"even");
|
||||||
$row++;
|
$row++;
|
||||||
}
|
}
|
||||||
|
$item++;
|
||||||
|
my $inform_id = "";
|
||||||
|
$inform_id = "informId=\"$d-$item.item\"" if( $readings );
|
||||||
my $name_style = lookup2($name_style,$name,$1,undef);
|
my $name_style = lookup2($name_style,$name,$1,undef);
|
||||||
$ret .= "<td><div $name_style class=\"dname\">$txt</div></td>";
|
$ret .= "<td><div $name_style $inform_id class=\"dname\">$txt</div></td>";
|
||||||
$first = 0;
|
$first = 0;
|
||||||
next;
|
next;
|
||||||
} elsif( $regex && $regex =~ m/^\+(.*)/ ) {
|
} elsif( $regex && $regex =~ m/^\+(.*)/ ) {
|
||||||
@ -486,6 +493,7 @@ readingsGroup_Notify($$)
|
|||||||
$valueIcon = eval $valueIcon if( $valueIcon =~ m/^{.*}$/ );
|
$valueIcon = eval $valueIcon if( $valueIcon =~ m/^{.*}$/ );
|
||||||
|
|
||||||
foreach my $device (@{$devices}) {
|
foreach my $device (@{$devices}) {
|
||||||
|
my $item = 0;
|
||||||
my $h = $defs{@{$device}[0]};
|
my $h = $defs{@{$device}[0]};
|
||||||
next if( !$h );
|
next if( !$h );
|
||||||
next if( $dev->{NAME} ne $h->{NAME} );
|
next if( $dev->{NAME} ne $h->{NAME} );
|
||||||
@ -501,6 +509,33 @@ readingsGroup_Notify($$)
|
|||||||
next if( $reading eq "state" && !$show_state && (!defined($regex) || $regex ne "state") );
|
next if( $reading eq "state" && !$show_state && (!defined($regex) || $regex ne "state") );
|
||||||
next if( $regex && $regex =~ m/^\+/ );
|
next if( $regex && $regex =~ m/^\+/ );
|
||||||
next if( $regex && $regex =~ m/^\?/ );
|
next if( $regex && $regex =~ m/^\?/ );
|
||||||
|
if( $regex && $regex =~ m/^<(.*)>$/ ) {
|
||||||
|
my $txt = $1;
|
||||||
|
my $readings;
|
||||||
|
if( $txt =~ m/^{(.*)}(#([\w|.*]+))?$/ ) {
|
||||||
|
$txt = "{$1}";
|
||||||
|
$readings = $3;
|
||||||
|
|
||||||
|
next if( !$readings );
|
||||||
|
next if( $reading !~ m/^$readings$/);
|
||||||
|
|
||||||
|
my $new_line;
|
||||||
|
my $DEVICE = $name;
|
||||||
|
($txt,$new_line) = eval $txt;
|
||||||
|
$new_line if( defined($new_line) );
|
||||||
|
if( $@ ) {
|
||||||
|
$txt = "<ERROR>";
|
||||||
|
Log3 $name, 3, $name .": ". $regex .": ". $@;
|
||||||
|
}
|
||||||
|
$txt = "" if( !defined($txt) );
|
||||||
|
|
||||||
|
$item++;
|
||||||
|
CommandTrigger( "", "$name $item.item: $txt" );
|
||||||
|
}
|
||||||
|
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
next if( defined($regex) && $reading !~ m/^$regex$/);
|
next if( defined($regex) && $reading !~ m/^$regex$/);
|
||||||
|
|
||||||
my $value = $value;
|
my $value = $value;
|
||||||
@ -604,8 +639,9 @@ readingsGroup_Get($@)
|
|||||||
<li>If regex is a comma separatet list the reading values will be shown on a single line.</li>
|
<li>If regex is a comma separatet list the reading values will be shown on a single line.</li>
|
||||||
<li>If regex starts with a + it will be matched against the internal values of the device instead of the readings.</li>
|
<li>If regex starts with a + it will be matched against the internal values of the device instead of the readings.</li>
|
||||||
<li>If regex starts with a ? it will be matched against the attributes of the device instead of the readings.</li>
|
<li>If regex starts with a ? it will be matched against the attributes of the device instead of the readings.</li>
|
||||||
<li>regex can be of the form <STRING> or <{perl}> where STRING or the string returned by perl is
|
<li>regex can be of the form <STRING> or <{perl}[#readings]> where STRING or the string returned by perl is
|
||||||
inserted as the reading. skipped if STRING is undef.</li>
|
inserted as the reading. skipped if STRING is undef. if readings is given the perl expression will be reevaluated
|
||||||
|
during longpoll updates.</li>
|
||||||
<li>For internal values and attributes longpoll update is not possible. Refresh the page to update the values.</li>
|
<li>For internal values and attributes longpoll update is not possible. Refresh the page to update the values.</li>
|
||||||
<li>the <{perl}> expression is limited to expressions without a space. it is best just to call a small sub
|
<li>the <{perl}> expression is limited to expressions without a space. it is best just to call a small sub
|
||||||
in 99_myUtils.pm instead of having a compex expression in the define.</li>
|
in 99_myUtils.pm instead of having a compex expression in the define.</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user