Begonnen von andrejs, 27 April 2015, 09:13:48

Vorheriges Thema - Nächstes Thema


I started to create my Dashboard in FHEM and for that purpose I created attribute Group for particular devices and add groups to dashboard tab.  The problem is that except the value of the reading "state" no other data can be displayed. I would like to see also TIME of last activity  or the value of some other READINGS or INTERNALS or ATTRIBUTES. There are already some solutions in place to display TIME of the last activity using attr ShowTIme (TIME replace "state") or to define readingsGroup but this solution create additional data entries in the database. 
One of the possible solution is also to change 01_FHEMWEB Module. I made this amendment in sub FW_devState where I add the following code:

my $style = AttrVal($d, "devStateStyle", ""); #this the existing code in sub FW_devState

my $webdata;
my $delstart = '<div id=\"$d\" $style class=\"col2\">';
my $delend = '</div>';

if(AttrVal($d, "webData", undef)) {
     if(AttrVal($d, "webDatadel", undef) eq "div") {
     $delstart = '<div id=\"$d\" $style class=\"col2\">';
     $delend = '</div>';
     } elsif (AttrVal($d, "webDatadel", undef) eq "tab") {
     $delstart = "&nbsp;&nbsp;&nbsp;";
     $delend = "";
  my @tmpdata = split(',',AttrVal($d, "webData", undef));
   foreach my $tmpdata1 (@tmpdata) {
        my @tmpindata = split(":",$tmpdata1);
   if (@tmpindata==2) {
           if ($tmpindata[0] eq "time") {
      } elsif ($tmpindata[0] eq "value") {
      $webdata.=ReadingsVal($d, $tmpindata[1], undef);
      } elsif ($tmpindata[0] eq "attr") {
      $webdata.=AttrVal($d, $tmpindata[1], undef);
      } elsif ($tmpindata[0] eq "int") {
      } else {
        Log 3,"Parameter type of attr webData is not correct. Use value/time/attr/int.";
        } else {
   Log 3,"Number of parameters is not correct for attr webData. Use type1:reading1,type2:reading2...";


  if(AttrVal($d, "webDatadel", undef) eq "tab") {
  $txt = "<div id=\"$d\" $style class=\"col2\">$txt$webdata<>"; #existing line of code in sub FW_devState is changed
  } else {
  $txt = "<div id=\"$d\" $style class=\"col2\">$txt<>".$webdata;

  my $type = $defs{$d}{TYPE}; #this is the existing code in sub FW_devState

How this works? In order to add the data in fheweb you need to define attribute webData for each device. The correct syntax for attr webData is the following:

Type can be: time, value,int,attr
time - timestamp of specific reading is displayed
value - value od specific reading is displayed
int - internal of the device is displayed
attr - attribute of the device is displayed

Example for the device FHT (4 additional data):

By default each additional data is split by <div> so it is displayed in a new row. If you define for the device the value of attribute webDatadel "tab" then all additional data is displayed in the same row and between them are 3 white spaces.
I inserted the code in the FHEMWEB module and try how it works. The result was OK - see attached print screen.     

It possible to implement my proposal in FHEMWEB module? If this is not possible any other proposal which can solve may problem is more than welcome.