valuestyle einer readingsgroup mit mehreren Farben

Begonnen von Aladin222, 09 November 2020, 17:39:36

Vorheriges Thema - Nächstes Thema

Aladin222

hi @all,

ich versuche gerade in einer readingsgroup bestimmte Ausdrücke farblich zu markieren . ( SPÄT=rot , NACHT=blau usw. )

mit

{
    my $readingStart = $READING;
    $readingStart =~ s/summary$//;

{
if ($VALUE eq "SPÄT") { 'style="color:red;"' }
}


}



bekomme ich die Spätschichten alle in rot angezeigt :-)
Wenn ich nun aber versuche mit elseif oder else die nächste Schicht farblich zu markieren



{
    my $readingStart = $READING;
    $readingStart =~ s/summary$//;

{
if ($VALUE eq "SPÄT") { 'style="color:red;"' }
}
else
{
if ($VALUE eq "NACHT") { 'style="color:blue;"' }
}

}



geht es in die Hose .... entweder geht garnichts oder aber nur das letzte if wird ausgeführt und nur NACHT wird blau dargestellt

Icinger

Da stimmt die Klammersetzung nicht

Sollte so funktionieren:
{
    my $readingStart = $READING;
    $readingStart =~ s/summary$//;

if ($VALUE eq "SPÄT") { 'style="color:red;"' }
elsif ($VALUE eq "NACHT") { 'style="color:blue;"' }

}
Verwende deine Zeit nicht mit Erklärungen. Die Menschen hören (lesen) nur, was sie hören (lesen) wollen. (c) Paulo Coelho


Peter aus Calw

Hallo guten Abend,
habe für meine readingsgroup aus dem Forum das erhalten, was auch funktioniert :

Valuestyle:
{ if($READING eq 'E_aktuell') {'style="color:red"';;}  elsif ($READING eq
'2.8.1') {'style="color:blue"';;} elsif ($READING eq
'state') {'style="color:blue"';;}elsif ($READING eq
'SV_TVB') {'style="color:red"';;} elsif ($READING eq
'PV_JWE') {'style="color:blue"';;} elsif ($READING eq
'NT_JVB') {'style="color:red"';;} elsif ($READING eq
'HT_JVB') {'style="color:red"';;} elsif ($READING eq
'ESP_Tag') {'style="color:blue"';;}}


aber die werte werden linksbündig angezeigt, nun wollte ich das einfügen :
style="text-align:right"
aber wo oder wie wird das eingebunden ?

IR_Kopf:E_aktuell           => "4.053 kW"           2020-12-05 19:21:48
SV_Tag:SV_TVB              => "-93.190 kW"        2020-12-05 19:25:42
HT-JVB:HT_JVB               => "-1471.883 kW"    2020-12-05 19:25:42
NT-JVB:NT_JVB               => "-11684.111 kW"  2020-12-05 19:25:42
ESP-Tag:ESP_Tag            => "0.000 kW"           2020-12-05 19:25:42
PV_GSE:state                 => "50386.270 kW"   2020-12-05 19:20:22
PV_aktuell:state            => "0.000 kW"            2020-12-05 19:25:42
PV_ESP:state                 => "36928.596 kW"    2020-12-05 19:25:42
PV_tag:state                  => "3.122 kW"            2020-12-05 19:26:22
PV_JWANZ:PV_JWE         => "7487.148 kW"      2020-12-05 19:20:22

Bitte um einen Tipp Gruß Peter  :-\

amenomade

Wahrscheinlich mit
{'style="color:blue;;text-align:right"';;}
(nicht getestet)
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Peter aus Calw

Hallo, allerbesten Dank für die tolle schnelle Hilfe - Test gelungen ! :) :) :)
Hast Du auch noch einen Tipp für das :
KLI_Wzi                                alive        ok         2020-12-05 17:53:04
FS_Bad                                 alive        ok          2020-12-05 00:26:39
FS_Gäste-WC                        alive        ok          2020-12-05 14:57:24
FS_Wohnzimmer                  alive        low        2020-12-05 21:22:45


