Hallo zusammen,
ich habe eine laienhaft zusammengefrickelte aber soweit funktionierende readingsgroup für die Ergebnisse des map - Moduls erstellt.
Jetzt möchte ich zunächst "nur" den Wert der #1_state Spalte durch die die Icons rc_RED bzw. rc_GREEN ersetzen.
Bei der Erstellung der lfd.-Nr (aus der IP) habe ich es schon nicht geschafft den Code in eine Spalte zu bekommen.
Die Lösung mit dem pauschalen Ersetzen der IP über valueFormat Attribut funktioniert nur, da die IP auch die Gruppierung ist, für die das valueFormat nicht greift.
Wie kann ich mein Vorhaben umsetzen?
Danke
Gernot
99_myUtils:
NmapNr($)
{
my ($ipV4) = @_;
my $Nr = "";
$Nr = substr($ipV4,rindex($ipV4,".")+1);
return $Nr;
}
Definition der readingsGroup nmapListe:
defmod nmapListe readingsGroup <>,<Nr>,<IP-Adresse>,<Rechner-Name>,<Online>,<MAC>,<Hersteller> \
nmap:@3,#1_ip,<#1>,(.*)_alias,#1_state,#1_macAddress,#1_macVendor
attr nmapListe cellStyle { "c:1" => 'style="text-align:right"',"c:4" => 'style="text-align:right"' }
attr nmapListe devStateIcon absent:rc_RED present:rc_GREEN .*:rc_YELLOW
attr nmapListe sortColumn 2
attr nmapListe valueFormat { NmapNr($VALUE) }
List nmap:
Internals:
DEF <>,<Nr>,<IP-Adresse>,<Rechner-Name>,<Online>,<MAC>,<Hersteller>
nmap:@3,#1_ip,<#1>,(.*)_alias,#1_state,#1_macAddress,#1_macVendor
NAME nmapListe
NR 321
NTFY_ORDER 50-nmapListe
STATE Initialized
TYPE readingsGroup
mayBeVisible 1
Content:
nmap 1
Content2:
DEVICES:
ARRAY(0xcb7cf60)
ARRAY(0x8967a10)
Helper:
Dblog:
Nmap.192.168.1.102_alias:
Logdb:
TIME 1493483346.08284
VALUE <html>iPhone_Gernot</html>
Nmap.192.168.1.102_ip:
Logdb:
TIME 1493483346.02343
VALUE <html>102</html>
Nmap.192.168.1.102_macaddress:
Logdb:
TIME 1493483345.99948
VALUE <html>80:BE:05:78:35:8F</html>
Nmap.192.168.1.102_macvendor:
Logdb:
TIME 1493483346.11707
VALUE <html>Apple</html>
Nmap.192.168.1.102_state:
Logdb:
TIME 1493483644.54902
VALUE <html>absent</html>
Nmap.192.168.1.10_alias:
Logdb:
TIME 1493485143.34436
VALUE <html>SERVER_RAUNET</html>
Nmap.192.168.1.10_ip:
Logdb:
TIME 1493485143.14641
VALUE <html>10</html>
Nmap.192.168.1.10_macaddress:
Logdb:
TIME 1493485143.33755
VALUE <html>A8:20:66:55:58:AC</html>
Nmap.192.168.1.10_macvendor:
Logdb:
TIME 1493485143.30646
VALUE <html>Apple</html>
Nmap.192.168.1.10_state:
Logdb:
TIME 1493485143.21629
VALUE <html>present</html>
Nmap.192.168.1.11_alias:
Logdb:
TIME 1493485143.24235
VALUE <html>FHEM</html>
Nmap.192.168.1.11_ip:
Logdb:
TIME 1493485143.21265
VALUE <html>11</html>
Nmap.192.168.1.11_macaddress:
Logdb:
TIME 1493485143.23918
VALUE <html>00:1C:42:55:04:BB</html>
Nmap.192.168.1.11_macvendor:
Logdb:
TIME 1493485143.29712
VALUE <html>Parallels</html>
Nmap.192.168.1.11_state:
Logdb:
TIME 1493485143.28348
VALUE <html>present</html>
Nmap.192.168.1.120_alias:
Logdb:
TIME 1493484244.04505
VALUE <html>iPad_Susanne</html>
Nmap.192.168.1.120_ip:
Logdb:
TIME 1493484243.96715
VALUE <html>120</html>
Nmap.192.168.1.120_macaddress:
Logdb:
TIME 1493484243.99064
VALUE <html>74:81:14:81:C7:7F</html>
Nmap.192.168.1.120_macvendor:
Logdb:
TIME 1493484243.94117
VALUE <html>Apple</html>
Nmap.192.168.1.120_state:
Logdb:
TIME 1493484543.32114
VALUE <html>absent</html>
Nmap.192.168.1.12_alias:
Logdb:
TIME 1493485143.26261
VALUE <html>NumanTwo</html>
Nmap.192.168.1.12_ip:
Logdb:
TIME 1493485143.17441
VALUE <html>12</html>
Nmap.192.168.1.12_macaddress:
Logdb:
TIME 1493485143.19577
VALUE <html>00:22:61:96:60:D8</html>
Nmap.192.168.1.12_macvendor:
Logdb:
TIME 1493485143.19913
VALUE <html>Frontier Silicon</html>
Nmap.192.168.1.12_state:
Logdb:
TIME 1493485143.32701
VALUE <html>present</html>
Nmap.192.168.1.1_alias:
Logdb:
TIME 1493485143.18244
VALUE <html>SpeedportLTE2</html>
Nmap.192.168.1.1_ip:
Logdb:
TIME 1493485143.27255
VALUE <html>1</html>
Nmap.192.168.1.1_macaddress:
Logdb:
TIME 1493485143.28674
VALUE <html>0C:96:BF:7A:C9:30</html>
Nmap.192.168.1.1_macvendor:
Logdb:
TIME 1493485143.16622
VALUE <html>Huawei Technologies</html>
Nmap.192.168.1.1_state:
Logdb:
TIME 1493485143.30329
VALUE <html>present</html>
Nmap.192.168.1.20_alias:
Logdb:
TIME 1493485143.19287
VALUE <html>Terrassensteuerung</html>
Nmap.192.168.1.20_ip:
Logdb:
TIME 1493485143.22157
VALUE <html>20</html>
Nmap.192.168.1.20_macaddress:
Logdb:
TIME 1493485143.20236
VALUE <html>5C:CF:7F:0F:C0:6C</html>
Nmap.192.168.1.20_macvendor:
Logdb:
TIME 1493485143.22974
VALUE <html>Espressif</html>
Nmap.192.168.1.20_state:
Logdb:
TIME 1493485143.17831
VALUE <html>present</html>
Nmap.192.168.1.24_alias:
Logdb:
TIME 1493485143.25931
VALUE <html>Gaderobe</html>
Nmap.192.168.1.24_ip:
Logdb:
TIME 1493485143.30981
VALUE <html>24</html>
Nmap.192.168.1.24_macaddress:
Logdb:
TIME 1493485143.18922
VALUE <html>5C:CF:7F:1D:F3:63</html>
Nmap.192.168.1.24_macvendor:
Logdb:
TIME 1493485143.35771
VALUE <html>Espressif</html>
Nmap.192.168.1.24_state:
Logdb:
TIME 1493485143.20916
VALUE <html>present</html>
Nmap.192.168.1.27_alias:
Logdb:
TIME 1493485143.29994
VALUE <html>Spitzbodensteuerung</html>
Nmap.192.168.1.27_ip:
Logdb:
TIME 1493485143.26927
VALUE <html>27</html>
Nmap.192.168.1.27_macaddress:
Logdb:
TIME 1493485143.2331
VALUE <html>5C:CF:7F:C3:B1:4B</html>
Nmap.192.168.1.27_macvendor:
Logdb:
TIME 1493485143.29374
VALUE <html>Espressif</html>
Nmap.192.168.1.27_state:
Logdb:
TIME 1493485143.26586
VALUE <html>present</html>
Nmap.192.168.1.2_alias:
Logdb:
TIME 1493485143.29006
VALUE <html>AirportExtreme</html>
Nmap.192.168.1.2_ip:
Logdb:
TIME 1493485143.20567
VALUE <html>2</html>
Nmap.192.168.1.2_macaddress:
Logdb:
TIME 1493485143.3476
VALUE <html>88:1F:A1:2B:1D:1E</html>
Nmap.192.168.1.2_macvendor:
Logdb:
TIME 1493485143.15645
VALUE <html>Apple</html>
Nmap.192.168.1.2_state:
Logdb:
TIME 1493485143.23595
VALUE <html>present</html>
Nmap.192.168.1.3_alias:
Logdb:
TIME 1493485143.36477
VALUE <html>AirportExpress</html>
Nmap.192.168.1.3_ip:
Logdb:
TIME 1493485143.27533
VALUE <html>3</html>
Nmap.192.168.1.3_macaddress:
Logdb:
TIME 1493485143.15297
VALUE <html>20:C9:D0:9F:D4:56</html>
Nmap.192.168.1.3_macvendor:
Logdb:
TIME 1493485143.31918
VALUE <html>Apple</html>
Nmap.192.168.1.3_state:
Logdb:
TIME 1493485143.16312
VALUE <html>present</html>
Nmap.192.168.1.4_alias:
Logdb:
TIME 1493485143.16962
VALUE <html>HomematicCCU2</html>
Nmap.192.168.1.4_ip:
Logdb:
TIME 1493485143.3542
VALUE <html>4</html>
Nmap.192.168.1.4_macaddress:
Logdb:
TIME 1493485143.36121
VALUE <html>00:1A:22:08:3D:4F</html>
Nmap.192.168.1.4_macvendor:
Logdb:
TIME 1493485143.33397
VALUE <html>eQ-3 Entwicklung GmbH</html>
Nmap.192.168.1.4_state:
Logdb:
TIME 1493485143.27893
VALUE <html>present</html>
Nmap.192.168.1.5_alias:
Logdb:
TIME 1493485143.25469
VALUE <html>SERVERFHEM</html>
Nmap.192.168.1.5_ip:
Logdb:
TIME 1493485143.15981
VALUE <html>5</html>
Nmap.192.168.1.5_state:
Logdb:
TIME 1493485143.34098
VALUE <html>present</html>
Nmap.192.168.1.8_alias:
Logdb:
TIME 1493485143.31594
VALUE <html>FritzPowerline</html>
Nmap.192.168.1.8_ip:
Logdb:
TIME 1493485143.33058
VALUE <html>8</html>
Nmap.192.168.1.8_macaddress:
Logdb:
TIME 1493485143.31312
VALUE <html>3A:31:C4:D4:3B:C0</html>
Nmap.192.168.1.8_state:
Logdb:
TIME 1493485143.32327
VALUE <html>present</html>
Nmap.192.168.1.9_alias:
Logdb:
TIME 1493485143.24955
VALUE <html>HarmonyHub</html>
Nmap.192.168.1.9_ip:
Logdb:
TIME 1493485143.18581
VALUE <html>9</html>
Nmap.192.168.1.9_macaddress:
Logdb:
TIME 1493485143.24564
VALUE <html>00:04:20:F6:28:D6</html>
Nmap.192.168.1.9_macvendor:
Logdb:
TIME 1493485143.35092
VALUE <html>Slim Devices</html>
Nmap.192.168.1.9_state:
Logdb:
TIME 1493485143.22605
VALUE <html>present</html>
Sort:
Logdb:
TIME 1493485143.36766
VALUE 2
Fhem:
lastDefChange 4
last_update 1493485413.15513
groupedList:
<br2>
192.168.1.1_ip
<192.168.1.1>
192.168.1.1_alias
192.168.1.1_state
192.168.1.1_macAddress
192.168.1.1_macVendor
<br2>
192.168.1.10_ip
<192.168.1.10>
192.168.1.10_alias
192.168.1.10_state
192.168.1.10_macAddress
192.168.1.10_macVendor
<br2>
192.168.1.101_ip
<192.168.1.101>
192.168.1.101_alias
192.168.1.101_state
192.168.1.101_macAddress
192.168.1.101_macVendor
<br2>
192.168.1.102_ip
<192.168.1.102>
192.168.1.102_alias
192.168.1.102_state
192.168.1.102_macAddress
192.168.1.102_macVendor
<br2>
192.168.1.11_ip
<192.168.1.11>
192.168.1.11_alias
192.168.1.11_state
192.168.1.11_macAddress
192.168.1.11_macVendor
<br2>
192.168.1.12_ip
<192.168.1.12>
192.168.1.12_alias
192.168.1.12_state
192.168.1.12_macAddress
192.168.1.12_macVendor
<br2>
192.168.1.120_ip
<192.168.1.120>
192.168.1.120_alias
192.168.1.120_state
192.168.1.120_macAddress
192.168.1.120_macVendor
<br2>
192.168.1.15_ip
<192.168.1.15>
192.168.1.15_alias
192.168.1.15_state
192.168.1.15_macAddress
192.168.1.15_macVendor
<br2>
192.168.1.2_ip
<192.168.1.2>
192.168.1.2_alias
192.168.1.2_state
192.168.1.2_macAddress
192.168.1.2_macVendor
<br2>
192.168.1.20_ip
<192.168.1.20>
192.168.1.20_alias
192.168.1.20_state
192.168.1.20_macAddress
192.168.1.20_macVendor
<br2>
192.168.1.21_ip
<192.168.1.21>
192.168.1.21_alias
192.168.1.21_state
192.168.1.21_macAddress
192.168.1.21_macVendor
<br2>
192.168.1.24_ip
<192.168.1.24>
192.168.1.24_alias
192.168.1.24_state
192.168.1.24_macAddress
192.168.1.24_macVendor
<br2>
192.168.1.27_ip
<192.168.1.27>
192.168.1.27_alias
192.168.1.27_state
192.168.1.27_macAddress
192.168.1.27_macVendor
<br2>
192.168.1.3_ip
<192.168.1.3>
192.168.1.3_alias
192.168.1.3_state
192.168.1.3_macAddress
192.168.1.3_macVendor
<br2>
192.168.1.4_ip
<192.168.1.4>
192.168.1.4_alias
192.168.1.4_state
192.168.1.4_macAddress
192.168.1.4_macVendor
<br2>
192.168.1.5_ip
<192.168.1.5>
192.168.1.5_alias
192.168.1.5_state
192.168.1.5_macAddress
192.168.1.5_macVendor
<br2>
192.168.1.6_ip
<192.168.1.6>
192.168.1.6_alias
192.168.1.6_state
192.168.1.6_macAddress
192.168.1.6_macVendor
<br2>
192.168.1.8_ip
<192.168.1.8>
192.168.1.8_alias
192.168.1.8_state
192.168.1.8_macAddress
192.168.1.8_macVendor
<br2>
192.168.1.9_ip
<192.168.1.9>
192.168.1.9_alias
192.168.1.9_state
192.168.1.9_macAddress
192.168.1.9_macVendor
Helper:
DEF
valueFormat { NmapNr($VALUE) }
Cellstyle:
c:1 style="text-align:right"
c:4 style="text-align:right"
Positions:
nmap.192.168.1.101_alias 5:3
nmap.192.168.1.101_ip 5:1
nmap.192.168.1.101_macAddress 5:5
nmap.192.168.1.101_macVendor 5:6
nmap.192.168.1.101_state 5:4
nmap.192.168.1.102_alias 6:3
nmap.192.168.1.102_ip 6:1
nmap.192.168.1.102_macAddress 6:5
nmap.192.168.1.102_macVendor 6:6
nmap.192.168.1.102_state 6:4
nmap.192.168.1.10_alias 4:3
nmap.192.168.1.10_ip 4:1
nmap.192.168.1.10_macAddress 4:5
nmap.192.168.1.10_macVendor 4:6
nmap.192.168.1.10_state 4:4
nmap.192.168.1.11_alias 7:3
nmap.192.168.1.11_ip 7:1
nmap.192.168.1.11_macAddress 7:5
nmap.192.168.1.11_macVendor 7:6
nmap.192.168.1.11_state 7:4
nmap.192.168.1.120_alias 9:3
nmap.192.168.1.120_ip 9:1
nmap.192.168.1.120_macAddress 9:5
nmap.192.168.1.120_macVendor 9:6
nmap.192.168.1.120_state 9:4
nmap.192.168.1.12_alias 8:3
nmap.192.168.1.12_ip 8:1
nmap.192.168.1.12_macAddress 8:5
nmap.192.168.1.12_macVendor 8:6
nmap.192.168.1.12_state 8:4
nmap.192.168.1.15_alias 10:3
nmap.192.168.1.15_ip 10:1
nmap.192.168.1.15_macAddress 10:5
nmap.192.168.1.15_macVendor 10:6
nmap.192.168.1.15_state 10:4
nmap.192.168.1.1_alias 3:3
nmap.192.168.1.1_ip 3:1
nmap.192.168.1.1_macAddress 3:5
nmap.192.168.1.1_macVendor 3:6
nmap.192.168.1.1_state 3:4
nmap.192.168.1.20_alias 12:3
nmap.192.168.1.20_ip 12:1
nmap.192.168.1.20_macAddress 12:5
nmap.192.168.1.20_macVendor 12:6
nmap.192.168.1.20_state 12:4
nmap.192.168.1.21_alias 13:3
nmap.192.168.1.21_ip 13:1
nmap.192.168.1.21_macAddress 13:5
nmap.192.168.1.21_state 13:4
nmap.192.168.1.24_alias 14:3
nmap.192.168.1.24_ip 14:1
nmap.192.168.1.24_macAddress 14:5
nmap.192.168.1.24_macVendor 14:6
nmap.192.168.1.24_state 14:4
nmap.192.168.1.27_alias 15:3
nmap.192.168.1.27_ip 15:1
nmap.192.168.1.27_macAddress 15:5
nmap.192.168.1.27_macVendor 15:6
nmap.192.168.1.27_state 15:4
nmap.192.168.1.2_alias 11:3
nmap.192.168.1.2_ip 11:1
nmap.192.168.1.2_macAddress 11:5
nmap.192.168.1.2_macVendor 11:6
nmap.192.168.1.2_state 11:4
nmap.192.168.1.3_alias 16:3
nmap.192.168.1.3_ip 16:1
nmap.192.168.1.3_macAddress 16:5
nmap.192.168.1.3_macVendor 16:6
nmap.192.168.1.3_state 16:4
nmap.192.168.1.4_alias 17:3
nmap.192.168.1.4_ip 17:1
nmap.192.168.1.4_macAddress 17:5
nmap.192.168.1.4_macVendor 17:6
nmap.192.168.1.4_state 17:4
nmap.192.168.1.5_alias 18:3
nmap.192.168.1.5_ip 18:1
nmap.192.168.1.5_state 18:4
nmap.192.168.1.6_alias 19:3
nmap.192.168.1.6_ip 19:1
nmap.192.168.1.6_macAddress 19:5
nmap.192.168.1.6_macVendor 19:6
nmap.192.168.1.6_state 19:4
nmap.192.168.1.8_alias 20:3
nmap.192.168.1.8_ip 20:1
nmap.192.168.1.8_macAddress 20:5
nmap.192.168.1.8_state 20:4
nmap.192.168.1.9_alias 21:3
nmap.192.168.1.9_ip 21:1
nmap.192.168.1.9_macAddress 21:5
nmap.192.168.1.9_macVendor 21:6
nmap.192.168.1.9_state 21:4
Values:
formated:
undef
ARRAY(0x8dcd0f8)
undef
ARRAY(0x892cbd0)
ARRAY(0xdaf44e0)
ARRAY(0xcefbd18)
ARRAY(0x926f3a0)
orig:
undef
ARRAY(0xbff6020)
undef
ARRAY(0x8d96818)
ARRAY(0x892ace8)
ARRAY(0xcca54a8)
ARRAY(0xdd424c8)
prefixsuffix:
undef
ARRAY(0xd9e0418)
undef
ARRAY(0x8ef1fb0)
ARRAY(0x918e638)
ARRAY(0xce89860)
ARRAY(0xd7297c0)
Attributes:
cellStyle { "c:1" => 'style="text-align:right"',"c:4" => 'style="text-align:right"' }
devStateIcon absent:rc_RED present:rc_GREEN .*:rc_YELLOW
room 92 Informationen
sortColumn 2
valueFormat { NmapNr($VALUE) }
Dank der Lösung von
igami habe ich eine alternative Lösung für das hervorheben der "Abwesenden".
Dennoch suche ich weiterhin eine Antwort auf Frage nach einer Möglichkeit z.B. ein valueIcon vor der Gruppierung zusetzen.
Dieses Thema werde ich schließen und dort fortsetzen, wo die Experten bereits antworten.
Zitat von: igami am 23 April 2017, 13:27:23
Ich persönlich verwende
defmod Nmap_readingsGroup readingsGroup <>,<host>,<IP>,<MAC>,<uptime>,<lastSeen>,<>\
Nmap:@1,(.*)_alias,#1_ip,!#1_macAddress,#1_uptimeText,#1_lastSeen,<>
attr Nmap_readingsGroup nameStyle style="font-weight: bold;; text-align: center;;"
attr Nmap_readingsGroup room Netzwerk
attr Nmap_readingsGroup sortColumn 0
attr Nmap_readingsGroup valueFormat {return("unknown") if($VALUE =~ m/_macAddress/);;}
attr Nmap_readingsGroup valueStyle {$READING =~ m/(.+)_/;;\
my $state = ReadingsVal($DEVICE, $1."_state", "NA");;\
my $style = "font-family: monospace;;";;\
\
return('style="color: #61CE3C;; text-align: right;; '.$style.'"') if($state eq "present" && $READING =~ m/_uptime/);;\
return('style="color: #FF0000;; text-align: right;; '.$style.'"') if($state eq "absent" && $READING =~ m/_uptime/);;\
\
return('style="color: #61CE3C;; '.$style.'"') if($state eq "present");;\
return('style="color: #FF0000;; '.$style.'"') if($state eq "absent");;\
}
Werde mir die andere DEF bei Gelegenheit mal ansehen
Ich habe es an meinen "Der Style" optisch angepasst und verwende jetzt zunächst:
defmod nmapListe readingsGroup <>,<Nr>,<IP-Adresse>,<Rechner-Name>,<MAC>,<Hersteller> \
nmap:@3,#1_ip,<#1>,(.*)_alias,#1_macAddress,#1_macVendor
attr nmapListe cellStyle { "c:1" => 'style="text-align:right"' }
attr nmapListe icon it_network
attr nmapListe room 92 Informationen
attr nmapListe sortColumn 2
attr nmapListe valueFormat { NmapNr($VALUE) }
attr nmapListe valueStyle {$READING =~ m/(.+)_/;;\
my $state = ReadingsVal($DEVICE, $1."_state", "NA");;\
my $style = "";;\
\
return('style="text-align: right;; '.$style.'"') if($state eq "present" && $READING =~ m/_uptime/);;\
return('style="color: #FF0000;; text-align: right;; '.$style.'"') if($state eq "absent" && $READING =~ m/_uptime/);;\
\
return('style="'.$style.'"') if($state eq "present");;\
return('style="color: #FF0000;; '.$style.'"') if($state eq "absent");;\
}