Im vorherigen Post habe ich uner anderem eine Visualisierung von Abfallterminen beschrieben. Leider konnte ich da noch keine Wochentage als Text darstellen. Nun habe ich die 99_MyUtils.pm erweitert um für einen wday Wert den Wochentag Namen zu bekommen:
package main; use strict; use warnings; use POSIX; sub myUtils_Initialize($$) { my ($hash) = @_; my $NewMailtime = time; }
# Enter you functions below _this_ line. ######## Wochentag sub wochentag($){ my $wd=shift; if($wd > 6){ $wd=$wd % 7; } my @Wochentage = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag); return $Wochentage[$wd]; } ######## Wochentag kurz sub wochentagkurz($){ my $wd=shift; if($wd > 6){ $wd=$wd % 7; } my @Wochentage = qw(So Mo Di Mi Do Fr Sa); return $Wochentage[$wd]; } ... 1;
Nun kann man dies Funktionen nach einem Neustart von fhem verwenden. In meiner rss.layout steht nun für die Abfalltermine folgendes:
text 400 60 { 'Abfalltermine 5 Tage:' } text 410 75 { sprintf('%s', wochentagkurz($wday)) } text 435 75 { sprintf('%s', wochentagkurz($wday+1)) } text 460 75 { wochentagkurz($wday+2) } text 485 75 { wochentagkurz($wday+3) } text 510 75 { wochentagkurz($wday+4) } text 535 75 { wochentagkurz($wday+5) } img 410 80 0.2 png file { '/opt/fhem/www/images/tonne_'. fhem('get abfall days 0') .'.png' } img 435 80 0.2 png file { '/opt/fhem/www/images/tonne_'. fhem('get abfall days 1') .'.png' } img 460 80 0.2 png file { '/opt/fhem/www/images/tonne_'. fhem('get abfall days 2') .'.png' } img 485 80 0.2 png file { '/opt/fhem/www/images/tonne_'. fhem('get abfall days 3') .'.png' } img 510 80 0.2 png file { '/opt/fhem/www/images/tonne_'. fhem('get abfall days 4') .'.png' } img 535 80 0.2 png file { '/opt/fhem/www/images/tonne_'. fhem('get abfall days 5') .'.png' }
und so siehts dann aus:
Die Bilder tonne_grau.png, tonne_gelb.png, tonne_papier.png, tonne_buendel.png, tonne_braun.png, tonne_none.png habe ich alle aus einem Bild generiert indem ich die Tonne in GIMP jeweils anders eingefärbt habe.