From b54e727f6ed132f7c4344504a03df1dc914ddc61 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 25 Jun 2013 08:55:15 +0000 Subject: [PATCH] InternalVal added git-svn-id: https://svn.fhem.de/fhem/trunk@3331 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 4 +++- fhem/FHEM/01_FHEMWEB.pm | 20 ++++++++++---------- fhem/docs/commandref_frame.html | 13 ++++++++++--- fhem/docs/commandref_frame_DE.html | 26 ++++++++++++++++---------- fhem/fhem.pl | 11 +++++++++++ 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 6ef642984..99d4618fc 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +1,8 @@ # Add changes at the top of the list. Keep it in ASCII - SVN - - feature: new module speedtest to monitor internet connection speed with speedtest-cli + - feature: InternalVal function added (like ReadingsVal) + - feature: new module speedtest to monitor internet connection speed with + speedtest-cli - feature: new module "remotecontrol" to display a graphical remotecontrol for any device - feature: HUEDevice: new attribute color-icons to colored svg icons diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index f64aaa6ab..bd0679062 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -24,7 +24,7 @@ sub FW_htmlEscape($); sub FW_logWrapper($); sub FW_makeEdit($$$); sub FW_makeImage(@); -sub FW_makeTable($$@); +sub FW_makeTable($$$@); sub FW_makeTableFromArray($@); sub FW_pF($@); sub FW_pH(@); @@ -664,11 +664,12 @@ FW_updateHashes() ############################## sub -FW_makeTable($$@) +FW_makeTable($$$@) { - my($name, $hash, $cmd) = (@_); + my($title, $name, $hash, $cmd) = (@_); return if(!$hash || !int(keys %{$hash})); + FW_pO $title; FW_pO ""; my $si = AttrVal("global", "showInternalValues", 0); @@ -758,7 +759,7 @@ FW_makeSelect($$$$) # Initial setting FW_pO ""; - FW_pO ""; + FW_pO "

"; } ############################## @@ -798,16 +799,15 @@ FW_doDetail($) FW_pO FW_hidden("detail", $d); FW_makeSelect($d, "set", getAllSets($d), "set"); - FW_makeTable($d, $h); # Internal values - FW_pO "Readings" if($h->{READINGS}); - FW_makeTable($d, $h->{READINGS}); # Readings + FW_makeTable("Internals", $d, $h); + FW_makeTable("Readings", $d, $h->{READINGS}); my $attrList = getAllAttr($d); my $roomList = join(",", sort grep !/ /, keys %FW_rooms); $attrList =~ s/room /room:$roomList /; - FW_makeSelect($d, "attr", $attrList,"attr"); - FW_makeTable($d, $attr{$d}, "deleteattr"); # Attributes + + FW_makeTable("Attributes", $d, $attr{$d}, "deleteattr"); ## dependent objects my @dob; # dependent objects - triggered by current device @@ -838,7 +838,7 @@ FW_makeTableFromArray($@) { my ($txt,@obj) = @_; if (@obj>0) { my $row=1; - FW_pO "

"; + FW_pO "
"; FW_pO "$txt"; FW_pO '
'; foreach (sort @obj) { diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index 8450993db..2b24b5513 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -1288,15 +1288,15 @@ A line ending with \ will be concatenated with the next one, so long lines
  • Value(<devicename>)
    returns the state of the device (the string you see in paranthesis in the output of the list command). -

    +

  • OldValue(<devicename>)
  • OldTimestamp(<devicename>)
    returns the old value/timestamp of the device. -

    +

  • ReadingsVal(<devicename>,<reading>,<defaultvalue>)
    Return the reading (the value in the Readings section of "list device") -

    +

  • AttrVal(<devicename>,<attribute>,<defaultvalue>)
    Return the attribute of the device @@ -1307,6 +1307,13 @@ A line ending with \ will be concatenated with the next one, so long lines { ReadingsVal("wz", "measured-temp", "20")+0 }
    { ReadingsTimestamp("wz", "measured-temp", 0)}
    { AttrVal("wz", "room", "none") }
    +

  • +
  • + InternalVal(<devicename>,<property>,<defaultvalue>) +
    + Return the internal value (the value in the Internals section of "list + device"). +

  • diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index d60287d4b..1768ea926 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -1356,19 +1356,19 @@ ebenfalls 1 bei Urlaubstagen.

    +
    +
  • + InternalVal(<devicename>,<reading>,<defaultvalue>)
    + Gibt den Inhalt der "internal" zurück (den Inhalt der in + dem "Internals"-Abschnitt von "list device" angezeigt wird) +

  • +
  • diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 589ecdea4..5eb715af6 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -2832,6 +2832,17 @@ setGlobalAttrBeforeFork($) ########################################### # Functions used to make fhem-oneliners more readable, # but also recommended to be used by modules +sub +InternalVal($$$) +{ + my ($d,$n,$default) = @_; + if(defined($defs{$d}) && + defined($defs{$d}{$n})) { + return $defs{$d}{$n}; + } + return $default; +} + sub ReadingsVal($$$) {