FHEM Forum

FHEM => Frontends => readingsGroup / readingsHistory => Thema gestartet von: mumpitzstuff am 29 März 2018, 16:36:40

Titel: [halb gelöst]Spalte in Readingsgroup verkleinern?
Beitrag von: mumpitzstuff am 29 März 2018, 16:36:40
Besteht die Möglichkeit eine oder mehrere Spalten in einer readingsGroup schmaler zu machen? Ich habe jetzt alles versucht, komme aber nicht weiter.

Meine readingsGroup sieht wie folgt aus:

defmod rg_Abfall readingsGroup ABFALL_LEERUNG:Restmuell_weekday,Restmuell_date,<%dustbin@red>,Restmuell_days,Restmuell_daysnext,Restmuell_text\
ABFALL_LEERUNG:Rund_weekday,Rund_date,<%dustbin@green>,Rund_days,Rund_daysnext,Rund_text\
ABFALL_LEERUNG:Flach_weekday,Flach_date,<%dustbin@limegreen>,Flach_days,Flach_daysnext,Flach_text\
ABFALL_LEERUNG:Biogut_weekday,Biogut_date,<%dustbin@yellow>,Biogut_days,Biogut_daysnext,Biogut_text\

attr rg_Abfall nonames 1
attr rg_Abfall room KALENDER
attr rg_Abfall valueColumns {\
  'r:1,c:3' => 'colspan="3"',\
  'r:2,c:3' => 'colspan="3"',\
  'r:3,c:3' => 'colspan="3"',\
  'r:4,c:3' => 'colspan="3"'\
}
attr rg_Abfall valueStyle {\
  my $bcolor = 'white';;\
\
  if ('1' eq $VALUE)\
  {\
    $bcolor = 'red';;\
  }\
  elsif ('2' eq $VALUE)\
  {\
    $bcolor = 'orange';;\
  }\
  else\
  {     \
    $bcolor = 'green';;\
  }\
\
  if ($READING =~ /_days$/)\
  {\
    'style="width:16px;;height:16px;;border-radius:8px;;background-color:'.$bcolor.';;font-size:10px;;font-weight:600;;text-align:center;;position:relative;;left:-29px;;top:-10px;;"';;\
  }\
  elsif ($READING =~ /_daysnext$/)\
  {\
    'style="width:16px;;height:16px;;border-radius:8px;;background-color:'.$bcolor.';;font-size:10px;;font-weight:600;;text-align:center;;position:relative;;left:-48px;;top:-10px;;"';;\
  }\
}


Ich möchte den Abstand z.B. zwischen Restmüll und den zwei Punkten verkleinern. Das Attribut valueColumns hat übrigens keinerlei Auswirkungen auf das Aussehen.
Titel: Antw:Spalte in Readingsgroup verkleinern?
Beitrag von: mumpitzstuff am 29 März 2018, 23:03:16
Habe mir jetzt damit behelfen können:

defmod rg_Abfall readingsGroup ABFALL_LEERUNG:Restmuell_weekday,Restmuell_date,Restmuell_text,<%dustbin@red>,<{recyclebinCounter($DEVICE,'Restmuell_')}@state>\
ABFALL_LEERUNG:Rund_weekday,Rund_date,Rund_text,<%dustbin@green>,<{recyclebinCounter($DEVICE,'Rund_')}@state>\
ABFALL_LEERUNG:Flach_weekday,Flach_date,Flach_text,<%dustbin@limegreen>,<{recyclebinCounter($DEVICE,'Flach_')}@state>\
ABFALL_LEERUNG:Biogut_weekday,Biogut_date,Biogut_text,<%dustbin@yellow>,<{recyclebinCounter($DEVICE,'Biogut_')}@state>
attr rg_Abfall nonames 1
attr rg_Abfall room KALENDER
attr rg_Abfall valueStyle {\
  my $color;;   \
\
  if ($READING =~ /^(Restmuell_|Rund_|Flach_|Biogut_)/)\
  {\
    my $days = ReadingsVal($DEVICE, $1.'days', 0);;\
\
    $color = (1 == $days ? 'red' : 2 == $days ? 'darkorange' : 'white');;\
  }\
\
  return 'style="color:'.$color.'"';;\
}


sub recyclebinCounter($$)
{
  my ($device, $reading) = @_;
  my $days = ReadingsVal($device, $reading.'days', 'na');
  my $daysnext = ReadingsVal($device, $reading.'daysnext', 'na');
  my $color_days = ('1' eq $days ? 'red' : '2' eq $days ? 'darkorange' : 'green');
 
  return '<div style="width:16px;height:14px;border-radius:14px;color:white;background-color:'.
         $color_days.
         ';font-size:10px;font-weight:700;text-align:center;position:relative;padding-top:1%;'.
         'left:-29px;top:-4px;">'.$days.'</div>'.
         '<div style="width:16px;height:14px;border-radius:14px;color:white;'.
         'border:1px solid white;'.
         'font-size:10px;font-weight:700;text-align:center;position:relative;padding-top:1%;'.
         'left:-11px;top:-19px;">'.$daysnext.'</div>';
}