wie man die Zuständen "aliv" z.B. bei "dead" bzw. den Zustand "ok" bei "low" mit "valuestyle"farblich anpassen kann  ?
Das wäre super ! :D

amenomade

Nicht sicher, was Du willst, und was genau deine Devices für Readings haben und für Werte liefern, aber das ist reines Perl. Dann kannst Du dein if elsif elsif beliebig ergänzen.
Und Du kannst $READING testen, aber auch $VALUE, und abhängig davon entspr styles zuweisen:

if ($READING eq 'state') {
   if ($VALUE eq 'low'){'style="color:red"';;} elsif ($VALUE eq 'high') {'style="color:green"';;} else {'style="color:black"';;}
}
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Peter aus Calw

super, besten Dank, das werde ich morgen versuchen und berichten.
Der Sinn ist die überwachten Geräte (Homatik HT,Fenstersensoren usw.) in der readingsgroup anzuzeigen und bei Zustandsänderungen wie "dead" oder "low" den Anzeigetext in der Tabelle farblich zu ändern. Z.B das "dead" in rot oder "low" in gelb. Das wird zwar alles per DOIF akustisch angezeigt oder als email gesendet, aber es erleichtert das schnelle erkennen in der readingsgroup-Tabelle.
erstmal herzlichen Dank für die schnelle Hilfe und ich werde mich morgen melden.
Wünsche eine gute Nacht und liebe Grüße aus dem Nordschwarzwald von Peter 

Peter aus Calw

Hallo,
zum Verständnis hier das DEF der Readingsgroup :
KLI_Wzi:Activity,battery,<>,datum,
FS_.*:Activity,battery,<>,datum,
TH_Aussentemp:Activity,battery,<>,datum,
TH_HKRestw:Activity,battery,<>,datum,
TH_VLRL:Activity,battery,<>,datum,
HT_.*:Activity,battery,batteryLevel,datum, WT_.*:Activity,battery,batteryLevel,datum

und hier mein Versuch mit "valuestyle" :
if ($READING eq 'battery') {
   if ($VALUE eq 'low'){'style="color:red"';;} elsif ($VALUE eq 'ok') {'style="color:green"';;} else {'style="color:black"';;}
}


und hier die aktuelle Liste (Auszug) :

KLI_Wzi                              alive        ok         2020-12-06 12:59:40
FS_Bad                              alive        ok         2020-12-06 00:17:46
FS_Gäste-WC                     alive        ok         2020-12-06 10:00:46
FS_Wohnzimmer               alive        low        2020-12-06 15:30:21
Aussentemperatur_local   alive        ok          2020-12-06 15:44:02
TH_HKRestw                      alive        ok          2020-12-06 15:43:30

nun sollte "low" eigentlich in "red" angezeigt werden ? Oder wo mache ich hier einen (Denk)Fehler ?
Gruß Peter

amenomade

Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Peter aus Calw

hier das gewaltige List "Batteriekontrolle" :
Internals:
   DEF        KLI_Wzi:Activity,battery,<>,datum,
