57_Calendar: line parsing rewritten, care for missing modification timestamps

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@6690 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2014-10-05 14:14:23 +00:00
parent d1bce151bb
commit 5e85bcc7eb
2 changed files with 21 additions and 10 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: 57_Calendar: line parsing rewritten, care for missing
modification timestamps
- change: SYSMON: support userReadings in SYSMON_ShowValues - change: SYSMON: support userReadings in SYSMON_ShowValues
- change: 59_Weather: change icon for condition clear to sunny.png - change: 59_Weather: change icon for condition clear to sunny.png
- bugfix: 57_Calendar: calendar event anymore in modeAlarmed if started - bugfix: 57_Calendar: calendar event anymore in modeAlarmed if started

View File

@ -36,8 +36,10 @@ package main;
# #
# There might be issues when turning to daylight saving time and back that # There might be issues when turning to daylight saving time and back that
# need further investigation. For reference please see # need further investigation. For reference please see
# http://forum.fhem.de/index.php?topic=18707.new#new # http://forum.fhem.de/index.php?topic=18707.new
# http://forum.fhem.de/index.php?topic=15827.new;topicseen#new # http://forum.fhem.de/index.php?topic=15827.new
#
# Continuation lines are only partially honored, e.g. not for descriptions
# #
# Potential future extensions: add support for EXDATE # Potential future extensions: add support for EXDATE
# http://forum.fhem.de/index.php?topic=24485.new#new # http://forum.fhem.de/index.php?topic=24485.new#new
@ -65,19 +67,22 @@ sub new {
sub addproperty { sub addproperty {
my ($self,$line)= @_; my ($self,$line)= @_;
# contentline = name *(";" param ) ":" value CRLF [Page 13]
# example:
# TRIGGER;VALUE=DATE-TIME:20120531T150000Z # TRIGGER;VALUE=DATE-TIME:20120531T150000Z
#main::Debug "line= $line"; #main::Debug "line=\'$line\'";
# for DTSTART, DTEND there are several variants: # for DTSTART, DTEND there are several variants:
# DTSTART;TZID=Europe/Berlin:20140205T183600 # DTSTART;TZID=Europe/Berlin:20140205T183600
# * DTSTART;TZID="(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna":20140904T180000 # * DTSTART;TZID="(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna":20140904T180000
# DTSTART:20140211T212000Z # DTSTART:20140211T212000Z
# DTSTART;VALUE=DATE:20130619 # DTSTART;VALUE=DATE:20130619
my ($property,$parameter)= split(":", $line,2); # TRIGGER;VALUE=DATE-TIME 20120531T150000Z my ($key,$parts,$parameter);
#main::Debug "property= $property parameter= $parameter"; if($line =~ /^([\w\d\-]+)(;(.*))?:(.*)$/) {
my ($key,$parts)= split(";", $property,2); $key= $1;
#main::Debug "key= $key parts= $parts"; $parts= defined($3) ? $3 : "";
$parts= "" unless(defined($parts)); $parameter= defined($4) ? $4 : "";
$parameter= "" unless(defined($parameter)); }
#main::Debug "-> key=\'$key\' parts=\'$parts\' parameter=\'$parameter\'";
if($key eq "EXDATE") { if($key eq "EXDATE") {
push @{$self->{properties}{exdates}}, $parameter; push @{$self->{properties}{exdates}}, $parameter;
} }
@ -738,7 +743,11 @@ sub updateFromCalendar {
$event->setMode($self->event($uid)->mode()); # copy the mode from the existing event $event->setMode($self->event($uid)->mode()); # copy the mode from the existing event
#main::Debug "Our lastModified: " . ts($self->event($uid)->lastModified()); #main::Debug "Our lastModified: " . ts($self->event($uid)->lastModified());
#main::Debug "New lastModified: " . ts($event->lastModified()); #main::Debug "New lastModified: " . ts($event->lastModified());
if($self->event($uid)->lastModified() != $event->lastModified()) { if(
defined($self->event($uid)->lastModified()) &&
defined($event->lastModified()) &&
($self->event($uid)->lastModified() != $event->lastModified())
) {
$event->setState("updated"); $event->setState("updated");
#main::Debug "We set it to updated."; #main::Debug "We set it to updated.";
} else { } else {