1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
RemovalCheck exec {
my $RemovalBlack = "off";;
my $RemovalBrown = "off";;
my $RemovalBlue = "off";;
my $RemovalYellow = "off";;
my $rcal= fhem("get Abfall text all 4");;
my @events = split ("\n", $rcal);;
my $tomorrow = strftime "%%d.%%m.%%y", localtime(time + 86400);;
foreach my $event (@events)
{
my @values = split(" ", $event);;
if ($values[0] eq $tomorrow)
{
if ($values[3] eq "Restmüll") {$RemovalBlack = "on"}
elsif ($values[3] eq "Biomüllabfuhr") {$RemovalBrown = "on"}
elsif ($values[3] eq "Papiertonne") {$RemovalBlue = "on"}
elsif ($values[3] eq "Gelber") {$RemovalYellow = "on"}
}
}
fhem("set RemovalBlack $RemovalBlack");;
fhem("set RemovalBrown $RemovalBrown");;
fhem("set RemovalBlue $RemovalBlue");;
fhem("set RemovalYellow $RemovalYellow");;
return;;
}
get Abfall text all 4
1
2
3
4
09.12.15 06:00 Abfuhrtermin Restmüll am 09.12.2015
10.12.15 06:00 Abfuhrtermin Gelber Sack am 10.12.2015
11.12.15 06:00 Abfuhrtermin Biomüllabfuhr am 11.12.2015
12.12.15 06:00 Abfuhrtermin Restmüll am 12.12.2015
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
my $RemovalBlack = "off";;
my $RemovalBrown = "off";;
my $RemovalBlue = "off";;
my $RemovalYellow = "off";;
my $rcal= fhem("get Abfall text all 4");;
my @events = split ("\n", $rcal);;
my $tomorrow = strftime "%%d.%%m.%%y", localtime(time + 86400);;
foreach my $event (@events)
{
my @values = split(" ", $event);;
if ($values[0] eq $tomorrow)
{
if ($values[3] eq "Restmüll") {$RemovalBlack = "on"}
elsif ($values[3] eq "Biomüllabfuhr") {$RemovalBrown = "on"}
elsif ($values[3] eq "Papiertonne") {$RemovalBlue = "on"}
elsif ($values[3] eq "Gelber") {$RemovalYellow = "on"}
}
}
fhem("set RemovalBlack $RemovalBlack");;
fhem("set RemovalBrown $RemovalBrown");;
fhem("set RemovalBlue $RemovalBlue");;
fhem("set RemovalYellow $RemovalYellow");;
return;;
09.12.15 06:00 Abfuhrtermin Restmüll am 09.12.2015 /n10.12.15 06:00 Abfuhrtermin Gelber Sack am 10.12.2015 /n11.12.15 06:00 Abfuhrtermin Biomüllabfuhr am 11.12.2015 /n12.12.15 06:00 Abfuhrtermin Restmüll am 12.12.2015
QuoteWie kann ich das direkt überprüfen ?
1
2
3
4
5
my $rcal= fhem("get Abfall text all 4");
print "\$rcal: $rcal\n";
my @events = split ("\n", $rcal);;
print "\@events:\n", join "\n", @events;
Quotemy $rcal sollte wahrscheinlich enthalten
1 2
warn sprintf "(D) values[0]: %s\n", $values[0]; warn sprintf "(D) tomorrow: %s\n", $tomorrow;