FS_.*:Activity,battery,<>,datum,
TH_Aussentemp:Activity,battery,<>,datum,
TH_HKRestw:Activity,battery,<>,datum,
TH_VLRL:Activity,battery,<>,datum,
HT_.*:Activity,battery,batteryLevel,datum,
WT_.*:Activity,battery,batteryLevel,datum
   FUUID      5e9c8a02-f33f-b3b4-6153-04a5570e6bbf2599
   NAME       Batteriekontrolle
   NR         362
   NTFY_ORDER 50-Batteriekontrolle
   STATE      Initialized
   TYPE       readingsGroup
   changed    0
   mayBeVisible 1
   CONTENT:
     FS_Bad     1
     FS_Gwc     1
     FS_Wzi     1
     HT_Bad     1
     HT_Bad_Clima 1
     HT_Bad_ClimaTeam 1
     HT_Bad_Climate 1
     HT_Bad_Weather 1
     HT_Bad_WindowRec 1
     HT_Bad_remote 1
     HT_Gwc     1
     HT_Gwc_Clima 1
     HT_Gwc_ClimaTeam 1
     HT_Gwc_Climate 1
     HT_Gwc_Weather 1
     HT_Gwc_WindowRec 1
     HT_Gwc_remote 1
     HT_Gzi     1
     HT_Gzi_Clima 1
     HT_Gzi_ClimaTeam 1
     HT_Gzi_Climate 1
     HT_Gzi_Weather 1
     HT_Gzi_WindowRec 1
     HT_Gzi_remote 1
     HT_Wz1     1
     HT_Wz1_Clima 1
     HT_Wz1_ClimaTeam 1
     HT_Wz1_Climate 1
     HT_Wz1_Weather 1
     HT_Wz1_WindowRec 1
     HT_Wz1_remote 1
     HT_Wz2     1
     HT_Wz2_Clima 1
     HT_Wz2_ClimaTeam 1
     HT_Wz2_Climate 1
     HT_Wz2_Weather 1
     HT_Wz2_WindowRec 1
     HT_Wz2_remote 1
     KLI_Wzi    1
     TH_Aussentemp 1
     TH_HKRestw 1
     TH_VLRL    1
     WT_Gzi     1
     WT_Gzi_Climate 1
     WT_Gzi_SwitchTr 1
     WT_Gzi_Weather 1
     WT_Gzi_WindowRec 1
     WT_Gzi_remote 1
     WT_Wzi     1
     WT_Wzi_Climate 1
     WT_Wzi_SwitchTr 1
     WT_Wzi_Weather 1
     WT_Wzi_WindowRec 1
     WT_Wzi_remote 1
   CONTENT2:
   DEVICES:
     ARRAY(0x56b5830)
     ARRAY(0x5db38d8)
     ARRAY(0x5243638)
     ARRAY(0x57247d8)
     ARRAY(0x5cf33c8)
     ARRAY(0x56ed028)
     ARRAY(0x56d1590)
     ARRAY(0x55124b0)
     ARRAY(0x5c72180)
     ARRAY(0x5685ae0)
     ARRAY(0x51c01e8)
     ARRAY(0x5662d50)
     ARRAY(0x5449f20)
     ARRAY(0x5a8dcf8)
     ARRAY(0x59aa690)
     ARRAY(0x58dd330)
     ARRAY(0x5d2c648)
     ARRAY(0x55e1780)
     ARRAY(0x5611840)
     ARRAY(0x5acd4c8)
     ARRAY(0x4c77a60)
     ARRAY(0x57350a0)
     ARRAY(0x5e3e7c0)
     ARRAY(0x549fb98)
     ARRAY(0x5160058)
     ARRAY(0x56e7360)
     ARRAY(0x55a8320)
     ARRAY(0x551aa70)
     ARRAY(0x5e59160)
     ARRAY(0x5552238)
     ARRAY(0x5d4cea0)
     ARRAY(0x54e33d8)
     ARRAY(0x5b58a00)
     ARRAY(0x5dd9238)
     ARRAY(0x5f913d8)
     ARRAY(0x5fc7630)
     ARRAY(0x5e73138)
     ARRAY(0x567b830)
     ARRAY(0x59b21d8)
     ARRAY(0x5c84980)
     ARRAY(0x5d0fbb0)
     ARRAY(0x59c69a0)
     ARRAY(0x54222f0)
     ARRAY(0x549fc58)
     ARRAY(0x5e82b08)
     ARRAY(0x5dbccd8)
     ARRAY(0x5a70c70)
     ARRAY(0x5f95c88)
     ARRAY(0x5638be0)
     ARRAY(0x552cc30)
     ARRAY(0x5d1deb8)
     ARRAY(0x5e45ef8)
     ARRAY(0x5e6feb0)
     ARRAY(0x56a38c8)
   fhem:
     lastDefChange 251
     last_update 1607268398.5781
   helper:
     DEF       
     valueStyle if ($READING eq 'battery') {
  if  ($VALUE eq 'low'){'style="color:red"';;} elsif ($VALUE eq 'ok') {'style="color:green"';;}
     positions:
       FS_Bad.Activity 2:1
       FS_Bad.battery 2:2
       FS_Bad.datum 2:4
       FS_Gwc.Activity 3:1
       FS_Gwc.battery 3:2
       FS_Gwc.datum 3:4
       FS_Wzi.Activity 4:1
       FS_Wzi.battery 4:2
       FS_Wzi.datum 4:4
       HT_Bad.Activity 8:1
       HT_Bad.battery 8:2
       HT_Bad.batteryLevel 8:3
       HT_Bad.datum 8:4
       HT_Gwc.Activity 15:1
       HT_Gwc.battery 15:2
       HT_Gwc.batteryLevel 15:3
       HT_Gwc.datum 15:4
       HT_Gzi.Activity 22:1
       HT_Gzi.battery 22:2
       HT_Gzi.batteryLevel 22:3
       HT_Gzi.datum 22:4
       HT_Wz1.Activity 29:1
       HT_Wz1.battery 29:2
       HT_Wz1.batteryLevel 29:3
       HT_Wz1.datum 29:4
       HT_Wz2.Activity 36:1
       HT_Wz2.battery 36:2
       HT_Wz2.batteryLevel 36:3
       HT_Wz2.datum 36:4
       KLI_Wzi.Activity 1:1
       KLI_Wzi.battery 1:2
       KLI_Wzi.datum 1:4
       TH_Aussentemp.Activity 5:1
       TH_Aussentemp.battery 5:2
       TH_Aussentemp.datum 5:4
       TH_HKRestw.Activity 6:1
       TH_HKRestw.battery 6:2
       TH_HKRestw.datum 6:4
       TH_VLRL.Activity 7:1
       TH_VLRL.battery 7:2
       TH_VLRL.datum 7:4
       WT_Gzi.Activity 43:1
       WT_Gzi.battery 43:2
       WT_Gzi.batteryLevel 43:3
       WT_Gzi.datum 43:4
       WT_Wzi.Activity 49:1
       WT_Wzi.battery 49:2
       WT_Wzi.batteryLevel 49:3
       WT_Wzi.datum 49:4
     values:
       formated:
         undef
         ARRAY(0x5f16ff0)
         ARRAY(0x54dafe0)
         ARRAY(0x55ff648)
         ARRAY(0x5dfe618)
       orig:
         undef
         ARRAY(0x57f6ee0)
         ARRAY(0x521b390)
         ARRAY(0x5db1538)
         ARRAY(0x59b3890)
       prefixsuffix:
         undef
         ARRAY(0x5d7e2d8)
         ARRAY(0x5526428)
         ARRAY(0x57057b8)
         ARRAY(0x549b868)
Attributes:
   group      Batteriekontrolle
   room       Gerate-Report
   valueStyle if ($READING eq 'battery') {
  if  ($VALUE eq 'low'){'style="color:red"';;} elsif ($VALUE eq 'ok') {'style="color:green"';;}

amenomade

Du musst das ganze noch in geschweifte Klammern setzen
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Peter aus Calw

jetzt hab ich verschiedene Klammervariationen ausprobiert und alle werden als fehler erkannt - habe keine Ahnung wo die stehen müssen ? :-[

if ($READING eq 'battery') {
  if  ($VALUE eq 'low'){'style="color:red"';;} elsif ($VALUE eq 'ok') {'style="color:green"';;}

amenomade

#13
Am Anfang, vor dem ersten if, und (ganz) am Ende

{if ($READING eq 'battery') {
  if  ($VALUE eq 'low'){'style="color:red"';;} elsif ($VALUE eq 'ok') {'style="color:green"';;}}}


EDIT: wie trägst Du das im Attribut ein? Dir hat auch noch ein } gefehlt, aber damit hätte nw. Fhem gemeckert.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Peter aus Calw

Die Variante mit 3 Klammern am Ende hat noch gefehlt, aber trotzdem ändert sich die Farbe nicht ?  :(