From 3e91149c63f7a10d6705666e2ed079061633c290 Mon Sep 17 00:00:00 2001 From: hcs-svn Date: Sun, 26 Oct 2014 21:17:18 +0000 Subject: [PATCH] 98_CustomReadings.pm: added CustomReadings_GetHTML (see commandref) git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6814 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_CustomReadings.pm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/98_CustomReadings.pm b/fhem/FHEM/98_CustomReadings.pm index e66593a29..e95c3669d 100644 --- a/fhem/FHEM/98_CustomReadings.pm +++ b/fhem/FHEM/98_CustomReadings.pm @@ -66,7 +66,7 @@ sub CustomReadings_read($) readingsEndUpdate($hash, 1); foreach my $r (keys %{$hash->{READINGS}}) { - if (not $r ~~ @used ) { + if (not $r ~~ @used) { delete $hash->{READINGS}{$r}; } } @@ -85,6 +85,25 @@ CustomReadings_Undef($$) return undef; } +sub CustomReadings_GetHTML ($) +{ + my ($name) = @_; + my $hash = $main::defs{$name}; + my $result = ""; + + $result .= ""; + foreach my $reading (keys %{$hash->{READINGS}}) { + $result .= ""; + $result .= ""; + $result .= ""; + } + $result .= "
$reading: " . ReadingsVal($name, $reading, "???") . "
"; + + return $result; +} + + + 1; @@ -106,6 +125,7 @@ CustomReadings_Undef($$)
define myReadings CustomReadings
attr myReadings room 0-Test
+attr myReadings group Readings
attr myReadings interval 2
attr myReadings readingDefinitions hdd_temperature:qx(hddtemp /dev/sda 2>&1),
ac_powersupply_voltage:qx(cat /sys/class/power_supply/ac/voltage_now 2>&1) / 1000000,
@@ -117,6 +137,13 @@ device_name:$hash->{NAME},
bullshit: $hash->{bullshit},
fhem_backup_folder_size:qx(du -ch /opt/fhem/backup | grep total | cut -d 't' -f1 2>&1)
+

+Optionally, to display the readings:
+define myReadingsDisplay weblink htmlCode {CustomReadings_GetHTML('myReadings')}
+attr myReadingsDisplay group Readings
+attr myReadingsDisplay room 0-Test
+ +
Resulting readings: